Class: RuboCop::Cop::RSpec::Cop Abstract

Inherits:
WorkaroundCop
  • Object
show all
Includes:
RSpec::Language, RSpec::Language::NodePattern
Defined in:
lib/rubocop/cop/rspec/cop.rb

Overview

This class is 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:

Examples:

configuring analyzed paths


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

Constant Summary collapse

DEFAULT_CONFIGURATION =
RuboCop::RSpec::CONFIG.fetch('AllCops').fetch('RSpec')
DEFAULT_PATTERN_RE =
Regexp.union(
  DEFAULT_CONFIGURATION.fetch('Patterns')
                       .map(&Regexp.public_method(:new))
)

Constants included from RSpec::Language

RSpec::Language::ALL

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(subclass) ⇒ Object

Invoke the original inherited hook so our cops are recognized



53
54
55
# File 'lib/rubocop/cop/rspec/cop.rb', line 53

def self.inherited(subclass)
  RuboCop::Cop::Cop.inherited(subclass)
end

Instance Method Details

#relevant_file?(file) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/rubocop/cop/rspec/cop.rb', line 57

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