It isn't easy to find the documentation, but you can tag examples with a hash. Eg.
# spec/my_spec.rb
describe SomeContext do
it "won't run this" do
raise "never reached"
end
it "will run this", :focus => true do
1.should == 1
end
end
$ rspec --tag focus spec/my_spec.rb
More info on GitHub. (anyone with a better link, please advise)
(update)
RSpec is now superbly documented here. See the --tag option section for details.
As of v2.6 this kind of tag can be expressed even more simply by including the configuration option treat_symbols_as_metadata_keys_with_true_values
, which allows you to do:
describe "Awesome feature", :awesome do
where :awesome
is treated as if it were :awesome => true
.
Also see this answer for how to configure RSpec to automatically run 'focused' tests. This works especially well with Guard.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…