Quickly debug failures in RSpec

Ian Ker-Seymer
Broadlume Product Development
1 min readFeb 7, 2018

The main reason I prefer using RSpec is that I find the CLI integration to be much more usable than alternatives like Minitest.

Since RSpec 3.3, RSpec has offered the --next-failure feature. With this option, RSpec will only the first spec that failed. This is perfect for situations where diffs made some tests fail, or you just want to stay focused on the current failure.

In order to make this work, RSpec keeps some metadata about your previous runs. To enable this, add this to your spec_helper.rb:

Unfortunately, rspec --next-failure required a little too much typing for my liking. So as of RSpec 3.7, you can now just rspec -n. A small ergonomics improvement.

If you love writing well-tested, decoupled, happiness-inducing Ruby and React, we’re hiring!

--

--