How to run a specific RSpec test

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

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
Sajad Torkamani

Hello! My name is Sajad. I’m a software developer at Nationwide and an aspiring entrepreneur. Originally from Afghanistan, I moved to London at an early age and have been living here for the past 20 years.

This is my personal website where I blog mostly about programming with occasional thoughts on a bunch of other things. I write mainly for my own benefit as I find that writing helps clarify my otherwise very confused thoughts.

Get in touch: