Skip to content

Commit d10d094

Browse files
authored
Reintroduce cleaned up 9.2.1 into main (#1776)
* Initial changelog * Tidy up and use equivalent of polyglot for changelog * Update comment for 3.4 issue * Remove unindenting hack override for snippet spec
1 parent 89b8990 commit d10d094

File tree

4 files changed

+84
-69
lines changed

4 files changed

+84
-69
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ that need to rely on procedural loading / reloading of files should use method i
2323

2424
### Fixed
2525
- Fixed an issue where a change to one example in compatibility testing wasn't fully adhered to ([luke-hill](https://github.com/luke-hill))
26-
- Fixed an issue for Ruby 3.4.0 where a default hash instantiation was being picked up as keyword arguments ([Jon Rowe](https://github.com/JonRowe))
2726

2827
### Removed
2928
- `StepDefinitionLight` associated methods. The class itself is present but deprecated
@@ -32,6 +31,11 @@ that need to rely on procedural loading / reloading of files should use method i
3231
- Tag Expressions using legacy syntax that were handled / sanitized are no longer done so
3332
(This applies to both regular usage and internal testing)
3433
- Removed support for Ruby 2.7 ([luke-hill](https://github.com/luke-hill))
34+
- Unindentation support for snippet generator / tests (Heredocs are much better now) ([luke-hill](https://github.com/luke-hill))
35+
36+
## [9.2.1] - 2025-01-12
37+
### Fixed
38+
- Fixed an issue for Ruby 3.4+ where a default hash instantiation was being picked up as keyword arguments ([Jon Rowe](https://github.com/JonRowe))
3539

3640
## [9.2.0] - 2024-03-19
3741
### Changed
@@ -177,7 +181,8 @@ can use the immutable versions instead: `DataTable#map_column` and
177181
([#1590](https://github.com/cucumber/cucumber-ruby/pull/1590))
178182
- Removed support for Ruby 2.5 and JRuby 9.2.
179183

180-
[Unreleased]: https://github.com/cucumber/cucumber-ruby/compare/v9.2.0...HEAD
184+
[Unreleased]: https://github.com/cucumber/cucumber-ruby/compare/v9.2.1...HEAD
185+
[9.2.1]: https://github.com/cucumber/cucumber-ruby/compare/v9.2.0...v9.2.1
181186
[9.2.0]: https://github.com/cucumber/cucumber-ruby/compare/v9.1.2...v9.2.0
182187
[9.1.2]: https://github.com/cucumber/cucumber-ruby/compare/v9.1.1...v9.1.2
183188
[9.1.1]: https://github.com/cucumber/cucumber-ruby/compare/v9.1.0...v9.1.1

lib/cucumber/multiline_argument/data_table.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def row(row)
7676
def eof; end
7777
end
7878

79-
# This is a Hash being initialized with a default value of a Hash, DO NOT REFORMAT TO REMOVE {}
80-
# Future versions [3.4.0+] of ruby will interpret these as keywords and break.
79+
# This is a Hash being initialized with a default value of a Hash
80+
# DO NOT REFORMAT TO REMOVE {} - Ruby 3.4+ will interpret these as keywords and cucumber will not work
8181
NULL_CONVERSIONS = Hash.new({ strict: false, proc: ->(cell_value) { cell_value } }).freeze
8282

8383
# @param data [Core::Test::DataTable] the data for the table

spec/cucumber/glue/snippet_spec.rb

Lines changed: 74 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -23,121 +23,129 @@ module Glue
2323
@cucumber_expression_generator = CucumberExpressions::CucumberExpressionGenerator.new(@registry)
2424
end
2525

26-
def unindented(snippet)
27-
indent(snippet.split("\n")[1..-2].join("\n"), -10)
28-
end
29-
3026
describe Snippet::Regexp do
3127
let(:snippet_class) { described_class }
3228
let(:snippet_text) { snippet.to_s }
3329

3430
it 'wraps snippet patterns in parentheses' do
3531
@step_text = 'A "string" with 4 spaces'
32+
cucumber_output = <<~CUKE.chomp
33+
Given(/^A "([^"]*)" with (\\d+) spaces$/) do |arg1, arg2|
34+
pending # Write code here that turns the phrase above into concrete actions
35+
end
36+
CUKE
3637

37-
expect(snippet_text).to eq unindented(%{
38-
Given(/^A "([^"]*)" with (\\d+) spaces$/) do |arg1, arg2|
39-
pending # Write code here that turns the phrase above into concrete actions
40-
end
41-
})
38+
expect(snippet_text).to eq(cucumber_output)
4239
end
4340

4441
it 'recognises numbers in name and make according regexp' do
4542
@step_text = 'Cloud 9 yeah'
43+
cucumber_output = <<~CUKE.chomp
44+
Given(/^Cloud (\\d+) yeah$/) do |arg1|
45+
pending # Write code here that turns the phrase above into concrete actions
46+
end
47+
CUKE
4648

47-
expect(snippet_text).to eq unindented(%{
48-
Given(/^Cloud (\\d+) yeah$/) do |arg1|
49-
pending # Write code here that turns the phrase above into concrete actions
50-
end
51-
})
49+
expect(snippet_text).to eq(cucumber_output)
5250
end
5351

5452
it 'recognises a mix of ints, strings and why not a table too' do
5553
@step_text = 'I have 9 "awesome" cukes in 37 "boxes"'
5654
@multiline_argument = Core::Test::DataTable.new([[]])
57-
58-
expect(snippet_text).to eq unindented(%{
59-
Given(/^I have (\\d+) "([^"]*)" cukes in (\\d+) "([^"]*)"$/) do |arg1, arg2, arg3, arg4, table|
60-
# table is a Cucumber::MultilineArgument::DataTable
61-
pending # Write code here that turns the phrase above into concrete actions
62-
end
63-
})
55+
cucumber_output = <<~CUKE.chomp
56+
Given(/^I have (\\d+) "([^"]*)" cukes in (\\d+) "([^"]*)"$/) do |arg1, arg2, arg3, arg4, table|
57+
# table is a Cucumber::MultilineArgument::DataTable
58+
pending # Write code here that turns the phrase above into concrete actions
59+
end
60+
CUKE
61+
62+
expect(snippet_text).to eq(cucumber_output)
6463
end
6564

6665
it 'recognises quotes in name and make according regexp' do
6766
@step_text = 'A "first" arg'
67+
cucumber_output = <<~CUKE.chomp
68+
Given(/^A "([^"]*)" arg$/) do |arg1|
69+
pending # Write code here that turns the phrase above into concrete actions
70+
end
71+
CUKE
6872

69-
expect(snippet_text).to eq unindented(%{
70-
Given(/^A "([^"]*)" arg$/) do |arg1|
71-
pending # Write code here that turns the phrase above into concrete actions
72-
end
73-
})
73+
expect(snippet_text).to eq(cucumber_output)
7474
end
7575

7676
it 'recognises several quoted words in name and make according regexp and args' do
7777
@step_text = 'A "first" and "second" arg'
78+
cucumber_output = <<~CUKE.chomp
79+
Given(/^A "([^"]*)" and "([^"]*)" arg$/) do |arg1, arg2|
80+
pending # Write code here that turns the phrase above into concrete actions
81+
end
82+
CUKE
7883

79-
expect(snippet_text).to eq unindented(%{
80-
Given(/^A "([^"]*)" and "([^"]*)" arg$/) do |arg1, arg2|
81-
pending # Write code here that turns the phrase above into concrete actions
82-
end
83-
})
84+
expect(snippet_text).to eq(cucumber_output)
8485
end
8586

8687
it 'does not use quote group when there are no quotes' do
8788
@step_text = 'A first arg'
89+
cucumber_output = <<~CUKE.chomp
90+
Given(/^A first arg$/) do
91+
pending # Write code here that turns the phrase above into concrete actions
92+
end
93+
CUKE
8894

89-
expect(snippet_text).to eq unindented(%{
90-
Given(/^A first arg$/) do
91-
pending # Write code here that turns the phrase above into concrete actions
92-
end
93-
})
95+
expect(snippet_text).to eq(cucumber_output)
9496
end
9597

9698
it 'is helpful with tables' do
9799
@step_text = 'A "first" arg'
98100
@multiline_argument = Core::Test::DataTable.new([[]])
99-
100-
expect(snippet_text).to eq unindented(%{
101-
Given(/^A "([^"]*)" arg$/) do |arg1, table|
102-
# table is a Cucumber::MultilineArgument::DataTable
103-
pending # Write code here that turns the phrase above into concrete actions
104-
end
105-
})
101+
cucumber_output = <<~CUKE.chomp
102+
Given(/^A "([^"]*)" arg$/) do |arg1, table|
103+
# table is a Cucumber::MultilineArgument::DataTable
104+
pending # Write code here that turns the phrase above into concrete actions
105+
end
106+
CUKE
107+
108+
expect(snippet_text).to eq(cucumber_output)
106109
end
107110

108111
it 'is helpful with doc string' do
109112
@step_text = 'A "first" arg'
110113
@multiline_argument = MultilineArgument.from('', Core::Test::Location.new(''))
114+
cucumber_output = <<~CUKE.chomp
115+
Given(/^A "([^"]*)" arg$/) do |arg1, doc_string|
116+
pending # Write code here that turns the phrase above into concrete actions
117+
end
118+
CUKE
111119

112-
expect(snippet_text).to eq unindented(%{
113-
Given(/^A "([^"]*)" arg$/) do |arg1, doc_string|
114-
pending # Write code here that turns the phrase above into concrete actions
115-
end
116-
})
120+
expect(snippet_text).to eq(cucumber_output)
117121
end
118122
end
119123

120124
describe Snippet::Classic do
121125
let(:snippet_class) { described_class }
122126

123127
it 'renders snippet as unwrapped regular expression' do
124-
expect(snippet.to_s).to eq unindented(%(
125-
Given /^we have a missing step$/ do
126-
pending # Write code here that turns the phrase above into concrete actions
127-
end
128-
))
128+
cucumber_output = <<~CUKE.chomp
129+
Given /^we have a missing step$/ do
130+
pending # Write code here that turns the phrase above into concrete actions
131+
end
132+
CUKE
133+
134+
expect(snippet.to_s).to eq(cucumber_output)
129135
end
130136
end
131137

132138
describe Snippet::Percent do
133139
let(:snippet_class) { described_class }
134140

135141
it 'renders snippet as percent-style regular expression' do
136-
expect(snippet.to_s).to eq unindented(%(
137-
Given %r{^we have a missing step$} do
138-
pending # Write code here that turns the phrase above into concrete actions
139-
end
140-
))
142+
cucumber_output = <<~CUKE.chomp
143+
Given %r{^we have a missing step$} do
144+
pending # Write code here that turns the phrase above into concrete actions
145+
end
146+
CUKE
147+
148+
expect(snippet.to_s).to eq(cucumber_output)
141149
end
142150
end
143151

@@ -163,12 +171,14 @@ def unindented(snippet)
163171
false
164172
))
165173

166-
expect(snippet.to_s).to eq unindented(%{
167-
Given('I have {float} {cucumis} in my belly') do |float, cucumis|
168-
# Given('I have {float} {veg} in my belly') do |float, veg|
169-
pending # Write code here that turns the phrase above into concrete actions
170-
end
171-
})
174+
cucumber_output = <<~CUKE.chomp
175+
Given('I have {float} {cucumis} in my belly') do |float, cucumis|
176+
# Given('I have {float} {veg} in my belly') do |float, veg|
177+
pending # Write code here that turns the phrase above into concrete actions
178+
end
179+
CUKE
180+
181+
expect(snippet.to_s).to eq(cucumber_output)
172182
end
173183
end
174184
end

spec/cucumber/multiline_argument/data_table_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module MultilineArgument
3333
end
3434

3535
describe '#symbolic_hashes' do
36-
it 'coverts data table to an array of hashes with symbols as keys' do
36+
it 'converts data table to an array of hashes with symbols as keys' do
3737
ast_table = Cucumber::Core::Test::DataTable.new([['foo', 'Bar', 'Foo Bar'], %w[1 22 333]])
3838
data_table = described_class.new(ast_table)
3939

0 commit comments

Comments
 (0)