class RuboCop::Cop::Ezcater::RspecMatchOrderedArray
Enforce use of `match_ordered_array` matcher instead of using `eq` matcher
@example
# good expect(foo).to match_ordered_array([1, 2, 3]) expect(foo).to match_ordered_array [1, 2, 3] # bad expect(foo).to eq([1, 2, 3]) expect(foo).to eq [1, 2, 3]
Constants
- MATCH_ORDERED_ARRAY
- MSG
Public Instance Methods
autocorrect(node)
click to toggle source
# File lib/rubocop/cop/ezcater/rspec_match_ordered_array.rb, line 32 def autocorrect(node) lambda do |corrector| corrector.replace( Parser::Source::Range.new( node.source_range.source_buffer, node.source_range.begin_pos, node.source_range.begin_pos + 2 ), MATCH_ORDERED_ARRAY ) end end
on_send(node)
click to toggle source
# File lib/rubocop/cop/ezcater/rspec_match_ordered_array.rb, line 26 def on_send(node) eq_array(node) do add_offense(node, location: :expression, message: MSG) end end