Run specific RSpec test
11 March 2022 (Updated 11 March 2022)
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
If you now run bundle exec rspec, only the tests with the f prefix should run.
The x prefix can also be used to skip a particular example:
xit 'do not run this example' do
# ...
end
Tagged:
Ruby tooling
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment