Class: RuboCop::Cop::RSpec::Eq
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/rspec/eq.rb
Overview
Use ‘eq` instead of `be ==` to compare objects.
Constant Summary collapse
- MSG =
'Use `eq` instead of `be ==` to compare objects.'
- RESTRICT_ON_SEND =
Runners.all
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#be_equals(node) ⇒ Object
23 24 25 |
# File 'lib/rubocop/cop/rspec/eq.rb', line 23 def_node_matcher :be_equals, <<~PATTERN (send _ #Runners.all $(send (send nil? :be) :== _)) PATTERN |
#on_send(node) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/rubocop/cop/rspec/eq.rb', line 27 def on_send(node) be_equals(node) do |matcher| range = offense_range(matcher) add_offense(range) do |corrector| corrector.replace(range, 'eq') end end end |