Class: RuboCop::Cop::Ezcater::RspecMatchOrderedArray
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Ezcater::RspecMatchOrderedArray
- Defined in:
- lib/rubocop/cop/ezcater/rspec_match_ordered_array.rb
Overview
Enforce use of ‘match_ordered_array` matcher instead of using `eq` matcher
Constant Summary collapse
- MATCH_ORDERED_ARRAY =
"match_ordered_array"
- MSG =
"Use the `match_ordered_array` matcher from ezcater_matchers gem "\ "instead of `eq` when comparing collections"
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# 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) ⇒ Object
26 27 28 29 30 |
# 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 |