Run only specific tests in RSpec

Sep 14, 2020

Configure RSpec in a spec_helper.rb file or some file that you include when running RSpec tests.

RSpec.configure do |config|
  config.filter_run focus: true
  config.run_all_when_everything_filtered = true
end

Now, you can prepend an f to a describe, context or it block to only run that example:

fit 'run only this example' do ... end

The x prefix can also be used to skip a particular example:

xit 'do not run this example' do ... end