Handle spec example name normalization #3490
Merged
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.
Motivation
We were not using the correct IDs for
it
examples inMinitest::Spec
. Minitest will take the description and format it using the example count (see here).This means that the Minitest reporter will use a different ID than discovery and we'll not be able to show results properly.
Implementation
Since we discover tests through static analysis, it is not possible to match the exact same numbers Minitest uses from the runtime for its examples.
Instead of trying to match that exactly, we can be more accurate if we use the line number of where we found that test as part of its ID - which is guaranteed to match. For this to work, we must ensure that both discovery and test result reporting are using the same ID formatting, which is what this PR does.
Note: there's a decision being made here, which is that dynamically defined anonymous tests cannot be supported (see the doc changes). They are not that common anyway and we have limited support for meta-programming.
Automated Tests
Added/improved current tests.