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 a false positive for Minitest/MultipleAssertions when using assertion method with block #224

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

fatkodima
Copy link
Contributor

Fixes #223.

assertions_count method was updated to count assertion-like send nodes belonging to block node only once.

@@ -15,6 +15,14 @@ def test_asserts_twice
assert_equal(foo, bar)
assert_empty(array)
end

def test_asserts_three_times
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you separate this new test example from existing def test_registers_offense_when_multiple_expectations (L10) to a new test method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@koic koic merged commit 9633b33 into rubocop:master Jan 16, 2023
@koic
Copy link
Member

koic commented Jan 16, 2023

Thanks!

@fatkodima fatkodima deleted the fix-multiple_assertions branch January 16, 2023 13:07
koic added a commit that referenced this pull request Jan 18, 2023
`[2/1]` and `[3/1]` may be detected incorrectly in multiple_assertions_test.rb of #224:
https://app.circleci.com/pipelines/github/rubocop/rubocop-minitest/853/workflows/3da99133-155c-4bca-8e92-4c3287b537b6/jobs/5481

Another essential fix is needed, but this commit prevents a flaky test by unifying to `[2/1]`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Minitest/MultipleAssertions unexpectedly counts the block node
2 participants