lib/rubocop/cop/minitest/refute_equal.rb in rubocop-minitest-0.11.1 vs lib/rubocop/cop/minitest/refute_equal.rb in rubocop-minitest-0.12.0

- old
+ new

@@ -12,12 +12,13 @@ # assert(! "rubocop-minitest" == actual) # # # good # refute_equal("rubocop-minitest", actual) # - class RefuteEqual < Cop + class RefuteEqual < Base include ArgumentRangeHelper + extend AutoCorrector MSG = 'Prefer using `refute_equal(%<preferred>s)` over ' \ '`assert(%<over>s)`.' RESTRICT_ON_SEND = %i[assert].freeze @@ -27,16 +28,13 @@ def on_send(node) preferred, over = process_not_equal(node) return unless preferred && over - message = format(MSG, preferred: preferred, over: over) - add_offense(node, message: message) - end + assert_not_equal(node) do |_, expected, actual| + message = format(MSG, preferred: preferred, over: over) - def autocorrect(node) - lambda do |corrector| - assert_not_equal(node) do |_, expected, actual| + add_offense(node, message: message) do |corrector| corrector.replace(node.loc.selector, 'refute_equal') replacement = [expected, actual].map(&:source).join(', ') corrector.replace(first_argument_range(node), replacement) end