Class: RuboCop::Cop::RSpec::PredicateMatcher
- Includes:
- ConfigurableEnforcedStyle, RangeHelp, 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 InflectedHelper
InflectedHelper::MSG_INFLECTED
Constants inherited from Cop
Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE
Constants included from RSpec::Language
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#autocorrect(node) ⇒ Object
315 316 317 318 319 320 321 322 |
# File 'lib/rubocop/cop/rspec/predicate_matcher.rb', line 315 def autocorrect(node) case style when :inflected autocorrect_inflected(node) when :explicit autocorrect_explicit(node) end end |
#on_block(node) ⇒ Object
311 312 313 |
# File 'lib/rubocop/cop/rspec/predicate_matcher.rb', line 311 def on_block(node) check_explicit(node) if style == :explicit end |
#on_send(node) ⇒ Object
302 303 304 305 306 307 308 309 |
# File 'lib/rubocop/cop/rspec/predicate_matcher.rb', line 302 def on_send(node) case style when :inflected check_inflected(node) when :explicit check_explicit(node) end end |