Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Fix taging feature on Ruby head #3118

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 12 additions & 22 deletions features/command_line/tag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,66 +39,56 @@ Feature: `--tag` option

Scenario: Filter examples with a simple tag
When I run `rspec . --tag focus`
Then the output should contain "include {:focus=>true}"
Then the output should print the included tags {focus: true}
And the examples should all pass

Scenario: Filter examples with a simple tag and @
When I run `rspec . --tag @focus`
Then the output should contain "include {:focus=>true}"
Then the output should print the included tags {focus: true}
Then the examples should all pass

Scenario: Filter examples with a `name:value` tag
When I run `rspec . --tag type:special`
Then the output should contain:
"""
include {:type=>"special"}
"""
Then the output should print the included tags {type: "special"}
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"}
"""
Then the output should print the included tags {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}"
Then the output should print the excluded tags {skip: true}
Then the examples should all pass

Scenario: Exclude examples with a simple tag and @
When I run `rspec . --tag ~@skip`
Then the output should contain "exclude {:skip=>true}"
Then the output should print the excluded tags {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 output should print the excluded tags {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:
"""
exclude {:speed=>"slow"}
"""
Then the output should print the excluded tags {speed: "slow"}
Then the examples should all pass

Scenario: Filter examples with a simple tag, exclude examples with another tag
When I run `rspec . --tag focus --tag ~skip`
Then the output should contain "include {:focus=>true}"
And the output should contain "exclude {:skip=>true}"
Then the output should print the included tags {focus: true}
And the output should print the excluded tags {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} |
| exclude {skip: true, speed: "slow"} |
| exclude {speed: "slow", skip: true} |
Then the examples should all pass
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Feature: Using `run_all_when_everything_filtered`
"""
When I run `rspec spec/example_spec.rb --tag some_tag`
Then the output should contain "1 example, 0 failures"
And the output should contain "Run options: include {:some_tag=>true}"
And the output should contain in either hash syntax "Run options: include {:some_tag=>true}"

Scenario: When the `run_all_when_everything_filtered` option is turned on, all the specs are run when the tag has no matches
Given a file named "spec/example_spec.rb" with:
Expand All @@ -78,5 +78,5 @@ Feature: Using `run_all_when_everything_filtered`
"""
When I run `rspec spec/example_spec.rb --tag some_tag`
Then the output should contain "2 examples, 0 failures"
And the output should contain "All examples were filtered out; ignoring {:some_tag=>true}"
And the output should contain in either hash syntax "All examples were filtered out; ignoring {:some_tag=>true}"

17 changes: 17 additions & 0 deletions features/step_definitions/additional_cli_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

require './spec/support/formatter_support'

# For Ruby 3.4.0 hash formatting
Then /^the output should print the (include|exclude)d tags {(\w+): (.*)}$/ do |word, key, value|
if RUBY_VERSION.to_f > 3.3
expect(all_output).to include "#{word} {#{key}: #{value}}"
else
expect(all_output).to include "#{word} {:#{key}=>#{value}}"
end
end

Then /^the output should contain in either hash syntax "(.*)"$/ do |string|
if RUBY_VERSION.to_f > 3.3
step "the output should contain \"#{string.gsub(/:(\w+)=>/, '\1: ')}\""
else
step "the output should contain \"#{string}\""
end
end

Then /^the output should contain all of these:$/ do |table|
table.raw.flatten.each do |string|
expect(all_output).to include(string)
Expand Down
Loading