class RuboCop::Cop::RSpec::Cop

  • ‘(?:^|/)test/’
    - ‘_test.rb$’
    Patterns:
    RSpec:
    AllCops:
    @example configuring analyzed paths
    then you could add this to your configuration:
    customize your project to scan all files within a ‘test/` directory
    is configured via `AllCops/RSpec`. For example, if you want to
    The criteria for whether rubocop-rspec analyzes a certain ruby file
    @abstract parent class to rspec cops

def self.inherited(subclass)

Invoke the original inherited hook so our cops are recognized
def self.inherited(subclass)
  RuboCop::Cop::Cop.inherited(subclass)
end

def all_cops_config

def all_cops_config
  config
    .for_all_cops
end

def relevant_file?(file)

def relevant_file?(file)
  relevant_rubocop_rspec_file?(file) && super
end

def relevant_rubocop_rspec_file?(file)

def relevant_rubocop_rspec_file?(file)
  rspec_pattern =~ file
end

def rspec_pattern

def rspec_pattern
  if rspec_pattern_config?
    Regexp.union(rspec_pattern_config.map(&Regexp.public_method(:new)))
  else
    DEFAULT_PATTERN_RE
  end
end

def rspec_pattern_config

def rspec_pattern_config
  all_cops_config
    .fetch('RSpec', DEFAULT_CONFIGURATION)
    .fetch('Patterns')
end

def rspec_pattern_config?

def rspec_pattern_config?
  return unless all_cops_config.key?('RSpec')
  all_cops_config.fetch('RSpec').key?('Patterns')
end