Can I get RSpec to only run changed specs?

Viewed 3217

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 skips 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?

3 Answers
Related