Raise exception when using :focus
tag to avoid skipping RSpec tests
#167
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.
Raise exception only when RSpec inclusion rule includes
:focus
tag.problem description
When tests can be skipped by RSpec?
The problem occurs when at least one of the test files has
:focus
tag. And when you useFor instance, if a test file has content like this:
Then this sets RSpec filter to
focus: true
. You can see in RSpec output this:Run options: include {:focus=>true}
and as a result we can see in the RSpec output:
All examples were filtered out
so tests without the tag are skipped.All further test files fetched from Queue are going to be skipped due to this filter
:focus => true
.solution
Using the
:focus
tag should be a temporary change in the development environment when you only want to run tests with the:focus
tag. In the CI environment, it is not recommended to use:focus
tag because this can lead to skipping test cases. Especially it can lead to skipping random test file paths without:focus
tag in the Knapsack Pro Queue Mode when the test files are loaded after the test file with:focus
tag. Please remove:focus
tags from your test files and commit the change and push to the repository. RSpec provides aliasesfit
,fdescribe
andfcontext
as a shorthand forit
,describe
andcontext
with:focus
metadata, making it easy to temporarily focus an example or group by prefixing anf
. Please remove all occurrences of it or use an alternative solution: https://knapsackpro.com/faq/question/why-is-rspec-skipping-some-of-the-tests#if-you-have-too-many-test-files-with-focus-tag-and-you-dont-want-to-remove-the-tag-manually