Class: RuboCop::Cop::RSpec::PredicateMatcher
- Extended by:
- AutoCorrector
- Includes:
- ConfigurableEnforcedStyle, ExplicitHelper, InflectedHelper
- Defined in:
- lib/rubocop/cop/rspec/predicate_matcher.rb
Overview
Prefer using predicate matcher over using predicate method directly.
RSpec defines magic matchers for predicate methods. This cop recommends to use the predicate matcher instead of using predicate method directly.
Constant Summary collapse
- RESTRICT_ON_SEND =
Runners.all
Constants included from ExplicitHelper
ExplicitHelper::BUILT_IN_MATCHERS, ExplicitHelper::MSG_EXPLICIT
Constants included from InflectedHelper
InflectedHelper::MSG_INFLECTED
Instance Method Summary collapse
-
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler.
- #on_send(node) ⇒ Object
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Methods inherited from Base
inherited, #on_new_investigation
Instance Method Details
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler
343 344 345 |
# File 'lib/rubocop/cop/rspec/predicate_matcher.rb', line 343 def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler check_explicit(node) if style == :explicit end |
#on_send(node) ⇒ Object
330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'lib/rubocop/cop/rspec/predicate_matcher.rb', line 330 def on_send(node) case style when :inflected check_inflected(node) when :explicit check_explicit(node) else # :nocov: :noop # :nocov: end end |