rspec bisect

Have you ever had one of those days where no matter how hard you try, you can't seem to figure out why a test case is failing?

You've used pry, you've run things every way imaginable, but you still can't get that failing spec to run or even fail like you expect it to?

I've had one of those days. I have a rails app that I'm currently in the process of upgrading to rails 5. I'm pretty proud that I'm down to only 25 failing specs. The HARD part, right now, is that those spec files, when run independently of each other, produce successful test runs. When run with the suite, they fail spectacularly.

Enter 'rspec –bisect' this awesome command, similar to git's bisect command, does a similar thing. It runs through your test suite finding the minimal amount of tests that will consistently fail and it does its best to tell you if those failures are order dependent.

There are around 700 test cases in the app and it narrowed it down to 6 that would make it consistently fail. From there, I was able to narrow it down to one other test case that would make it fail. This would have been hours or days to figure out any other way. Awesome tool!

Share this post