You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The assertion counter defaults to checking the children of nodes and the node itself using assertion_method? - this results in double counting when the node is an assignment of the result of an assertion method because assertion_method? itself is "assignment aware":
send:'assert_equal(1, 2)' is an assertion method!
lvasgn:'_ = assert_equal(1, 2)' is an assertion method!
Expected behavior
The test to pass
Actual behavior
The test fails:
2) Failure:
MultipleAssertionsTest#test_assignments_are_not_counted_twice [/home/jones/workspace/projects-oss/rubocop-minitest/test/rubocop/cop/minitest/multiple_assertions_test.rb:25]:
--- expected
+++ actual
@@ -1,5 +1,6 @@
"class FooTest < Minitest::Test
def test_asserts_once
+ ^^^^^^^^^^^^^^^^^^^^^ Test case has too many assertions [2/1].
_ = assert_equal(1, 2)
end
end
Steps to reproduce the problem
Add the following test:
def test_assignments_are_not_counted_twice
assert_no_offenses(<<~RUBY)
class FooTest < Minitest::Test
def test_asserts_once
_ = assert_equal(1, 2)
end
end
RUBY
end
The assertion counter defaults to checking the children of nodes and the node itself using
assertion_method?
- this results in double counting when the node is an assignment of the result of an assertion method becauseassertion_method?
itself is "assignment aware":Expected behavior
The test to pass
Actual behavior
The test fails:
Steps to reproduce the problem
Add the following test:
RuboCop version
The text was updated successfully, but these errors were encountered: