From 1f5b045466c88ca5b58e49f769324b6ff619494b Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 9 Oct 2024 23:02:43 +0100 Subject: [PATCH] Fix taging feature on Ruby head --- features/command_line/tag.feature | 34 +++++++------------ .../step_definitions/additional_cli_steps.rb | 17 ++++++++++ 2 files changed, 29 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..11be18522b 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 included tags {(\w+): (\w+)$/ do |key, value| + if RUBY_VERSION.to_f > 3.3 + Then %Q{the output should contain "include {#{key}: #{value}}"} + else + Then %Q{the output should contain "include {:#{key}=>#{value}}"} + end +end + +Then /^the output should print the excluded tags {(\w+): (\w+)$/ do |key, value| + if RUBY_VERSION.to_f > 3.3 + Then %Q{the output should contain "exclude {#{key}: #{value}}"} + else + Then %Q{the output should contain "exclude {:#{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)