Last Updated: February 25, 2016
·
4.698K
· sheerun

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

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

over 1 year ago ·

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

over 1 year ago ·

@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 ·

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 ·