How to run a single test in guard for rspec?

You have to argument your spec/spec_helper.rb file to accept the :focus => true statement.

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

Then you can use

it 'does something', :focus => true do
  //your spec
end

or

describe "something", :focus => true do
  before do
     sign in
     visit page
  end

  it { does something }
  it { does something else }
end

If you are going to take that approach, you probably also want to ensure all specs are run if there is no :focus => true anywhere, using the documented approach:

RSpec.configure do |config|
  config.run_all_when_everything_filtered = true
end

You can do a lot with filters; you might want to have a look at this page: https://relishapp.com/rspec/rspec-core/v/3-0/docs/filtering

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)