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

Commit 787670c

Browse files
authored
Merge pull request #3118 from rspec/fix-ruby-head-hash-syntax
Fix taging feature on Ruby head
2 parents 3f10b72 + 447893d commit 787670c

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

features/command_line/tag.feature

+12-22
Original file line numberDiff line numberDiff line change
@@ -39,66 +39,56 @@ Feature: `--tag` option
3939

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

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

5050
Scenario: Filter examples with a `name:value` tag
5151
When I run `rspec . --tag type:special`
52-
Then the output should contain:
53-
"""
54-
include {:type=>"special"}
55-
"""
52+
Then the output should print the included tags {type: "special"}
5653
And the output should contain "2 examples"
5754
And the examples should all pass
5855

5956
Scenario: Filter examples with a `name:value` tag and @
6057
When I run `rspec . --tag @type:special`
61-
Then the output should contain:
62-
"""
63-
include {:type=>"special"}
64-
"""
58+
Then the output should print the included tags {type: "special"}
6559
And the examples should all pass
6660

6761
Scenario: Exclude examples with a simple tag
6862
When I run `rspec . --tag ~skip`
69-
Then the output should contain "exclude {:skip=>true}"
63+
Then the output should print the excluded tags {skip: true}
7064
Then the examples should all pass
7165

7266
Scenario: Exclude examples with a simple tag and @
7367
When I run `rspec . --tag ~@skip`
74-
Then the output should contain "exclude {:skip=>true}"
68+
Then the output should print the excluded tags {skip: true}
7569
Then the examples should all pass
7670

7771
Scenario: Exclude examples with a `name:value` tag
7872
When I run `rspec . --tag ~speed:slow`
79-
Then the output should contain:
80-
"""
81-
exclude {:speed=>"slow"}
82-
"""
73+
Then the output should print the excluded tags {speed: "slow"}
8374
Then the examples should all pass
8475

8576
Scenario: Exclude examples with a `name:value` tag and @
8677
When I run `rspec . --tag ~@speed:slow`
87-
Then the output should contain:
88-
"""
89-
exclude {:speed=>"slow"}
90-
"""
78+
Then the output should print the excluded tags {speed: "slow"}
9179
Then the examples should all pass
9280

9381
Scenario: Filter examples with a simple tag, exclude examples with another tag
9482
When I run `rspec . --tag focus --tag ~skip`
95-
Then the output should contain "include {:focus=>true}"
96-
And the output should contain "exclude {:skip=>true}"
83+
Then the output should print the included tags {focus: true}
84+
And the output should print the excluded tags {skip: true}
9785
And the examples should all pass
9886

9987
Scenario: Exclude examples with multiple tags
10088
When I run `rspec . --tag ~skip --tag ~speed:slow`
10189
Then the output should contain one of the following:
10290
| exclude {:skip=>true, :speed=>"slow"} |
10391
| exclude {:speed=>"slow", :skip=>true} |
92+
| exclude {skip: true, speed: "slow"} |
93+
| exclude {speed: "slow", skip: true} |
10494
Then the examples should all pass

features/configuration/run_all_when_everything_filtered.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Feature: Using `run_all_when_everything_filtered`
6262
"""
6363
When I run `rspec spec/example_spec.rb --tag some_tag`
6464
Then the output should contain "1 example, 0 failures"
65-
And the output should contain "Run options: include {:some_tag=>true}"
65+
And the output should contain in either hash syntax "Run options: include {:some_tag=>true}"
6666

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

features/step_definitions/additional_cli_steps.rb

+17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
require './spec/support/formatter_support'
44

5+
# For Ruby 3.4.0 hash formatting
6+
Then /^the output should print the (include|exclude)d tags {(\w+): (.*)}$/ do |word, key, value|
7+
if RUBY_VERSION.to_f > 3.3
8+
expect(all_output).to include "#{word} {#{key}: #{value}}"
9+
else
10+
expect(all_output).to include "#{word} {:#{key}=>#{value}}"
11+
end
12+
end
13+
14+
Then /^the output should contain in either hash syntax "(.*)"$/ do |string|
15+
if RUBY_VERSION.to_f > 3.3
16+
step "the output should contain \"#{string.gsub(/:(\w+)=>/, '\1: ')}\""
17+
else
18+
step "the output should contain \"#{string}\""
19+
end
20+
end
21+
522
Then /^the output should contain all of these:$/ do |table|
623
table.raw.flatten.each do |string|
724
expect(all_output).to include(string)

0 commit comments

Comments
 (0)