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

- old
+ new

@@ -14,10 +14,12 @@ # # good # refute_includes(collection, object) # refute_includes(collection, object, 'the message') # class RefuteIncludes < Cop + include ArgumentRangeHelper + MSG = 'Prefer using `refute_includes(%<arguments>s)` over ' \ '`refute(%<receiver>s)`.' def_node_matcher :refute_with_includes, <<~PATTERN (send nil? :refute $(send $_ :include? $_) $...) @@ -37,15 +39,14 @@ end end def autocorrect(node) lambda do |corrector| - refute_with_includes(node) do - |_receiver, collection, object, rest_receiver_arg| + refute_with_includes(node) do |_, collection, actual| + corrector.replace(node.loc.selector, 'refute_includes') - message = rest_receiver_arg.first - replacement = node_arguments(collection, object, message) - corrector.replace(node.loc.expression, "refute_includes(#{replacement})") + replacement = [collection, actual].map(&:source).join(', ') + corrector.replace(first_argument_range(node), replacement) end end end private