I have a test suite for a very large project (~ 3800 individual examples) that I'm updating from RSpec 2.14 to 3.6.
I have just run a replace-all for s/be_true/be true/
, but some of them should be_truthy
instead, and these specs are failing.
I can extract the changed lines from git diff
- with a little work - but then I need to feed these into RSpec's config.filter_run
, and it doesn't seem to like me doing that for the locations
filter (the one activated when you specify a rspec path/to/file:line
on the command line); it says "All examples were filtered out; ignoring {:locations=>...}
".
I can also example.run unless example.location.in? changed_specs
in an around
filter, but this skip
s all the others and marks them as pending
, rather than ignoring them completely; and it doesn't work in concert with the other filters to run_all_when_everything_filtered
. (Probably because example.location
refers to the top line of the test, but the changes are a few lines below that.)
And I can't seem to use it to add a tag to the example.metadata
and then filter it out, either.
Edit: I also don't want to specify them on the command line, because my tests run under rerun
, which keeps running the same command.
Any more ideas?
You can run changed specs with:
rspec $(git ls-files --modified spec)
if you want include new unversioned specs as well use:
rspec $(git ls-files --modified --others spec)
You can make this handier with a shell alias:
alias rch='rspec $(git ls-files --modified --others spec)'
git status might be a better bet? Why doesn't something like this work for you:
$ bundle exec rspec $(git status | grep spec | grep "modified:" | cut -b 15-)
source: https://coderwall.com/p/usrhyq/running-modified-specs-with-git
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With