class RuboCop::Cop::Minitest::AssertEmptyLiteral
assert_empty(object)
# good
assert_equal({}, object)
assert_equal([], object)
# bad
@example
instead of using ‘assert_equal([], object)` or `assert_equal({}, object)`.
Enforces the test to use `assert_empty`
def on_send(node)
def on_send(node) assert_equal_with_empty_literal(node) do |literal, matchers| return unless literal.values.empty? args = matchers.map(&:source).join(', ') message = format(MSG, literal: literal.source, arguments: args) add_offense(node, message: message) do |corrector| object = matchers.first corrector.replace(node.loc.selector, 'assert_empty') corrector.replace(first_and_second_arguments_range(node), object.source) end end end