Rerun Only Failed Tests with RSpec
Say you run your entire rspec suite and a couple of tests fail. You make a change that should fix them. How can you quickly rerun those failed tests to see if they're green? It could take minutes to run the whole suite again, and all you care about is 2 tests.
That's where the --next-failure
(-n
) flag comes in handy. According to the docs it is "Equivalent to --only-failures --fail-fast --order defined
)". So you can rerun only your failed specs, and exit immediately if one does fail. You could of course just use --only-failures
too, but sometimes it's nice to fail fast.
bundle exec rspec -n
h/t Brian Dunn
Tweet