gherkin 2.5.4 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +9 -7
- data/History.md +11 -1
- data/README.md +1 -1
- data/features/json_formatter.feature +376 -310
- data/features/json_parser.feature +245 -228
- data/features/step_definitions/json_formatter_steps.rb +7 -4
- data/features/step_definitions/json_parser_steps.rb +1 -1
- data/features/step_definitions/pretty_formatter_steps.rb +2 -1
- data/gherkin.gemspec +4 -3
- data/lib/gherkin/formatter/json_formatter.rb +13 -9
- data/lib/gherkin/formatter/model.rb +78 -20
- data/lib/gherkin/formatter/pretty_formatter.rb +1 -1
- data/lib/gherkin/i18n.yml +2 -3
- data/lib/gherkin/json_parser.rb +32 -24
- data/lib/gherkin/listener/formatter_listener.rb +76 -50
- data/spec/gherkin/fixtures/complex.json +8 -1
- data/spec/gherkin/formatter/json_formatter_spec.rb +49 -43
- data/spec/gherkin/formatter/model_spec.rb +2 -2
- data/spec/gherkin/formatter/pretty_formatter_spec.rb +10 -10
- data/spec/gherkin/json_parser_spec.rb +93 -77
- data/spec/gherkin/sexp_recorder.rb +0 -3
- metadata +27 -27
@@ -9,17 +9,20 @@ Feature: JSON lexer
|
|
9
9
|
Scenario: Only a Feature
|
10
10
|
Given the following JSON is parsed:
|
11
11
|
"""
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
[
|
13
|
+
{
|
14
|
+
"comments": [
|
15
|
+
{"value": "# language: no"},
|
16
|
+
{"value": "# Another comment"}
|
17
|
+
],
|
18
|
+
"description": "",
|
19
|
+
"keyword": "Egenskap",
|
20
|
+
"id": "kjapp",
|
21
|
+
"name": "Kjapp",
|
22
|
+
"tags": [],
|
23
|
+
"uri": "test.feature"
|
24
|
+
}
|
25
|
+
]
|
23
26
|
"""
|
24
27
|
Then the outputted text should be:
|
25
28
|
"""
|
@@ -31,181 +34,191 @@ Feature: JSON lexer
|
|
31
34
|
Scenario: Feature with scenarios and outlines
|
32
35
|
Given the following JSON is parsed:
|
33
36
|
"""
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
"keyword": "Scenario",
|
137
|
-
"name": "who stole my mojo?",
|
138
|
-
"description": "",
|
139
|
-
"type": "scenario",
|
140
|
-
"line": 23,
|
141
|
-
"steps": [
|
142
|
-
{
|
143
|
-
"comments": [],
|
144
|
-
"keyword": "When ",
|
145
|
-
"name": "I was",
|
146
|
-
"line": 24,
|
147
|
-
"rows": [
|
148
|
-
{
|
149
|
-
"comments": [],
|
150
|
-
"line": 25,
|
151
|
-
"cells": ["asleep"]
|
152
|
-
}
|
153
|
-
]
|
154
|
-
},
|
155
|
-
{
|
156
|
-
"comments": [],
|
157
|
-
"keyword": "And ",
|
158
|
-
"name": "so",
|
159
|
-
"line": 26,
|
160
|
-
"doc_string": {
|
161
|
-
"value": "innocent",
|
162
|
-
"line": 27
|
37
|
+
[
|
38
|
+
{
|
39
|
+
"comments": [],
|
40
|
+
"keyword": "Feature",
|
41
|
+
"id": "oh-hai",
|
42
|
+
"name": "OH HAI",
|
43
|
+
"tags": [{"name": "@one"}],
|
44
|
+
"uri": "test.feature",
|
45
|
+
"description": "",
|
46
|
+
"elements":[
|
47
|
+
{
|
48
|
+
"comments": [],
|
49
|
+
"tags": [],
|
50
|
+
"keyword": "Scenario",
|
51
|
+
"id": "oh-hai/fujin",
|
52
|
+
"name": "Fujin",
|
53
|
+
"description": "",
|
54
|
+
"type": "scenario",
|
55
|
+
"line": 4,
|
56
|
+
"steps": [
|
57
|
+
{
|
58
|
+
"comments": [],
|
59
|
+
"keyword": "Given ",
|
60
|
+
"name": "wind",
|
61
|
+
"line": 5
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"comments": [],
|
65
|
+
"keyword": "Then ",
|
66
|
+
"name": "spirit",
|
67
|
+
"line": 6
|
68
|
+
}
|
69
|
+
]
|
70
|
+
},
|
71
|
+
{
|
72
|
+
"comments": [],
|
73
|
+
"tags": [{"name": "@two"}],
|
74
|
+
"keyword": "Scenario",
|
75
|
+
"id": "oh-hai/_why",
|
76
|
+
"name": "_why",
|
77
|
+
"description": "",
|
78
|
+
"type": "scenario",
|
79
|
+
"line": 9,
|
80
|
+
"steps": [
|
81
|
+
{
|
82
|
+
"comments": [],
|
83
|
+
"keyword": "Given ",
|
84
|
+
"name": "chunky",
|
85
|
+
"line": 10
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"comments": [],
|
89
|
+
"keyword": "Then ",
|
90
|
+
"name": "bacon",
|
91
|
+
"line": 11
|
92
|
+
}
|
93
|
+
]
|
94
|
+
},
|
95
|
+
{
|
96
|
+
"comments": [],
|
97
|
+
"tags": [{"name": "@three"}, {"name": "@four"}],
|
98
|
+
"keyword": "Scenario Outline",
|
99
|
+
"id": "oh-hai/life",
|
100
|
+
"name": "Life",
|
101
|
+
"description": "",
|
102
|
+
"type": "scenario_outline",
|
103
|
+
"line": 14,
|
104
|
+
"steps": [
|
105
|
+
{
|
106
|
+
"comments": [],
|
107
|
+
"keyword": "Given ",
|
108
|
+
"name": "some <boredom>",
|
109
|
+
"line": 15
|
110
|
+
}
|
111
|
+
],
|
112
|
+
"examples": [
|
113
|
+
{
|
114
|
+
"type": "examples",
|
115
|
+
"comments": [],
|
116
|
+
"tags": [{"name": "@five"}],
|
117
|
+
"keyword": "Examples",
|
118
|
+
"id": "oh-hai/life/real-life",
|
119
|
+
"name": "Real life",
|
120
|
+
"description": "",
|
121
|
+
"line": 18,
|
122
|
+
"rows": [
|
123
|
+
{
|
124
|
+
"comments": [],
|
125
|
+
"cells": ["boredom"],
|
126
|
+
"line": 19
|
127
|
+
},
|
128
|
+
{
|
129
|
+
"comments": [],
|
130
|
+
"cells": ["airport"],
|
131
|
+
"line": 20
|
132
|
+
},
|
133
|
+
{
|
134
|
+
"comments": [],
|
135
|
+
"cells": ["meeting"],
|
136
|
+
"line": 21
|
137
|
+
}
|
138
|
+
]
|
163
139
|
}
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
"
|
196
|
-
"
|
197
|
-
},
|
198
|
-
{
|
199
|
-
"comments": [{"value": "# I really mean"}],
|
200
|
-
"line": 40,
|
201
|
-
"cells": ["bartout"]
|
140
|
+
]
|
141
|
+
},
|
142
|
+
{
|
143
|
+
"comments": [],
|
144
|
+
"tags": [],
|
145
|
+
"keyword": "Scenario",
|
146
|
+
"id": "oh-hai/who-stole-my-mojo?",
|
147
|
+
"name": "who stole my mojo?",
|
148
|
+
"description": "",
|
149
|
+
"type": "scenario",
|
150
|
+
"line": 23,
|
151
|
+
"steps": [
|
152
|
+
{
|
153
|
+
"comments": [],
|
154
|
+
"keyword": "When ",
|
155
|
+
"name": "I was",
|
156
|
+
"line": 24,
|
157
|
+
"rows": [
|
158
|
+
{
|
159
|
+
"comments": [],
|
160
|
+
"line": 25,
|
161
|
+
"cells": ["asleep"]
|
162
|
+
}
|
163
|
+
]
|
164
|
+
},
|
165
|
+
{
|
166
|
+
"comments": [],
|
167
|
+
"keyword": "And ",
|
168
|
+
"name": "so",
|
169
|
+
"line": 26,
|
170
|
+
"doc_string": {
|
171
|
+
"value": "innocent",
|
172
|
+
"line": 27
|
202
173
|
}
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
174
|
+
}
|
175
|
+
]
|
176
|
+
},
|
177
|
+
{
|
178
|
+
"comments": [{"value": "# The"}],
|
179
|
+
"tags": [],
|
180
|
+
"keyword": "Scenario Outline",
|
181
|
+
"description": "",
|
182
|
+
"type": "scenario_outline",
|
183
|
+
"line": 32,
|
184
|
+
"id": "oh-hai/with",
|
185
|
+
"name": "with",
|
186
|
+
"steps": [
|
187
|
+
{
|
188
|
+
"comments": [{"value": "# all"}],
|
189
|
+
"keyword": "Then ",
|
190
|
+
"line": 34,
|
191
|
+
"name": "nice"
|
192
|
+
}
|
193
|
+
],
|
194
|
+
"examples": [
|
195
|
+
{
|
196
|
+
"type": "examples",
|
197
|
+
"comments": [{"value": "# comments"}, {"value": "# everywhere"}],
|
198
|
+
"tags": [],
|
199
|
+
"keyword": "Examples",
|
200
|
+
"id": "oh-hai/with/an-example",
|
201
|
+
"name": "An example",
|
202
|
+
"description": "",
|
203
|
+
"line": 38,
|
204
|
+
"rows": [
|
205
|
+
{
|
206
|
+
"comments": [{"value": "# I mean"}],
|
207
|
+
"line": 40,
|
208
|
+
"cells": ["partout"]
|
209
|
+
},
|
210
|
+
{
|
211
|
+
"comments": [{"value": "# I really mean"}],
|
212
|
+
"line": 40,
|
213
|
+
"cells": ["bartout"]
|
214
|
+
}
|
215
|
+
]
|
216
|
+
}
|
217
|
+
]
|
218
|
+
}
|
219
|
+
]
|
220
|
+
}
|
221
|
+
]
|
209
222
|
"""
|
210
223
|
Then the outputted text should be:
|
211
224
|
"""
|
@@ -253,52 +266,56 @@ Feature: JSON lexer
|
|
253
266
|
| bartout |
|
254
267
|
"""
|
255
268
|
|
256
|
-
Scenario:
|
269
|
+
Scenario: Feature with Background
|
257
270
|
Given the following JSON is parsed:
|
258
271
|
"""
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
272
|
+
[
|
273
|
+
{
|
274
|
+
"comments": [],
|
275
|
+
"description": "",
|
276
|
+
"keyword": "Feature",
|
277
|
+
"id": "kjapp",
|
278
|
+
"name": "Kjapp",
|
279
|
+
"tags": [],
|
280
|
+
"uri": "test.feature",
|
281
|
+
"elements": [
|
282
|
+
{
|
283
|
+
"type": "background",
|
284
|
+
"comments": [],
|
285
|
+
"description": "",
|
286
|
+
"keyword": "Background",
|
287
|
+
"line": 2,
|
288
|
+
"name": "No idea what Kjapp means",
|
289
|
+
"steps": [
|
290
|
+
{
|
291
|
+
"comments": [],
|
292
|
+
"keyword": "Given ",
|
293
|
+
"line": 3,
|
294
|
+
"name": "I Google it"
|
295
|
+
}
|
296
|
+
]
|
297
|
+
},
|
298
|
+
{
|
299
|
+
"type": "scenario",
|
300
|
+
"comments": [{"value": "# Writing JSON by hand sucks"}],
|
301
|
+
"tags": [],
|
302
|
+
"keyword": "Scenario",
|
303
|
+
"id": "kjapp/",
|
304
|
+
"name": "",
|
305
|
+
"description": "",
|
306
|
+
"line": 6,
|
307
|
+
"steps": [
|
308
|
+
{
|
309
|
+
"comments": [],
|
310
|
+
"keyword": "Then ",
|
311
|
+
"name": "I think it means \"fast\"",
|
312
|
+
"line": 7
|
313
|
+
}
|
314
|
+
]
|
315
|
+
}
|
316
|
+
]
|
317
|
+
}
|
318
|
+
]
|
302
319
|
"""
|
303
320
|
Then the outputted text should be:
|
304
321
|
"""
|