[Fix #292] ensure all kinds of assignments are correctly handled when counting assertions #293
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #292
Fixes #295
This ensures that
Minitest/MultipleAssertions
properly counts assertions when dealing with assignments - I expect (and hope) this is pretty rare in real-world code, but it is technically correct for the cop to be doing and the actual support isn't that complex.I've only added a single test to ensure all the types of assignment work, and then a test using the standard assignment operator for each different kind of complex node (block, if, rescue, etc) since they all work the same except for mass assignment and it would be very tedious to write all those tests; they could be done through loops but I'm not sure its worth it vs the complexity.
Speaking of mass assignment, that is the fly in the ointment - I've added support for single method and array, and then had it just bail otherwise because I expect this to be the rarest of rare cases and worst case a follow-up PR can be done expanding its support; I know already that this doesn't cover assigning hashes (i.e.
x, y => { "value" => assert("why...?") }
).Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.