Improve detection of test file path in test-unit runner for test files with shared examples #123
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.
problem
When you use test runner
test-unit
https://test-unit.github.io and your test file has shared examples (share_should
method) and regular test cases then when tests are executed in random order for this file then it could lead to knapsack_pro detecting wrong test file path for executed test if first test case is shared example for a test file.Bug also happens when test file contains only shared examples.
Example test file with shared examples https://github.com/KnapsackPro/rails-app-with-knapsack_pro/blob/383cb917755f6d34bd3cacd8261226cc769e49a1/test-unit/models/shared_should_test.rb#L33
Root problem is that detecting test file path based on shared examples method returns wrong test file path.
test_path method returned wrong path
/Users/artur/.rvm/gems/ruby-2.6.5/gems/shared_should-0.10.0/lib/shared_should/shared_context.rb
for shared example instead oftest-unit/models/shared_should_test.rb
fix