lib/rubocop/cop/minitest/assert_empty.rb in rubocop-minitest-0.5.0 vs lib/rubocop/cop/minitest/assert_empty.rb in rubocop-minitest-0.5.1

- old
+ new

@@ -14,10 +14,12 @@ # # good # assert_empty(object) # assert_empty(object, 'the message') # class AssertEmpty < Cop + include ArgumentRangeHelper + MSG = 'Prefer using `assert_empty(%<arguments>s)` over ' \ '`assert(%<receiver>s)`.' def_node_matcher :assert_with_empty, <<~PATTERN (send nil? :assert $(send $_ :empty?) $...) @@ -35,14 +37,12 @@ end end def autocorrect(node) lambda do |corrector| - assert_with_empty(node) do |_first_receiver_arg, actual, rest_receiver_arg| - message = rest_receiver_arg.first - - replacement = [actual.source, message&.source].compact.join(', ') - corrector.replace(node.loc.expression, "assert_empty(#{replacement})") + assert_with_empty(node) do |_, actual_arg| + corrector.replace(node.loc.selector, 'assert_empty') + corrector.replace(first_argument_range(node), actual_arg.source) end end end end end