lib/rubocop/cop/rspec/implicit_expect.rb in rubocop-rspec-1.18.0 vs lib/rubocop/cop/rspec/implicit_expect.rb in rubocop-rspec-1.19.0

- old
+ new

@@ -29,12 +29,12 @@ MSG = 'Prefer `%<good>s` over `%<bad>s`.'.freeze def_node_matcher :implicit_expect, <<-PATTERN { - (send nil ${:should :should_not} ...) - (send (send nil $:is_expected) {:to :to_not :not_to} ...) + (send nil? ${:should :should_not} ...) + (send (send nil? $:is_expected) {:to :to_not :not_to} ...) } PATTERN alternatives = { 'is_expected.to' => 'should', @@ -42,20 +42,24 @@ 'is_expected.to_not' => 'should_not' } ENFORCED_REPLACEMENTS = alternatives.merge(alternatives.invert).freeze - def on_send(node) + def on_send(node) # rubocop:disable Metrics/MethodLength return unless (source_range = offending_expect(node)) expectation_source = source_range.source if expectation_source.start_with?(style.to_s) correct_style_detected else opposite_style_detected - add_offense(node, source_range, offense_message(expectation_source)) + add_offense( + node, + location: source_range, + message: offense_message(expectation_source) + ) end end def autocorrect(node) lambda do |corrector|