Class: RuboCop::Cop::RSpec::PredicateMatcher
- 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
Constants included from ExplicitHelper
ExplicitHelper::BUILT_IN_MATCHERS, ExplicitHelper::MSG_EXPLICIT
Constants included from RSpec::Language
RSpec::Language::ALL, RSpec::Language::RSPEC
Constants included from InflectedHelper
InflectedHelper::MSG_INFLECTED
Constants inherited from Cop
Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#autocorrect(node) ⇒ Object
320 321 322 323 324 325 326 327 |
# File 'lib/rubocop/cop/rspec/predicate_matcher.rb', line 320 def autocorrect(node) case style when :inflected autocorrect_inflected(node) when :explicit autocorrect_explicit(node) end end |
#on_block(node) ⇒ Object
316 317 318 |
# File 'lib/rubocop/cop/rspec/predicate_matcher.rb', line 316 def on_block(node) check_explicit(node) if style == :explicit end |
#on_send(node) ⇒ Object
307 308 309 310 311 312 313 314 |
# File 'lib/rubocop/cop/rspec/predicate_matcher.rb', line 307 def on_send(node) case style when :inflected check_inflected(node) when :explicit check_explicit(node) end end |