From 227922905e9f579ee6ce04bc9960cd8dc8ed10f0 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 9 Oct 2024 23:02:43 +0100 Subject: [PATCH 1/2] Fix taging feature on Ruby head --- features/command_line/tag.feature | 34 +++++++------------ .../step_definitions/additional_cli_steps.rb | 9 +++++ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/features/command_line/tag.feature b/features/command_line/tag.feature index 2c74c1d0e9..436eab730e 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/step_definitions/additional_cli_steps.rb b/features/step_definitions/additional_cli_steps.rb index ad75ba3829..89eb10b596 100644 --- a/features/step_definitions/additional_cli_steps.rb +++ b/features/step_definitions/additional_cli_steps.rb @@ -2,6 +2,15 @@ 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 all of these:$/ do |table| table.raw.flatten.each do |string| expect(all_output).to include(string) From 447893d9f7994681d4fae85521fc89eb962f941f Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 10 Oct 2024 00:07:52 +0100 Subject: [PATCH 2/2] Fix run all when filtered examples --- .../run_all_when_everything_filtered.feature | 4 ++-- features/step_definitions/additional_cli_steps.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/features/configuration/run_all_when_everything_filtered.feature b/features/configuration/run_all_when_everything_filtered.feature index 64f6219aed..6de90e62b2 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 89eb10b596..866340b512 100644 --- a/features/step_definitions/additional_cli_steps.rb +++ b/features/step_definitions/additional_cli_steps.rb @@ -11,6 +11,14 @@ 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)