|
| 1 | +Feature: tag option |
| 2 | + |
| 3 | + Use the --tag (or -t) option to filter the examples to be run by tag. |
| 4 | + |
| 5 | + The tag can be a simple name or a name:value pair. In the first case, |
| 6 | + examples with :name => true will be filtered. In the second case, examples |
| 7 | + with :name => value will be filtered, where value is always a string. |
| 8 | + In both cases, name is converted to a symbol. |
| 9 | + |
| 10 | + Tags can also be used to exclude examples by adding a ~ before the tag. |
| 11 | + For example ~tag will exclude all examples marked with :tag => true and |
| 12 | + ~tag:value will exclude all examples marked with :tag => value. |
| 13 | + |
| 14 | + To be compatible with the Cucumber syntax, tags can optionally start with |
| 15 | + a @, that will be ignored. |
| 16 | + |
| 17 | + Background: |
| 18 | + Given a file named "tagged_spec.rb" with: |
| 19 | + """ |
| 20 | + describe "group with tagged specs" do |
| 21 | + it "example I'm working now", :focus => true do; end |
| 22 | + it "special example", :type => 'special' do; end |
| 23 | + it "slow example", :skip => true do; end |
| 24 | + it "ordinary example", :speed => 'slow' do; end |
| 25 | + it "untagged example" do; end |
| 26 | + end |
| 27 | + """ |
| 28 | + |
| 29 | + Scenario: filter examples with non-existent tag |
| 30 | + When I run "rspec . --tag mytag" |
| 31 | + And the output should contain "0 examples, 0 failures" |
| 32 | + |
| 33 | + Scenario: filter examples with a simple tag |
| 34 | + When I run "rspec . --tag focus" |
| 35 | + Then the output should contain "Run filtered using {:focus=>true}" |
| 36 | + And the output should contain "1 example, 0 failures" |
| 37 | + |
| 38 | + Scenario: filter examples with a simple tag and @ |
| 39 | + When I run "rspec . --tag @focus" |
| 40 | + Then the output should contain "Run filtered using {:focus=>true}" |
| 41 | + Then the output should contain "1 example, 0 failures" |
| 42 | + |
| 43 | + Scenario: filter examples with a name:value tag |
| 44 | + When I run "rspec . --tag type:special" |
| 45 | + Then the output should contain: |
| 46 | + """ |
| 47 | + Run filtered using {:type=>"special"} |
| 48 | + """ |
| 49 | + And the output should contain "1 example, 0 failures" |
| 50 | + |
| 51 | + Scenario: filter examples with a name:value tag and @ |
| 52 | + When I run "rspec . --tag @type:special" |
| 53 | + Then the output should contain: |
| 54 | + """ |
| 55 | + Run filtered using {:type=>"special"} |
| 56 | + """ |
| 57 | + And the output should contain "1 example, 0 failures" |
| 58 | + |
| 59 | + Scenario: exclude examples with a simple tag |
| 60 | + When I run "rspec . --tag ~skip" |
| 61 | + Then the output should contain "4 examples, 0 failures" |
| 62 | + |
| 63 | + Scenario: exclude examples with a simple tag and @ |
| 64 | + When I run "rspec . --tag ~@skip" |
| 65 | + Then the output should contain "4 examples, 0 failures" |
| 66 | + |
| 67 | + Scenario: exclude examples with a name:value tag |
| 68 | + When I run "rspec . --tag ~speed:slow" |
| 69 | + Then the output should contain "4 examples, 0 failures" |
| 70 | + |
| 71 | + Scenario: exclude examples with a name:value tag and @ |
| 72 | + When I run "rspec . --tag ~@speed:slow" |
| 73 | + Then the output should contain "4 examples, 0 failures" |
| 74 | + |
0 commit comments