dkz50g
Last Updated: February 25, 2016
·
1.948K
· sheerun
Photo on 08.01.2013 at 04.15

Focus on single rspec test without running whole suite

# in spec/spec_helper.rb
RSpec.configure do |c|
  c.filter_run :focus => true
end

# in spec/any_spec.rb
describe "something" do
  it "does something", :focus => true do
    # ....
  end
end

As @mcansky clarified in comments, "the "trick" is the ":focus => true" part, it comes with Rspec 2.x.".

4 Responses
Add your response

1864
892a174c18182a2a3157e51cd071d1cf

the "trick" is the ":focus => true" part, it comes with Rspec 2.x.

over 1 year ago ·
1867
Photo on 08.01.2013 at 04.15

@mcansky Thank you for clarification. I've updated the protip to include your comment.

over 1 year ago ·
1873
892a174c18182a2a3157e51cd071d1cf

@sheerun you're welcome.

note : if I remember correctly "focus" is an edge case of the tag functionality that was added to rspec 2 : https://www.relishapp.com/rspec/rspec-core/v/2-4/docs/command-line/tag-option

over 1 year ago ·
15387
Userpic

You can run the it directly with $ rspec spec/any_spec.rb:10 where 10 is the line number of the spec you want to run.

over 1 year ago ·