class RuboCop::Cop::Minitest::RefuteSame


refute_same(expected, actual)
# good
refute_equal(expected.object_id, actual.object_id)
refute(expected.equal?(actual))
# bad
@example
Otherwise, use ‘refute_equal`.
NOTE: Use `refute_same` only when there is a need to compare by identity.
over `refute(expected.equal?(actual))`.
Enforces the use of `refute_same(expected, object)`

def message(expected_node, actual_node, message_node)

def message(expected_node, actual_node, message_node)
  arguments = [expected_node, actual_node, message_node].compact.map(&:source).join(', ')
  format(MSG, new_arguments: arguments)
end

def on_send(node)

rubocop:disable Metrics/AbcSize
def on_send(node)
  if (equal_node, expected_node, actual_node, message_node = refute_with_equal?(node))
    add_offense(node, message: message(expected_node, actual_node, message_node.first)) do |corrector|
      corrector.replace(node.loc.selector, 'refute_same')
      corrector.replace(equal_node, "#{expected_node.source}, #{actual_node.source}")
    end
  elsif (expected_node, actual_node, message_node = refute_equal_with_object_id?(node))
    add_offense(node, message: message(expected_node, actual_node, message_node.first)) do |corrector|
      corrector.replace(node.loc.selector, 'refute_same')
      remove_method_call(expected_node.parent, corrector)
      remove_method_call(actual_node.parent, corrector)
    end
  end
end

def remove_method_call(send_node, corrector)

def remove_method_call(send_node, corrector)
  range = send_node.loc.dot.join(send_node.loc.selector)
  corrector.remove(range)
end