class RuboCop::Cop::RSpec::Cop

@abstract parent class to rspec cops

The criteria for whether rubocop-rspec analyzes a certain ruby file is configured via `AllCops/RSpec`. For example, if you want to customize your project to scan all files within a `test/` directory then you could add this to your configuration:

@example configuring analyzed paths

AllCops:
  RSpec:
    Patterns:
    - '_test.rb$'
    - '(?:^|/)test/'

Constants

DEFAULT_CONFIGURATION

Public Class Methods

inherited(subclass) click to toggle source

Invoke the original inherited hook so our cops are recognized

# File lib/rubocop/cop/rspec/cop.rb, line 46
def self.inherited(subclass)
  RuboCop::Cop::Cop.inherited(subclass)
end

Public Instance Methods

relevant_file?(file) click to toggle source
Calls superclass method
# File lib/rubocop/cop/rspec/cop.rb, line 50
def relevant_file?(file)
  relevant_rubocop_rspec_file?(file) && super
end

Private Instance Methods

relevant_rubocop_rspec_file?(file) click to toggle source
# File lib/rubocop/cop/rspec/cop.rb, line 56
def relevant_rubocop_rspec_file?(file)
  rspec_pattern =~ file
end
rspec_pattern() click to toggle source
# File lib/rubocop/cop/rspec/cop.rb, line 60
def rspec_pattern
  Regexp.union(rspec_pattern_config.map(&Regexp.public_method(:new)))
end
rspec_pattern_config() click to toggle source
# File lib/rubocop/cop/rspec/cop.rb, line 64
def rspec_pattern_config
  config
    .for_all_cops
    .fetch('RSpec', DEFAULT_CONFIGURATION)
    .fetch('Patterns')
end