bryanl-gherkin 2.11.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +2 -0
- data/.mailmap +2 -0
- data/.rbenv-gemsets +1 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/.travis.yml +16 -0
- data/.yardopts +5 -0
- data/Gemfile +5 -0
- data/History.md +788 -0
- data/LICENSE +20 -0
- data/README.md +272 -0
- data/Rakefile +26 -0
- data/build_native_gems.sh +7 -0
- data/cucumber.yml +4 -0
- data/examples/parse_and_output_json.rb +19 -0
- data/features/.cucumber/stepdefs.json +244 -0
- data/features/escaped_pipes.feature +8 -0
- data/features/feature_parser.feature +237 -0
- data/features/json_formatter.feature +498 -0
- data/features/json_parser.feature +331 -0
- data/features/native_lexer.feature +19 -0
- data/features/parser_with_native_lexer.feature +205 -0
- data/features/pretty_formatter.feature +16 -0
- data/features/step_definitions/eyeball_steps.rb +3 -0
- data/features/step_definitions/gherkin_steps.rb +29 -0
- data/features/step_definitions/json_formatter_steps.rb +30 -0
- data/features/step_definitions/json_parser_steps.rb +20 -0
- data/features/step_definitions/pretty_formatter_steps.rb +85 -0
- data/features/steps_parser.feature +46 -0
- data/features/support/env.rb +42 -0
- data/gherkin.gemspec +77 -0
- data/install_mingw_os_x.sh +7 -0
- data/js/.npmignore +1 -0
- data/js/lib/gherkin/lexer/.npmignore +0 -0
- data/lib/gherkin.rb +2 -0
- data/lib/gherkin/c_lexer.rb +17 -0
- data/lib/gherkin/formatter/ansi_escapes.rb +97 -0
- data/lib/gherkin/formatter/argument.rb +16 -0
- data/lib/gherkin/formatter/escaping.rb +15 -0
- data/lib/gherkin/formatter/filter_formatter.rb +146 -0
- data/lib/gherkin/formatter/hashable.rb +19 -0
- data/lib/gherkin/formatter/json_formatter.rb +122 -0
- data/lib/gherkin/formatter/line_filter.rb +26 -0
- data/lib/gherkin/formatter/model.rb +281 -0
- data/lib/gherkin/formatter/pretty_formatter.rb +244 -0
- data/lib/gherkin/formatter/regexp_filter.rb +21 -0
- data/lib/gherkin/formatter/step_printer.rb +21 -0
- data/lib/gherkin/formatter/tag_count_formatter.rb +47 -0
- data/lib/gherkin/formatter/tag_filter.rb +19 -0
- data/lib/gherkin/i18n.rb +180 -0
- data/lib/gherkin/i18n.yml +613 -0
- data/lib/gherkin/js_lexer.rb +20 -0
- data/lib/gherkin/json_parser.rb +177 -0
- data/lib/gherkin/lexer/i18n_lexer.rb +46 -0
- data/lib/gherkin/listener/event.rb +45 -0
- data/lib/gherkin/listener/formatter_listener.rb +143 -0
- data/lib/gherkin/native.rb +7 -0
- data/lib/gherkin/native/java.rb +72 -0
- data/lib/gherkin/native/null.rb +5 -0
- data/lib/gherkin/native/therubyracer.rb +39 -0
- data/lib/gherkin/parser/meta.txt +5 -0
- data/lib/gherkin/parser/parser.rb +164 -0
- data/lib/gherkin/parser/root.txt +11 -0
- data/lib/gherkin/parser/steps.txt +4 -0
- data/lib/gherkin/rb_lexer.rb +8 -0
- data/lib/gherkin/rb_lexer/README.rdoc +8 -0
- data/lib/gherkin/rb_lexer/ar.rb +1165 -0
- data/lib/gherkin/rb_lexer/bg.rb +1377 -0
- data/lib/gherkin/rb_lexer/bm.rb +1081 -0
- data/lib/gherkin/rb_lexer/ca.rb +1305 -0
- data/lib/gherkin/rb_lexer/cs.rb +1157 -0
- data/lib/gherkin/rb_lexer/cy_gb.rb +1027 -0
- data/lib/gherkin/rb_lexer/da.rb +1043 -0
- data/lib/gherkin/rb_lexer/de.rb +1151 -0
- data/lib/gherkin/rb_lexer/en.rb +1151 -0
- data/lib/gherkin/rb_lexer/en_au.rb +971 -0
- data/lib/gherkin/rb_lexer/en_lol.rb +929 -0
- data/lib/gherkin/rb_lexer/en_pirate.rb +1205 -0
- data/lib/gherkin/rb_lexer/en_scouse.rb +1357 -0
- data/lib/gherkin/rb_lexer/en_tx.rb +1011 -0
- data/lib/gherkin/rb_lexer/eo.rb +990 -0
- data/lib/gherkin/rb_lexer/es.rb +1135 -0
- data/lib/gherkin/rb_lexer/et.rb +985 -0
- data/lib/gherkin/rb_lexer/fi.rb +964 -0
- data/lib/gherkin/rb_lexer/fr.rb +1223 -0
- data/lib/gherkin/rb_lexer/he.rb +1113 -0
- data/lib/gherkin/rb_lexer/hr.rb +1061 -0
- data/lib/gherkin/rb_lexer/hu.rb +1113 -0
- data/lib/gherkin/rb_lexer/id.rb +958 -0
- data/lib/gherkin/rb_lexer/is.rb +1115 -0
- data/lib/gherkin/rb_lexer/it.rb +1081 -0
- data/lib/gherkin/rb_lexer/ja.rb +1413 -0
- data/lib/gherkin/rb_lexer/ko.rb +1097 -0
- data/lib/gherkin/rb_lexer/lt.rb +1040 -0
- data/lib/gherkin/rb_lexer/lu.rb +1127 -0
- data/lib/gherkin/rb_lexer/lv.rb +1161 -0
- data/lib/gherkin/rb_lexer/nl.rb +1110 -0
- data/lib/gherkin/rb_lexer/no.rb +1055 -0
- data/lib/gherkin/rb_lexer/pl.rb +1452 -0
- data/lib/gherkin/rb_lexer/pt.rb +1425 -0
- data/lib/gherkin/rb_lexer/ro.rb +1159 -0
- data/lib/gherkin/rb_lexer/ru.rb +1749 -0
- data/lib/gherkin/rb_lexer/sk.rb +1041 -0
- data/lib/gherkin/rb_lexer/sr_cyrl.rb +1798 -0
- data/lib/gherkin/rb_lexer/sr_latn.rb +1289 -0
- data/lib/gherkin/rb_lexer/sv.rb +1065 -0
- data/lib/gherkin/rb_lexer/tr.rb +1087 -0
- data/lib/gherkin/rb_lexer/uk.rb +1641 -0
- data/lib/gherkin/rb_lexer/uz.rb +1371 -0
- data/lib/gherkin/rb_lexer/vi.rb +1193 -0
- data/lib/gherkin/rb_lexer/zh_cn.rb +1053 -0
- data/lib/gherkin/rb_lexer/zh_tw.rb +1047 -0
- data/lib/gherkin/rubify.rb +24 -0
- data/lib/gherkin/tag_expression.rb +62 -0
- data/ragel/lexer.c.rl.erb +454 -0
- data/ragel/lexer.java.rl.erb +219 -0
- data/ragel/lexer.js.rl.erb +227 -0
- data/ragel/lexer.rb.rl.erb +174 -0
- data/ragel/lexer_common.rl.erb +50 -0
- data/spec/gherkin/c_lexer_spec.rb +22 -0
- data/spec/gherkin/fixtures/1.feature +8 -0
- data/spec/gherkin/fixtures/comments_in_table.feature +9 -0
- data/spec/gherkin/fixtures/complex.feature +45 -0
- data/spec/gherkin/fixtures/complex.json +139 -0
- data/spec/gherkin/fixtures/complex_for_filtering.feature +60 -0
- data/spec/gherkin/fixtures/complex_with_tags.feature +61 -0
- data/spec/gherkin/fixtures/dos_line_endings.feature +45 -0
- data/spec/gherkin/fixtures/examples_with_only_header.feature +14 -0
- data/spec/gherkin/fixtures/hantu_pisang.feature +35 -0
- data/spec/gherkin/fixtures/i18n_fr.feature +14 -0
- data/spec/gherkin/fixtures/i18n_fr2.feature +8 -0
- data/spec/gherkin/fixtures/i18n_no.feature +7 -0
- data/spec/gherkin/fixtures/i18n_pt1.feature +44 -0
- data/spec/gherkin/fixtures/i18n_pt2.feature +4 -0
- data/spec/gherkin/fixtures/i18n_pt3.feature +4 -0
- data/spec/gherkin/fixtures/i18n_pt4.feature +4 -0
- data/spec/gherkin/fixtures/i18n_zh-CN.feature +9 -0
- data/spec/gherkin/fixtures/issue_145.feature +22 -0
- data/spec/gherkin/fixtures/scenario_outline_with_tags.feature +13 -0
- data/spec/gherkin/fixtures/scenario_without_steps.feature +5 -0
- data/spec/gherkin/fixtures/simple_with_comments.feature +7 -0
- data/spec/gherkin/fixtures/simple_with_tags.feature +11 -0
- data/spec/gherkin/fixtures/with_bom.feature +3 -0
- data/spec/gherkin/formatter/ansi_escapes_spec.rb +32 -0
- data/spec/gherkin/formatter/filter_formatter_spec.rb +204 -0
- data/spec/gherkin/formatter/json_formatter_spec.rb +92 -0
- data/spec/gherkin/formatter/model_spec.rb +28 -0
- data/spec/gherkin/formatter/pretty_formatter_spec.rb +177 -0
- data/spec/gherkin/formatter/spaces.feature +9 -0
- data/spec/gherkin/formatter/step_printer_spec.rb +55 -0
- data/spec/gherkin/formatter/tabs.feature +9 -0
- data/spec/gherkin/formatter/tag_count_formatter_spec.rb +30 -0
- data/spec/gherkin/i18n_spec.rb +241 -0
- data/spec/gherkin/java_lexer_spec.rb +20 -0
- data/spec/gherkin/js_lexer_spec.rb +23 -0
- data/spec/gherkin/json_parser_spec.rb +176 -0
- data/spec/gherkin/lexer/i18n_lexer_spec.rb +43 -0
- data/spec/gherkin/output_stream_string_io.rb +20 -0
- data/spec/gherkin/parser/parser_spec.rb +16 -0
- data/spec/gherkin/rb_lexer_spec.rb +20 -0
- data/spec/gherkin/sexp_recorder.rb +59 -0
- data/spec/gherkin/shared/bom_group.rb +20 -0
- data/spec/gherkin/shared/doc_string_group.rb +163 -0
- data/spec/gherkin/shared/lexer_group.rb +591 -0
- data/spec/gherkin/shared/row_group.rb +125 -0
- data/spec/gherkin/shared/tags_group.rb +54 -0
- data/spec/gherkin/tag_expression_spec.rb +142 -0
- data/spec/spec_helper.rb +75 -0
- data/tasks/bench.rake +184 -0
- data/tasks/bench/feature_builder.rb +49 -0
- data/tasks/bench/null_listener.rb +4 -0
- data/tasks/compile.rake +120 -0
- data/tasks/cucumber.rake +22 -0
- data/tasks/gems.rake +31 -0
- data/tasks/ikvm.rake +124 -0
- data/tasks/ragel_task.rb +100 -0
- data/tasks/release.rake +49 -0
- data/tasks/rspec.rake +8 -0
- data/tasks/yard.rake +7 -0
- data/tasks/yard/default/layout/html/bubble_32x32.png +0 -0
- data/tasks/yard/default/layout/html/bubble_48x48.png +0 -0
- data/tasks/yard/default/layout/html/footer.erb +5 -0
- data/tasks/yard/default/layout/html/index.erb +1 -0
- data/tasks/yard/default/layout/html/layout.erb +25 -0
- data/tasks/yard/default/layout/html/logo.erb +1 -0
- data/tasks/yard/default/layout/html/setup.rb +4 -0
- metadata +473 -0
@@ -0,0 +1,331 @@
|
|
1
|
+
Feature: JSON lexer
|
2
|
+
In order to support greater access to features
|
3
|
+
we want JSON
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a PrettyFormatter
|
7
|
+
And a JSON lexer
|
8
|
+
|
9
|
+
Scenario: Only a Feature
|
10
|
+
Given the following JSON is parsed:
|
11
|
+
"""
|
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
|
+
]
|
26
|
+
"""
|
27
|
+
Then the outputted text should be:
|
28
|
+
"""
|
29
|
+
# language: no
|
30
|
+
# Another comment
|
31
|
+
Egenskap: Kjapp
|
32
|
+
"""
|
33
|
+
|
34
|
+
Scenario: Feature with scenarios and outlines
|
35
|
+
Given the following JSON is parsed:
|
36
|
+
"""
|
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
|
+
]
|
139
|
+
}
|
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
|
173
|
+
}
|
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
|
+
]
|
222
|
+
"""
|
223
|
+
Then the outputted text should be:
|
224
|
+
"""
|
225
|
+
@one
|
226
|
+
Feature: OH HAI
|
227
|
+
|
228
|
+
Scenario: Fujin
|
229
|
+
Given wind
|
230
|
+
Then spirit
|
231
|
+
|
232
|
+
@two
|
233
|
+
Scenario: _why
|
234
|
+
Given chunky
|
235
|
+
Then bacon
|
236
|
+
|
237
|
+
@three @four
|
238
|
+
Scenario Outline: Life
|
239
|
+
Given some <boredom>
|
240
|
+
|
241
|
+
@five
|
242
|
+
Examples: Real life
|
243
|
+
| boredom |
|
244
|
+
| airport |
|
245
|
+
| meeting |
|
246
|
+
|
247
|
+
Scenario: who stole my mojo?
|
248
|
+
When I was
|
249
|
+
| asleep |
|
250
|
+
And so
|
251
|
+
\"\"\"
|
252
|
+
innocent
|
253
|
+
\"\"\"
|
254
|
+
|
255
|
+
# The
|
256
|
+
Scenario Outline: with
|
257
|
+
# all
|
258
|
+
Then nice
|
259
|
+
|
260
|
+
# comments
|
261
|
+
# everywhere
|
262
|
+
Examples: An example
|
263
|
+
# I mean
|
264
|
+
| partout |
|
265
|
+
# I really mean
|
266
|
+
| bartout |
|
267
|
+
"""
|
268
|
+
|
269
|
+
Scenario: Feature with Background
|
270
|
+
Given the following JSON is parsed:
|
271
|
+
"""
|
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
|
+
]
|
319
|
+
"""
|
320
|
+
Then the outputted text should be:
|
321
|
+
"""
|
322
|
+
Feature: Kjapp
|
323
|
+
|
324
|
+
Background: No idea what Kjapp means
|
325
|
+
Given I Google it
|
326
|
+
|
327
|
+
# Writing JSON by hand sucks
|
328
|
+
Scenario:
|
329
|
+
Then I think it means "fast"
|
330
|
+
"""
|
331
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Native (C/Java) Lexer
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a "native" "root" parser
|
5
|
+
|
6
|
+
Scenario: Parsing an empty feature
|
7
|
+
Given the following text is parsed:
|
8
|
+
"""
|
9
|
+
Feature: blah
|
10
|
+
"""
|
11
|
+
Then there should be no parse errors
|
12
|
+
|
13
|
+
Scenario: Parsing a comment
|
14
|
+
Given the following text is parsed:
|
15
|
+
"""
|
16
|
+
# A comment
|
17
|
+
Feature: Hello
|
18
|
+
"""
|
19
|
+
Then there should be no parse errors
|
@@ -0,0 +1,205 @@
|
|
1
|
+
Feature: Gherkin Feature lexer/parser
|
2
|
+
In order to make it easy to control the Gherkin syntax
|
3
|
+
As a Gherkin developer bent on Gherkin world-domination
|
4
|
+
I want a feature lexer that uses a feature parser to
|
5
|
+
make all the syntax decisions for me
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a "native" "root" parser
|
9
|
+
|
10
|
+
Scenario: Correctly formed feature
|
11
|
+
When the following text is parsed:
|
12
|
+
"""
|
13
|
+
# Apologies to Bill Watterson
|
14
|
+
@cardboard_box @wip
|
15
|
+
Feature: Transmogrification
|
16
|
+
As a young boy with a hyperactive imagination
|
17
|
+
I want a cardboard box
|
18
|
+
In order to transform the ennui of suburban life into something
|
19
|
+
befitting my imagination
|
20
|
+
|
21
|
+
Background:
|
22
|
+
Given I have a transmogrifier
|
23
|
+
And I am a member of G.R.O.S.S
|
24
|
+
|
25
|
+
Scenario: Whoozit to whatzit transmogrification
|
26
|
+
Given I have a whoozit
|
27
|
+
When I put it in the transmogrifier
|
28
|
+
And I press the "transmogrify" button
|
29
|
+
Then I should have a whatzit
|
30
|
+
|
31
|
+
Scenario Outline: Imaginary Beings
|
32
|
+
Given I have a <boring being>
|
33
|
+
When I transmogrify it with the incantation:
|
34
|
+
\"\"\"
|
35
|
+
ALAKAZAM!
|
36
|
+
\"\"\"
|
37
|
+
Then I should have an <exciting being>
|
38
|
+
|
39
|
+
Examples:
|
40
|
+
| boring being | exciting being |
|
41
|
+
| Sparrow | Alicanto |
|
42
|
+
| Goldfish | Baldanders |
|
43
|
+
| Cow | Hsiao |
|
44
|
+
|
45
|
+
Scenario: Sense of humor detection
|
46
|
+
Given the following excerpt:
|
47
|
+
\"\"\"
|
48
|
+
WOMAN: Who are the Britons?
|
49
|
+
ARTHUR: Well, we all are. we're all Britons and I am your king.
|
50
|
+
WOMAN: I didn't know we had a king. I thought we were an autonomous
|
51
|
+
collective.
|
52
|
+
DENNIS: You're fooling yourself. We're living in a dictatorship.
|
53
|
+
A self-perpetuating autocracy in which the working classes--
|
54
|
+
WOMAN: Oh there you go, bringing class into it again.
|
55
|
+
DENNIS: That's what it's all about if only people would--
|
56
|
+
ARTHUR: Please, please good people. I am in haste. Who lives
|
57
|
+
in that castle?
|
58
|
+
\"\"\"
|
59
|
+
When I read it
|
60
|
+
Then I should be amused
|
61
|
+
"""
|
62
|
+
Then there should be no parse errors
|
63
|
+
|
64
|
+
Scenario: Keyword before feature
|
65
|
+
When the following text is parsed:
|
66
|
+
"""
|
67
|
+
Scenario: Bullying my way to the head of the line
|
68
|
+
Given I am a big bully of a scenario
|
69
|
+
Then I should be caught by the syntax police(y)
|
70
|
+
|
71
|
+
Feature: Too timid to stand up for myself
|
72
|
+
"""
|
73
|
+
Then there should be parse errors on lines 1 through 3
|
74
|
+
|
75
|
+
Scenario: Tag ends background and scenario
|
76
|
+
When the following text is parsed:
|
77
|
+
"""
|
78
|
+
Feature: test feature
|
79
|
+
Background:
|
80
|
+
Given a something
|
81
|
+
@tag
|
82
|
+
And something else
|
83
|
+
|
84
|
+
@foo
|
85
|
+
Scenario: my scenario
|
86
|
+
@tag
|
87
|
+
Given this is a step
|
88
|
+
@oh_hai
|
89
|
+
And this is a horrible idea
|
90
|
+
Then it shouldn't work
|
91
|
+
"""
|
92
|
+
Then there should be parse errors on lines 5, 10 and 12
|
93
|
+
|
94
|
+
Scenario: Tables
|
95
|
+
When the following text is parsed:
|
96
|
+
"""
|
97
|
+
Feature: Antiques Roadshow
|
98
|
+
Scenario Outline: Table
|
99
|
+
Given a <foo>
|
100
|
+
Then a <bar>
|
101
|
+
|
102
|
+
Examples:
|
103
|
+
| foo | bar |
|
104
|
+
| 42 | towel |
|
105
|
+
@hello
|
106
|
+
| 1 | prime |
|
107
|
+
|
108
|
+
Scenario: Table arguments
|
109
|
+
Given this step needs this table:
|
110
|
+
| foo | bar |
|
111
|
+
| one | two |
|
112
|
+
@tag
|
113
|
+
| aaa | bbb |
|
114
|
+
"""
|
115
|
+
Then there should be parse errors on lines 10 and 17
|
116
|
+
|
117
|
+
Scenario: Multiline keyword descriptions
|
118
|
+
When the following text is parsed:
|
119
|
+
"""
|
120
|
+
Feature: Documentation is fun
|
121
|
+
Scenario Outline: With lots of docs
|
122
|
+
We need lots of embedded documentation for some reason
|
123
|
+
\"\"\" # Not interpreted as a pystring, just plain text
|
124
|
+
Oh hai
|
125
|
+
\"\"\"
|
126
|
+
|
127
|
+
La la la
|
128
|
+
|
129
|
+
Examples:
|
130
|
+
| one | two |
|
131
|
+
| foo | bar |
|
132
|
+
|
133
|
+
\"\"\"
|
134
|
+
Oh Hello
|
135
|
+
\"\"\"
|
136
|
+
|
137
|
+
# Body of the scenario outline starts below
|
138
|
+
Given <something>
|
139
|
+
And something <else>
|
140
|
+
|
141
|
+
# The real examples table
|
142
|
+
Examples:
|
143
|
+
| something | else |
|
144
|
+
| orange | apple |
|
145
|
+
"""
|
146
|
+
Then there should be no parse errors
|
147
|
+
|
148
|
+
Scenario: Scenario Outline with multiple Example groups
|
149
|
+
When the following text is parsed:
|
150
|
+
"""
|
151
|
+
Feature: Outline Sample
|
152
|
+
|
153
|
+
Scenario: I have no steps
|
154
|
+
|
155
|
+
Scenario Outline: Test state
|
156
|
+
Given <state> without a table
|
157
|
+
Given <other_state> without a table
|
158
|
+
|
159
|
+
Examples: Rainbow colours
|
160
|
+
| state | other_state |
|
161
|
+
| missing | passing |
|
162
|
+
| passing | passing |
|
163
|
+
| failing | passing |
|
164
|
+
|
165
|
+
Examples: Only passing
|
166
|
+
| state | other_state |
|
167
|
+
| passing | passing |
|
168
|
+
"""
|
169
|
+
Then there should be no parse errors
|
170
|
+
|
171
|
+
Scenario: Multiple Scenario Outlines with multiline outline steps
|
172
|
+
When the following text is parsed:
|
173
|
+
"""
|
174
|
+
Feature: Test
|
175
|
+
Scenario Outline: with step tables
|
176
|
+
Given I have the following fruits in my pantry
|
177
|
+
| name | quantity |
|
178
|
+
| cucumbers | 10 |
|
179
|
+
| strawberrys | 5 |
|
180
|
+
| apricots | 7 |
|
181
|
+
|
182
|
+
When I eat <number> <fruits> from the pantry
|
183
|
+
Then I should have <left> <fruits> in the pantry
|
184
|
+
|
185
|
+
Examples:
|
186
|
+
| number | fruits | left |
|
187
|
+
| 2 | cucumbers | 8 |
|
188
|
+
| 4 | strawberrys | 1 |
|
189
|
+
| 2 | apricots | 5 |
|
190
|
+
|
191
|
+
Scenario Outline: placeholder in a multiline string
|
192
|
+
Given my shopping list
|
193
|
+
\"\"\"
|
194
|
+
Must buy some <fruits>
|
195
|
+
\"\"\"
|
196
|
+
Then my shopping list should equal
|
197
|
+
\"\"\"
|
198
|
+
Must buy some cucumbers
|
199
|
+
\"\"\"
|
200
|
+
|
201
|
+
Examples:
|
202
|
+
| fruits |
|
203
|
+
| cucumbers |
|
204
|
+
"""
|
205
|
+
Then there should be no parse errors
|