diff --git a/features/command_line/tag.feature b/features/command_line/tag.feature index 2c74c1d0e..436eab730 100644 --- a/features/command_line/tag.feature +++ b/features/command_line/tag.feature @@ -39,61 +39,49 @@ 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 @@ -101,4 +89,6 @@ Feature: `--tag` option 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 diff --git a/features/configuration/run_all_when_everything_filtered.feature b/features/configuration/run_all_when_everything_filtered.feature index 64f6219ae..6de90e62b 100644 --- a/features/configuration/run_all_when_everything_filtered.feature +++ b/features/configuration/run_all_when_everything_filtered.feature @@ -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: @@ -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}" diff --git a/features/step_definitions/additional_cli_steps.rb b/features/step_definitions/additional_cli_steps.rb index ad75ba382..866340b51 100644 --- a/features/step_definitions/additional_cli_steps.rb +++ b/features/step_definitions/additional_cli_steps.rb @@ -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)