class RuboCop::Cop::Minitest::AssertWithExpectedArgument
assert(foo, msg)
assert(foo, message)
assert(foo, ‘message’)
assert_equal(expected, actual)
assert_equal(3, my_list.length)
# good
assert(expected, actual)
assert(3, my_list.length)
# bad
@example
whether the second argument of ‘assert` is a message or not.
This cop is unsafe because it is not possible to determine
@safety
Because their names are inferred as message arguments.
NOTE: The second argument to the `assert` method named `message` and `msg` is allowed.
`assert` when they meant to use `assert_equal`.
Tries to detect when a user accidentally used
def on_send(node)
def on_send(node) assert_with_two_arguments?(node) do |_expected, message| return if message.str_type? || message.dstr_type? || MESSAGE_VARIABLES.include?(message.source) arguments = node.arguments.map(&:source).join(', ') add_offense(node, message: format(MSG, arguments: arguments)) end end