class RuboCop::Cop::Minitest::AssertWithExpectedArgument
This cop tries to detect when a user accidentally used `assert` when they meant to use `assert_equal`.
It is marked as unsafe because it is not possible to determine whether the second argument of `assert` is a message or not.
@example
# bad assert(3, my_list.length) assert(expected, actual) # good assert_equal(3, my_list.length) assert_equal(expected, actual) assert(foo, 'message')
Constants
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/minitest/assert_with_expected_argument.rb, line 30 def on_send(node) assert_with_two_arguments?(node) do |_expected, message| return if message.str_type? || message.dstr_type? arguments = node.arguments.map(&:source).join(', ') add_offense(node, message: format(MSG, arguments: arguments)) end end