Fortunately thanks to very smart people in the community - yes there is! So worry not, warrior of legacy code, protector of good practices. Now you have tools that will help you lead the way into the clean and solid code, where tests are always green and developers are happy. Ok, maybe I got carried a way a little bit here, let’s get down to the business ;).

Rspec 3.3 introduced bisect command which is truly awesome, from docs:

Pass the –bisect option (in addition to –seed and any other options) and RSpec will repeatedly run subsets of your suite in order to isolate the minimal set of examples that reproduce the same failures.

I recommend checkout out this pull request for more references regarding internals/implementation.

Side note: still on Rspec 2.x? Checkout transpec that will help you with migration to 3.x.

So let’s say you have some sort of test suite that is passing. Unless you add config.order = :random to your rspec config (or run it with --order rand flag), then it’s not. Test suite should fail with a seed of some sort (eg. Randomized with seed 45379), pass that seed to bisect command (rspec --seed 45379 --bisect) and you should end up with a very narrow subset of tests that should help you a lot with the process of investigating what went wrong - of course this often won’t solve everything magically, but should help you guide into the right place.

Random tips / notes:

find spec -name '*_spec.rb' -exec rspec {} \;

(you might want to quote '{}' under fish shell)


Good luck! ⚔️