Run a rspec test many times in a row

Today I was trying to fix a flaky test and so I wanted to run the same rspec file over and over again so I could figure out if the test was still failing every so often.

This will repeat the test 10 times:

for i in {1..10}; do bin/rspec spec/requests/list_controller_spec.rb; done

And this one if you want the loop to stop running on failure:

for i in {1..10}; do bin/rspec spec/requests/list_controller_spec.rb; [[ ! $? = 0 ]] && break ; done

source