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
- DEFAULT_PATTERN_RE
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 53 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 57 def relevant_file?(file) relevant_rubocop_rspec_file?(file) && super end
Private Instance Methods
all_cops_config()
click to toggle source
# File lib/rubocop/cop/rspec/cop.rb, line 75 def all_cops_config config .for_all_cops end
relevant_rubocop_rspec_file?(file)
click to toggle source
# File lib/rubocop/cop/rspec/cop.rb, line 63 def relevant_rubocop_rspec_file?(file) rspec_pattern =~ file end
rspec_pattern()
click to toggle source
# File lib/rubocop/cop/rspec/cop.rb, line 67 def rspec_pattern if rspec_pattern_config? Regexp.union(rspec_pattern_config.map(&Regexp.public_method(:new))) else DEFAULT_PATTERN_RE end end
rspec_pattern_config()
click to toggle source
# File lib/rubocop/cop/rspec/cop.rb, line 86 def rspec_pattern_config all_cops_config .fetch('RSpec', DEFAULT_CONFIGURATION) .fetch('Patterns') end
rspec_pattern_config?()
click to toggle source
# File lib/rubocop/cop/rspec/cop.rb, line 80 def rspec_pattern_config? return unless all_cops_config.key?('RSpec') all_cops_config.fetch('RSpec').key?('Patterns') end