Skip to content

Commit

Permalink
Merge pull request #775 from sorentwo/document-multi-exclude
Browse files Browse the repository at this point in the history
Scenario documenting multiple exclude
  • Loading branch information
myronmarston committed Jan 16, 2013
2 parents 27a89f6 + 456fc8e commit 771f5f0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
21 changes: 14 additions & 7 deletions features/command_line/tag.feature
@@ -1,16 +1,16 @@
Feature: --tag option

Use the --tag (or -t) option to filter the examples by tags.

The tag can be a simple name or a name:value pair. In the first case,
examples with :name => true will be filtered. In the second case, examples
with :name => value will be filtered, where value is always a string. In
both cases, name is converted to a symbol.

Tags can also be used to exclude examples by adding a ~ before the tag. For
example ~tag will exclude all examples marked with :tag => true and
~tag:value will exclude all examples marked with :tag => value.

To be compatible with the Cucumber syntax, tags can optionally start with
an @ symbol, which will be ignored.

Expand Down Expand Up @@ -49,15 +49,15 @@ Feature: --tag option
"""
And the output should contain "2 examples"
And the examples should all pass

Scenario: filter examples with a name:value tag and @
When I run `rspec . --tag @type:special`
Then the output should contain:
"""
include {:type=>"special"}
"""
And the examples should all pass

Scenario: exclude examples with a simple tag
When I run `rspec . --tag ~skip`
Then the output should contain "exclude {:skip=>true}"
Expand All @@ -67,15 +67,15 @@ Feature: --tag option
When I run `rspec . --tag ~@skip`
Then the output should contain "exclude {:skip=>true}"
Then the examples should all pass

Scenario: exclude examples with a name:value tag
When I run `rspec . --tag ~speed:slow`
Then the output should contain:
"""
exclude {:speed=>"slow"}
"""
Then the examples should all pass

Scenario: exclude examples with a name:value tag and @
When I run `rspec . --tag ~@speed:slow`
Then the output should contain:
Expand All @@ -89,3 +89,10 @@ Feature: --tag option
Then the output should contain "include {:focus=>true}"
And the output should contain "exclude {:skip=>true}"
And the examples should all pass

Scenario: exclude examples with multiple tags
When I run `rspec . --tag ~skip --tag ~speed:slow`
Then the output should contain one of the following:
| exclude {:skip=>true, :speed=>"slow"} |
| exclude {:speed=>"slow", :skip=>true} |
Then the examples should all pass
8 changes: 8 additions & 0 deletions features/step_definitions/additional_cli_steps.rb
Expand Up @@ -12,6 +12,14 @@
end
end

Then /^the output should contain one of the following:$/ do |table|
matching_output = table.raw.flatten.select do |string|
all_output =~ regexp(string)
end

matching_output.should have(1).item
end

Then /^the example(?:s)? should(?: all)? pass$/ do
step %q{the output should contain "0 failures"}
step %q{the output should not contain "0 examples"}
Expand Down

0 comments on commit 771f5f0

Please sign in to comment.