Class: RuboCop::Cop::RSpec::InvalidPredicateMatcher

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/rspec/invalid_predicate_matcher.rb

Overview

Checks invalid usage for predicate matcher.

Predicate matcher does not need a question. This cop checks an unnecessary question in predicate matcher.

Examples:


# bad
expect(foo).to be_something?

# good
expect(foo).to be_something

Constant Summary collapse

MSG =
'Omit `?` from `%<matcher>s`.'

Constants inherited from Cop

Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE

Constants included from RSpec::Language

RSpec::Language::ALL, RSpec::Language::RSPEC

Instance Method Summary collapse

Methods inherited from Cop

inherited, #relevant_file?

Instance Method Details

#on_send(node) ⇒ Object



25
26
27
28
29
# File 'lib/rubocop/cop/rspec/invalid_predicate_matcher.rb', line 25

def on_send(node)
  invalid_predicate_matcher?(node) do |predicate|
    add_offense(predicate, location: :expression)
  end
end