class RuboCop::Cop::RSpec::Eq
Use ‘eq` instead of `be ==` to compare objects.
@example
# bad expect(foo).to be == 42 # good expect(foo).to eq 42
Constants
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
Source
# 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
Private Instance Methods
Source
# File lib/rubocop/cop/rspec/eq.rb, line 38 def offense_range(matcher) range_between( matcher.source_range.begin_pos, matcher.loc.selector.end_pos ) end