Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an error for Minitest/AssertEmptyLiteral when only passing an empty literal #300

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/fix_an_error_for_assert_empty_literal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#300](https://github.com/rubocop/rubocop-minitest/pull/300): Fix an error for `Minitest/AssertEmptyLiteral` when only passing an empty literal. ([@earlopain][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/minitest/assert_empty_literal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AssertEmptyLiteral < Base
RESTRICT_ON_SEND = %i[assert_equal].freeze

def_node_matcher :assert_equal_with_empty_literal, <<~PATTERN
(send nil? :assert_equal ${hash array} $...)
(send nil? :assert_equal ${hash array} $_+)
PATTERN

def on_send(node)
Expand Down
10 changes: 10 additions & 0 deletions test/rubocop/cop/minitest/assert_empty_literal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,14 @@ def test_do_something
end
RUBY
end

def test_does_not_register_offense_when_only_passing_empty_hash_to_assert_equal
assert_no_offenses(<<~RUBY)
class FooTest < Minitest::Test
def test_do_something
assert_equal({})
end
end
RUBY
end
end