ruby-on-rails - rails - ruby run guard




How to run a single test in guard for rspec? (2)

I think you can add the "focus: true" option for the spec you want to run, something like

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

then you save the file and guard runs only that focused test

when you are finished you just remove "focus: true"

I use guard-rspec to automatically run necessary rspec tests as my files changes, and I love how it works. However, when I'm debugging a file with multiple tests, sometimes I just want an individual test to be re-run. For example, with rspec from the command line:

rspec spec/requests/my_favorite_spec.rb:100

This will run only the single spec at line 100 in my_favorite_spec.rb.

I tried inputting the above into the guard console, but it just ran all the tests as if I had just pressed enter. Is there another syntax in the guard console to run a single spec?






guard