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
3.2.2 breaks line number filter when external shared examples are included #1961
Comments
I'm unlikely to reproduce the issue tonight, will close until I have a minimal sample file that can reproduce the issue. |
I managed to reproduce it tonight, after all. If it's bad / unsupported / edge case let me know and I'll follow up accordingly. If I've stumbled upon an actual bug, I'm happy to make a PR for a test+fix. |
This is definitely a regression. Thanks for putting together the reproduction! The regression is caused by 0a4937b / 8772cf5 (the first commit caused the regression in master (3.3.0.pre) whereas the latter caused it in 3.2.2). When you run a command line In your case, you've got specs defined in a shared example group file, and so the line number filtering isn't applying and they are running in spite of the fact they shouldn't. I'm not sure what the solution should be but here are a few thoughts:
Does that help point you in a direction for trying to work up a PR? |
One other thing...if you use |
Looks like all the information I should need to get started, thanks. I'll get onto a PR as soon as is practical within the next few days |
I think a tweak along these lines ben-axnick@01be52a should behave correctly both in cases where only location filters are present, and in cases where tag inclusions/exclusions are also present. At a high level, basically "if the current example is included as part of a location filtered file, but doesn't have its own location filters present, then prune it immediately". If you agree with the gist of that, I'll clean it up and then get my reproductions directory converted over to a set of specs. Unfortunately, I did end up using |
That solution looks fine. I'm not really concerned about backporting to 3-2 so let's just fix it against master. |
Fixes rspec#1961 The issue is that when the rerun file of an example is not taken into account, it is treated by the filtering mechanism as completely separate file. This causes issues for location filtering, which causes an implicit exclusion scoped to its own file. The fix extends the scope of that exclusion to any examples for which it is the rerun path. i.e. an external shared example that is `include`d or `require`d.
Fixes rspec#1961 The problem with using :absolute_file_path is that it doesn't function correctly for shared examples in an external file. The filter manager thinks that there are no location filters set, when actually there are. Since MetadataFilter already handles location filtering correctly across multiple nested examples / files, correcting the path that is checked is sufficient to fix the line filtering issue.
Fixes rspec#1961 The problem with using :absolute_file_path is that it doesn't function correctly for shared examples in an external file. The filter manager thinks that there are no location filters set, when actually there are. Since MetadataFilter already handles location filtering correctly across multiple nested examples / files, correcting the path that is checked is sufficient to fix the line filtering issue.
Fixes rspec#1961 The problem with using :absolute_file_path is that it doesn't function correctly for shared examples in an external file. The filter manager thinks that there are no location filters set, when actually there are. Since MetadataFilter already handles location filtering correctly across multiple nested examples / files, correcting the path that is checked is sufficient to fix the line filtering issue.
In going from
rspec-core
3.2.1 torspec-core
3.2.2 (included into the bundle viarspec-rails
), I've noticed that CLI commands in the form:where
123
is the start/inner line of anit
block no longer behave as expected. In 3.2.1, only that single test would be run. In 3.2.2 allit_behaves_like
blocks in the file get executed before running the indicated test. This can add significantly to the amount of time needed to interactively run tests if there are many tests defined inside theshared_examples
block thatit_behaves_like
refers to.The bug/change is still present in 3.2.3 but I have not tested against
master
.Issue
Appears to occur when shared examples are
require
d from an external file.Reproducing
Setup files as below (or
git clone https://github.com/bentheax/sample-rspec-for-bug-report.git
) and runGemfile
Gemfile.lock
spec/a_test_that_always_runs_external_examples.rb
spec/minimal_spec.rb
Output
The text was updated successfully, but these errors were encountered: