Skip to content

Commit b6f5aec

Browse files
Fix failing tests with Ruby < 2.5
Also remove writer test which is not super useful for now
1 parent 48e5d28 commit b6f5aec

File tree

3 files changed

+35
-33
lines changed

3 files changed

+35
-33
lines changed

lib/cucumber/core/gherkin/writer.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ class Background
8585

8686
private
8787
def statements
88-
prepare_statements comments_statement, tag_statement, name_statement, description_statement
88+
prepare_statements comments_statement,
89+
tag_statement,
90+
name_statement,
91+
description_statement
8992
end
9093
end
9194

@@ -97,13 +100,14 @@ class Rule
97100

98101
default_keyword 'Rule'
99102

100-
elements :scenario
103+
elements :example, :scenario
101104

102105
private
103106
def statements
104107
prepare_statements comments_statement,
105108
name_statement,
106-
description_statement
109+
description_statement,
110+
NEW_LINE
107111
end
108112
end
109113

@@ -126,6 +130,12 @@ def statements
126130
end
127131
end
128132

133+
class Example < Scenario
134+
include Indentation.level 4
135+
136+
default_keyword 'Example'
137+
end
138+
129139
class ScenarioOutline
130140
include HasElements
131141
include HasOptionsInitializer

spec/cucumber/core/gherkin/parser_spec.rb

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,23 @@ def self.source(&block)
9292
context "when scenario is inside a rule" do
9393
source do
9494
feature do
95-
rule do
96-
scenario do
97-
step 'text'
98-
end
95+
rule description: "My castle, my rules" do
96+
scenario name: "My scenario"
97+
end
98+
end
99+
end
100+
101+
it "passes on the pickle" do
102+
expect( receiver ).to receive(:pickle)
103+
parse
104+
end
105+
end
106+
107+
context "when example is inside a rule" do
108+
source do
109+
feature do
110+
rule description: "My castle, my rules" do
111+
example name: "My example"
99112
end
100113
end
101114
end
@@ -106,16 +119,16 @@ def self.source(&block)
106119
end
107120
end
108121

109-
context "when there are multiple rules and scenarios" do
122+
context "when there are multiple rules and scenarios or examples" do
110123
source do
111124
feature do
112-
rule do
113-
scenario do
125+
rule description: "First rule" do
126+
scenario name: "Do not talk about the fight club" do
114127
step 'text'
115128
end
116129
end
117-
rule do
118-
scenario do
130+
rule description: "Second rule"do
131+
example name: "Do not talk about the fight club" do
119132
step 'text'
120133
end
121134
end

spec/cucumber/core/gherkin/writer_spec.rb

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -233,27 +233,6 @@ module Cucumber::Core::Gherkin
233233
end
234234
end
235235
end
236-
237-
context 'with rules' do
238-
xit 'can have a description' do
239-
source = gherkin do
240-
feature do
241-
rule name: "Simple", description: "My castle, my rule" do
242-
scenario name: "My scenario"
243-
end
244-
end
245-
end
246-
247-
expect( source.body ).to eq <<-END.unindent
248-
Feature:
249-
250-
Rule: Simple
251-
My castle, my rules
252-
253-
Scenario: My scenario
254-
END
255-
end
256-
end
257236
end
258237

259238
it 'generates a complex feature' do

0 commit comments

Comments
 (0)