describe "How to run specific Examples with Tags" do it 'is a slow test', :slow = > true do sleep 10 puts 'This test is slow!' end it 'is a fast test', :fast = > true do puts 'This test is fast!' end endNow, save the above code in a new file called tag_spec.rb. From the command line, run this command: rspec --tag slow tag_spec.rb
You will see this output −
Run options: include {: slow = >true}
This test is slow! . Finished in 10 seconds (files took 0.11601 seconds to load) 1 example, 0 failuresThen, run this command: rspec --tag fast tag_spec.rb
You will see this output −
Run options: include {:fast = >true}
This test is fast!
.
Finished in 0.001 seconds (files took 0.11201 seconds to load)
1 example, 0 failures
As you can see, RSpec Tags makes it very easy to a subset of tests!
No comments:
Post a Comment