benhamill-gherkin 2.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/.gitattributes +2 -0
  2. data/.gitignore +11 -0
  3. data/.mailmap +2 -0
  4. data/.rspec +1 -0
  5. data/.rvmrc +1 -0
  6. data/Gemfile +7 -0
  7. data/History.txt +363 -0
  8. data/LICENSE +20 -0
  9. data/README.rdoc +149 -0
  10. data/Rakefile +19 -0
  11. data/VERSION +1 -0
  12. data/build_native_gems.sh +8 -0
  13. data/cucumber.yml +3 -0
  14. data/features/escaped_pipes.feature +8 -0
  15. data/features/feature_parser.feature +237 -0
  16. data/features/json_formatter.feature +377 -0
  17. data/features/json_parser.feature +318 -0
  18. data/features/native_lexer.feature +19 -0
  19. data/features/parser_with_native_lexer.feature +205 -0
  20. data/features/pretty_formatter.feature +15 -0
  21. data/features/step_definitions/eyeball_steps.rb +3 -0
  22. data/features/step_definitions/gherkin_steps.rb +29 -0
  23. data/features/step_definitions/json_formatter_steps.rb +28 -0
  24. data/features/step_definitions/json_parser_steps.rb +20 -0
  25. data/features/step_definitions/pretty_formatter_steps.rb +84 -0
  26. data/features/steps_parser.feature +46 -0
  27. data/features/support/env.rb +38 -0
  28. data/gherkin.gemspec +61 -0
  29. data/ikvm/.gitignore +3 -0
  30. data/java/.gitignore +5 -0
  31. data/java/src/main/java/gherkin/lexer/i18n/.gitignore +1 -0
  32. data/java/src/main/resources/gherkin/.gitignore +1 -0
  33. data/js/lib/gherkin/lexer/i18n/ar.js +1094 -0
  34. data/js/lib/gherkin/lexer/i18n/bg.js +1308 -0
  35. data/js/lib/gherkin/lexer/i18n/ca.js +1236 -0
  36. data/js/lib/gherkin/lexer/i18n/cs.js +1090 -0
  37. data/js/lib/gherkin/lexer/i18n/cy_gb.js +958 -0
  38. data/js/lib/gherkin/lexer/i18n/da.js +974 -0
  39. data/js/lib/gherkin/lexer/i18n/de.js +1082 -0
  40. data/js/lib/gherkin/lexer/i18n/en.js +965 -0
  41. data/js/lib/gherkin/lexer/i18n/en_au.js +902 -0
  42. data/js/lib/gherkin/lexer/i18n/en_lol.js +859 -0
  43. data/js/lib/gherkin/lexer/i18n/en_pirate.js +1136 -0
  44. data/js/lib/gherkin/lexer/i18n/en_scouse.js +1289 -0
  45. data/js/lib/gherkin/lexer/i18n/en_tx.js +942 -0
  46. data/js/lib/gherkin/lexer/i18n/eo.js +916 -0
  47. data/js/lib/gherkin/lexer/i18n/es.js +1049 -0
  48. data/js/lib/gherkin/lexer/i18n/et.js +915 -0
  49. data/js/lib/gherkin/lexer/i18n/fi.js +894 -0
  50. data/js/lib/gherkin/lexer/i18n/fr.js +1116 -0
  51. data/js/lib/gherkin/lexer/i18n/he.js +1044 -0
  52. data/js/lib/gherkin/lexer/i18n/hr.js +994 -0
  53. data/js/lib/gherkin/lexer/i18n/hu.js +1043 -0
  54. data/js/lib/gherkin/lexer/i18n/id.js +884 -0
  55. data/js/lib/gherkin/lexer/i18n/it.js +1007 -0
  56. data/js/lib/gherkin/lexer/i18n/ja.js +1344 -0
  57. data/js/lib/gherkin/lexer/i18n/ko.js +1028 -0
  58. data/js/lib/gherkin/lexer/i18n/lt.js +972 -0
  59. data/js/lib/gherkin/lexer/i18n/lu.js +1057 -0
  60. data/js/lib/gherkin/lexer/i18n/lv.js +1092 -0
  61. data/js/lib/gherkin/lexer/i18n/nl.js +1036 -0
  62. data/js/lib/gherkin/lexer/i18n/no.js +986 -0
  63. data/js/lib/gherkin/lexer/i18n/pl.js +1140 -0
  64. data/js/lib/gherkin/lexer/i18n/pt.js +1000 -0
  65. data/js/lib/gherkin/lexer/i18n/ro.js +1089 -0
  66. data/js/lib/gherkin/lexer/i18n/ru.js +1560 -0
  67. data/js/lib/gherkin/lexer/i18n/sk.js +972 -0
  68. data/js/lib/gherkin/lexer/i18n/sr_cyrl.js +1728 -0
  69. data/js/lib/gherkin/lexer/i18n/sr_latn.js +1220 -0
  70. data/js/lib/gherkin/lexer/i18n/sv.js +997 -0
  71. data/js/lib/gherkin/lexer/i18n/tr.js +1014 -0
  72. data/js/lib/gherkin/lexer/i18n/uk.js +1572 -0
  73. data/js/lib/gherkin/lexer/i18n/uz.js +1302 -0
  74. data/js/lib/gherkin/lexer/i18n/vi.js +1124 -0
  75. data/js/lib/gherkin/lexer/i18n/zh_cn.js +902 -0
  76. data/js/lib/gherkin/lexer/i18n/zh_tw.js +940 -0
  77. data/lib/.gitignore +4 -0
  78. data/lib/gherkin.rb +2 -0
  79. data/lib/gherkin/c_lexer.rb +17 -0
  80. data/lib/gherkin/formatter/ansi_escapes.rb +95 -0
  81. data/lib/gherkin/formatter/argument.rb +16 -0
  82. data/lib/gherkin/formatter/escaping.rb +15 -0
  83. data/lib/gherkin/formatter/filter_formatter.rb +136 -0
  84. data/lib/gherkin/formatter/hashable.rb +19 -0
  85. data/lib/gherkin/formatter/json_formatter.rb +102 -0
  86. data/lib/gherkin/formatter/line_filter.rb +26 -0
  87. data/lib/gherkin/formatter/model.rb +236 -0
  88. data/lib/gherkin/formatter/pretty_formatter.rb +243 -0
  89. data/lib/gherkin/formatter/regexp_filter.rb +21 -0
  90. data/lib/gherkin/formatter/step_printer.rb +17 -0
  91. data/lib/gherkin/formatter/tag_count_formatter.rb +47 -0
  92. data/lib/gherkin/formatter/tag_filter.rb +19 -0
  93. data/lib/gherkin/i18n.rb +175 -0
  94. data/lib/gherkin/i18n.yml +588 -0
  95. data/lib/gherkin/json_parser.rb +137 -0
  96. data/lib/gherkin/lexer/i18n_lexer.rb +47 -0
  97. data/lib/gherkin/listener/event.rb +45 -0
  98. data/lib/gherkin/listener/formatter_listener.rb +113 -0
  99. data/lib/gherkin/native.rb +7 -0
  100. data/lib/gherkin/native/ikvm.rb +55 -0
  101. data/lib/gherkin/native/java.rb +55 -0
  102. data/lib/gherkin/native/null.rb +9 -0
  103. data/lib/gherkin/parser/meta.txt +5 -0
  104. data/lib/gherkin/parser/parser.rb +164 -0
  105. data/lib/gherkin/parser/root.txt +11 -0
  106. data/lib/gherkin/parser/steps.txt +4 -0
  107. data/lib/gherkin/rb_lexer.rb +8 -0
  108. data/lib/gherkin/rb_lexer/.gitignore +1 -0
  109. data/lib/gherkin/rb_lexer/README.rdoc +8 -0
  110. data/lib/gherkin/rubify.rb +24 -0
  111. data/lib/gherkin/tag_expression.rb +62 -0
  112. data/lib/gherkin/version.rb +3 -0
  113. data/ragel/i18n/.gitignore +1 -0
  114. data/ragel/lexer.c.rl.erb +439 -0
  115. data/ragel/lexer.java.rl.erb +208 -0
  116. data/ragel/lexer.rb.rl.erb +167 -0
  117. data/ragel/lexer_common.rl.erb +50 -0
  118. data/spec/gherkin/c_lexer_spec.rb +21 -0
  119. data/spec/gherkin/fixtures/1.feature +8 -0
  120. data/spec/gherkin/fixtures/comments_in_table.feature +9 -0
  121. data/spec/gherkin/fixtures/complex.feature +45 -0
  122. data/spec/gherkin/fixtures/complex.json +143 -0
  123. data/spec/gherkin/fixtures/complex_for_filtering.feature +60 -0
  124. data/spec/gherkin/fixtures/complex_with_tags.feature +61 -0
  125. data/spec/gherkin/fixtures/dos_line_endings.feature +45 -0
  126. data/spec/gherkin/fixtures/hantu_pisang.feature +35 -0
  127. data/spec/gherkin/fixtures/i18n_fr.feature +14 -0
  128. data/spec/gherkin/fixtures/i18n_no.feature +7 -0
  129. data/spec/gherkin/fixtures/i18n_zh-CN.feature +9 -0
  130. data/spec/gherkin/fixtures/scenario_outline_with_tags.feature +13 -0
  131. data/spec/gherkin/fixtures/scenario_without_steps.feature +5 -0
  132. data/spec/gherkin/fixtures/simple_with_comments.feature +7 -0
  133. data/spec/gherkin/fixtures/simple_with_tags.feature +11 -0
  134. data/spec/gherkin/fixtures/with_bom.feature +3 -0
  135. data/spec/gherkin/formatter/ansi_escapes_spec.rb +19 -0
  136. data/spec/gherkin/formatter/filter_formatter_spec.rb +165 -0
  137. data/spec/gherkin/formatter/model_spec.rb +28 -0
  138. data/spec/gherkin/formatter/pretty_formatter_spec.rb +158 -0
  139. data/spec/gherkin/formatter/spaces.feature +9 -0
  140. data/spec/gherkin/formatter/step_printer_spec.rb +55 -0
  141. data/spec/gherkin/formatter/tabs.feature +9 -0
  142. data/spec/gherkin/formatter/tag_count_formatter_spec.rb +30 -0
  143. data/spec/gherkin/i18n_spec.rb +152 -0
  144. data/spec/gherkin/java_lexer_spec.rb +20 -0
  145. data/spec/gherkin/java_libs.rb +20 -0
  146. data/spec/gherkin/json_parser_spec.rb +113 -0
  147. data/spec/gherkin/lexer/i18n_lexer_spec.rb +43 -0
  148. data/spec/gherkin/output_stream_string_io.rb +20 -0
  149. data/spec/gherkin/parser/parser_spec.rb +16 -0
  150. data/spec/gherkin/rb_lexer_spec.rb +19 -0
  151. data/spec/gherkin/sexp_recorder.rb +56 -0
  152. data/spec/gherkin/shared/lexer_group.rb +593 -0
  153. data/spec/gherkin/shared/py_string_group.rb +153 -0
  154. data/spec/gherkin/shared/row_group.rb +125 -0
  155. data/spec/gherkin/shared/tags_group.rb +54 -0
  156. data/spec/gherkin/tag_expression_spec.rb +137 -0
  157. data/spec/spec_helper.rb +69 -0
  158. data/tasks/bench.rake +184 -0
  159. data/tasks/bench/feature_builder.rb +49 -0
  160. data/tasks/bench/generated/.gitignore +1 -0
  161. data/tasks/bench/null_listener.rb +4 -0
  162. data/tasks/compile.rake +102 -0
  163. data/tasks/cucumber.rake +20 -0
  164. data/tasks/gems.rake +35 -0
  165. data/tasks/ikvm.rake +79 -0
  166. data/tasks/ragel_task.rb +70 -0
  167. data/tasks/rdoc.rake +9 -0
  168. data/tasks/release.rake +30 -0
  169. data/tasks/rspec.rake +8 -0
  170. metadata +609 -0
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ unless ENV['RUBY_CC_VERSION']
5
+ Bundler.setup
6
+ Bundler::GemHelper.install_tasks
7
+ end
8
+ ENV['RUBYOPT'] = nil # Necessary to prevent Bundler from *&^%$#ing up rake-compiler.
9
+
10
+ require 'rake/clean'
11
+
12
+ $:.unshift(File.dirname(__FILE__) + '/lib')
13
+ require 'gherkin/version'
14
+
15
+ Dir['tasks/**/*.rake'].each { |rake| load File.expand_path(rake) }
16
+
17
+ task :default => [:spec, :cucumber]
18
+ task :spec => defined?(JRUBY_VERSION) ? :jar : :compile
19
+ task :cucumber => defined?(JRUBY_VERSION) ? :jar : :compile
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.3.5
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+ rm -Rf release
3
+ mkdir release
4
+ GEM_PLATFORM=java gem build gherkin.gemspec
5
+ GEM_PLATFORM=x86-mswin32 gem build gherkin.gemspec
6
+ GEM_PLATFORM=x86-mingw32 gem build gherkin.gemspec
7
+ GEM_PLATFORM=universal-dotnet gem build gherkin.gemspec
8
+ mv *.gem release
data/cucumber.yml ADDED
@@ -0,0 +1,3 @@
1
+ default: --format pretty --tags ~@pending,~@wip --strict --color features
2
+ wip: --format pretty --tags @wip --wip features
3
+ pending: --format pretty --tags @pending,~@native_lexer
@@ -0,0 +1,8 @@
1
+ Feature: Escaped pipes
2
+ Scenario: They are the future
3
+ Given they have arrived
4
+ | æ | o |
5
+ | a | ø |
6
+ Given they have arrived
7
+ | æ | \|o |
8
+ | \|a | ø\\ |
@@ -0,0 +1,237 @@
1
+ # language: en
2
+ Feature: Gherkin Feature lexer
3
+ In order to make it easy to control the Gherkin syntax
4
+ As a Gherkin developer bent on Gherkin world-domination
5
+ I want a feature lexer that uses a feature parser to
6
+ make all the syntax decisions for me
7
+
8
+ Background:
9
+ Given a "ruby" "root" parser
10
+
11
+ Scenario: Correctly formed feature
12
+ Given the following text is parsed:
13
+ """
14
+ # Apologies to Bill Watterson
15
+ @cardboard_box @wip
16
+ Feature: Transmogrification
17
+ As a young boy with a hyperactive imagination
18
+ I want a cardboard box
19
+ In order to transform the ennui of suburban life into something
20
+ befitting my imagination
21
+
22
+ Background:
23
+ Given I have a transmogrifier
24
+ And I am a member of G.R.O.S.S
25
+
26
+ Scenario: Whoozit to whatzit transmogrification
27
+ Given I have a whoozit
28
+ When I put it in the transmogrifier
29
+ And I press the "transmogrify" button
30
+ Then I should have a whatzit
31
+
32
+ Scenario Outline: Imaginary Beings
33
+ Given I have a <boring being>
34
+ When I transmogrify it with the incantation:
35
+ \"\"\"
36
+ ALAKAZAM!
37
+ \"\"\"
38
+ Then I should have an <exciting being>
39
+
40
+ Examples:
41
+ | boring being | exciting being |
42
+ | Sparrow | Alicanto |
43
+ | Goldfish | Baldanders |
44
+ | Cow | Hsiao |
45
+
46
+ Scenario: Sense of humor detection
47
+ Given the following excerpt:
48
+ \"\"\"
49
+ WOMAN: Who are the Britons?
50
+ ARTHUR: Well, we all are. we're all Britons and I am your king.
51
+ WOMAN: I didn't know we had a king. I thought we were an autonomous
52
+ collective.
53
+ DENNIS: You're fooling yourself. We're living in a dictatorship.
54
+ A self-perpetuating autocracy in which the working classes--
55
+ WOMAN: Oh there you go, bringing class into it again.
56
+ DENNIS: That's what it's all about if only people would--
57
+ ARTHUR: Please, please good people. I am in haste. Who lives
58
+ in that castle?
59
+ \"\"\"
60
+ When I read it
61
+ Then I should be amused
62
+ """
63
+ Then there should be no parse errors
64
+
65
+ Scenario: Keyword before feature
66
+ Given the following text is parsed:
67
+ """
68
+ Scenario: Bullying my way to the head of the line
69
+ Given I am a big bully of a scenario
70
+ Then I should be caught by the syntax police(y)
71
+
72
+ Feature: Too timid to stand up for myself
73
+ """
74
+ Then there should be parse errors on lines 1 through 3
75
+
76
+ Scenario: Multiple Features in file
77
+ Given the following text is parsed:
78
+ """
79
+ Feature:
80
+ Scenario: Hi
81
+ Feature: Uh ohs
82
+ Scenario Outline:
83
+ Feature: This is silly
84
+ """
85
+ Then there should be parse errors on lines 3 and 5
86
+
87
+ Scenario: Tag ends background and scenario
88
+ Given the following text is parsed:
89
+ """
90
+ Feature: test feature
91
+ Background:
92
+ Given a something
93
+ @tag
94
+ And something else
95
+
96
+ @foo
97
+ Scenario: my scenario
98
+ @tag
99
+ Given this is a step
100
+ @oh_hai
101
+ And this is a horrible idea
102
+ Then it shouldn't work
103
+ """
104
+ Then there should be parse errors on lines 5, 10 and 12
105
+
106
+ Scenario: Malformed Tables
107
+ Given the following text is parsed:
108
+ """
109
+ Feature: Antiques Roadshow
110
+ Scenario Outline: Table
111
+ Given a <foo>
112
+ Then a <bar>
113
+
114
+ Examples:
115
+ | foo | bar |
116
+ | 42 | towel |
117
+ @hello
118
+ | 1 | prime |
119
+
120
+ Scenario: Table arguments
121
+ Given this step needs this table:
122
+ | foo | bar |
123
+ | one | two |
124
+ @tag
125
+ | aaa | bbb |
126
+ """
127
+ Then there should be parse errors on lines 10 and 17
128
+
129
+ Scenario: Well-formed Tables
130
+ Given the following text is parsed:
131
+ """
132
+ Feature: Row-by-row
133
+
134
+ Scenario: Tables with comments!
135
+ Given I can now comment out a row:
136
+ | Key | Value |
137
+ # | Yes | No |
138
+ # | Good | Bad |
139
+ | Good | Evil |
140
+ Then I am pleased by these things:
141
+ | Raindrops | Roses |
142
+ # | Whiskers | Kittens |
143
+ | Bright Copper | Kettles |
144
+ # | Warm woolen | Mittens |
145
+ | Also Oban | And Hendricks |
146
+ """
147
+ Then there should be no parse errors
148
+
149
+ Scenario: Multiline keyword descriptions
150
+ Given the following text is parsed:
151
+ """
152
+ Feature: Documentation is fun
153
+ Scenario Outline: With lots of docs
154
+ We need lots of embedded documentation for some reason
155
+ \"\"\" # Not interpreted as a pystring, just plain text
156
+ Oh hai
157
+ \"\"\"
158
+
159
+ La la la
160
+
161
+ Examples:
162
+ | one | two |
163
+ | foo | bar |
164
+
165
+ \"\"\"
166
+ Oh Hello
167
+ \"\"\"
168
+
169
+ # Body of the scenario outline starts below
170
+ Given <something>
171
+ And something <else>
172
+
173
+ # The real examples table
174
+ Examples:
175
+ | something | else |
176
+ | orange | apple |
177
+ """
178
+ Then there should be no parse errors
179
+
180
+ Scenario: Scenario Outline with multiple Example groups
181
+ Given the following text is parsed:
182
+ """
183
+ Feature: Outline Sample
184
+
185
+ Scenario: I have no steps
186
+
187
+ Scenario Outline: Test state
188
+ Given <state> without a table
189
+ Given <other_state> without a table
190
+
191
+ Examples: Rainbow colours
192
+ | state | other_state |
193
+ | missing | passing |
194
+ | passing | passing |
195
+ | failing | passing |
196
+
197
+ Examples: Only passing
198
+ | state | other_state |
199
+ | passing | passing |
200
+ """
201
+ Then there should be no parse errors
202
+
203
+ Scenario: Multiple Scenario Outlines with multiline outline steps
204
+ Given the following text is parsed:
205
+ """
206
+ Feature: Test
207
+ Scenario Outline: with step tables
208
+ Given I have the following fruits in my pantry
209
+ | name | quantity |
210
+ | cucumbers | 10 |
211
+ | strawberrys | 5 |
212
+ | apricots | 7 |
213
+
214
+ When I eat <number> <fruits> from the pantry
215
+ Then I should have <left> <fruits> in the pantry
216
+
217
+ Examples:
218
+ | number | fruits | left |
219
+ | 2 | cucumbers | 8 |
220
+ | 4 | strawberrys | 1 |
221
+ | 2 | apricots | 5 |
222
+
223
+ Scenario Outline: placeholder in a multiline string
224
+ Given my shopping list
225
+ \"\"\"
226
+ Must buy some <fruits>
227
+ \"\"\"
228
+ Then my shopping list should equal
229
+ \"\"\"
230
+ Must buy some cucumbers
231
+ \"\"\"
232
+
233
+ Examples:
234
+ | fruits |
235
+ | cucumbers |
236
+ """
237
+ Then there should be no parse errors
@@ -0,0 +1,377 @@
1
+ Feature: JSON formatter
2
+ In order to support greater access to features
3
+ we want JSON
4
+
5
+ Background:
6
+ Given a JSON formatter
7
+ And a "ruby" "root" parser
8
+
9
+ Scenario: Only a Feature
10
+ Given the following text is parsed:
11
+ """
12
+ # language: no
13
+ # Another comment
14
+ Egenskap: Kjapp
15
+ """
16
+ Then the outputted JSON should be:
17
+ """
18
+ {
19
+ "comments": [{"value": "# language: no", "line": 1}, {"value": "# Another comment", "line": 2}],
20
+ "keyword": "Egenskap",
21
+ "name": "Kjapp",
22
+ "description": "",
23
+ "line": 3
24
+ }
25
+ """
26
+
27
+ Scenario: Feature with scenarios and outlines
28
+ Given the following text is parsed:
29
+ """
30
+ @one
31
+ Feature: OH HAI
32
+
33
+ Scenario: Fujin
34
+ Given wind
35
+ Then spirit
36
+
37
+ @two
38
+ Scenario: _why
39
+ Given chunky
40
+ Then bacon
41
+
42
+ @three @four
43
+ Scenario Outline: Life
44
+ Given some <boredom>
45
+
46
+ @five
47
+ Examples: Real life
48
+ |boredom|
49
+ |airport|
50
+ |meeting|
51
+
52
+ Scenario: who stole my mojo?
53
+ When I was
54
+ |asleep|
55
+ And so
56
+ \"\"\"
57
+ innocent
58
+ \"\"\"
59
+
60
+ # The
61
+ Scenario Outline: with
62
+ # all
63
+ Then nice
64
+
65
+ # comments
66
+ # everywhere
67
+ Examples: An example
68
+ # I mean
69
+ | partout |
70
+ """
71
+ Then the outputted JSON should be:
72
+ """
73
+ {
74
+ "tags": [{"name": "@one", "line":1}],
75
+ "keyword": "Feature",
76
+ "name": "OH HAI",
77
+ "description": "",
78
+ "line": 2,
79
+ "elements":[
80
+ {
81
+ "type": "scenario",
82
+ "keyword": "Scenario",
83
+ "name": "Fujin",
84
+ "description": "",
85
+ "line": 4,
86
+ "steps": [
87
+ {
88
+ "keyword": "Given ",
89
+ "name": "wind",
90
+ "line": 5
91
+ },
92
+ {
93
+ "keyword": "Then ",
94
+ "name": "spirit",
95
+ "line": 6
96
+ }
97
+ ]
98
+ },
99
+ {
100
+ "type": "scenario",
101
+ "tags": [{"name": "@two", "line":8}],
102
+ "keyword": "Scenario",
103
+ "name": "_why",
104
+ "description": "",
105
+ "line": 9,
106
+ "steps": [
107
+ {
108
+ "keyword": "Given ",
109
+ "name": "chunky",
110
+ "line": 10
111
+ },
112
+ {
113
+ "keyword": "Then ",
114
+ "name": "bacon",
115
+ "line": 11
116
+ }
117
+ ]
118
+ },
119
+ {
120
+ "type": "scenario_outline",
121
+ "tags": [{"name": "@three", "line":13}, {"name": "@four", "line":13}],
122
+ "keyword": "Scenario Outline",
123
+ "name": "Life",
124
+ "description": "",
125
+ "line": 14,
126
+ "steps": [
127
+ {
128
+ "keyword": "Given ",
129
+ "name": "some <boredom>",
130
+ "line": 15
131
+ }
132
+ ],
133
+ "examples": [
134
+ {
135
+ "tags": [{"name": "@five", "line":17}],
136
+ "keyword": "Examples",
137
+ "name": "Real life",
138
+ "description": "",
139
+ "line": 18,
140
+ "rows": [
141
+ {
142
+ "cells": ["boredom"],
143
+ "line": 19
144
+ },
145
+ {
146
+ "cells": ["airport"],
147
+ "line": 20
148
+ },
149
+ {
150
+ "cells": ["meeting"],
151
+ "line": 21
152
+ }
153
+ ]
154
+ }
155
+ ]
156
+ },
157
+ {
158
+ "type": "scenario",
159
+ "keyword": "Scenario",
160
+ "name": "who stole my mojo?",
161
+ "description": "",
162
+ "line": 23,
163
+ "steps": [
164
+ {
165
+ "keyword": "When ",
166
+ "name": "I was",
167
+ "line": 24,
168
+ "multiline_arg": {
169
+ "type": "table",
170
+ "value": [
171
+ {
172
+ "line": 25,
173
+ "cells": ["asleep"]
174
+ }
175
+ ]
176
+ }
177
+ },
178
+ {
179
+ "keyword": "And ",
180
+ "name": "so",
181
+ "line": 26,
182
+ "multiline_arg": {
183
+ "type": "py_string",
184
+ "value": "innocent",
185
+ "line": 27
186
+ }
187
+ }
188
+ ]
189
+ },
190
+ {
191
+ "type": "scenario_outline",
192
+ "comments": [{"value": "# The", "line":31}],
193
+ "keyword": "Scenario Outline",
194
+ "name": "with",
195
+ "description": "",
196
+ "line": 32,
197
+ "steps": [
198
+ {
199
+ "comments": [{"value": "# all", "line":33}],
200
+ "keyword": "Then ",
201
+ "line": 34,
202
+ "name": "nice"
203
+ }
204
+ ],
205
+ "examples": [
206
+ {
207
+ "comments": [{"value": "# comments", "line": 36}, {"value": "# everywhere", "line": 37}],
208
+ "keyword": "Examples",
209
+ "name": "An example",
210
+ "description": "",
211
+ "line": 38,
212
+ "rows": [
213
+ {
214
+ "comments": [{"value": "# I mean", "line": 39}],
215
+ "line": 40,
216
+ "cells": ["partout"]
217
+ }
218
+ ]
219
+ }
220
+ ]
221
+ }
222
+ ]
223
+ }
224
+ """
225
+
226
+ Scenario: Feature with Background
227
+ Given the following text is parsed:
228
+ """
229
+ Feature: Kjapp
230
+
231
+ Background: No idea what Kjapp means
232
+ Given I Google it
233
+
234
+ # Writing JSON by hand sucks
235
+ Scenario:
236
+ Then I think it means "fast"
237
+ """
238
+ Then the outputted JSON should be:
239
+ """
240
+ {
241
+ "keyword": "Feature",
242
+ "name": "Kjapp",
243
+ "description": "",
244
+ "line": 1,
245
+ "elements": [
246
+ {
247
+ "type": "background",
248
+ "keyword": "Background",
249
+ "line": 3,
250
+ "name": "No idea what Kjapp means",
251
+ "description": "",
252
+ "steps": [
253
+ {
254
+ "keyword": "Given ",
255
+ "line": 4,
256
+ "name": "I Google it"
257
+ }
258
+ ]
259
+ },
260
+ {
261
+ "type": "scenario",
262
+ "comments": [{"value": "# Writing JSON by hand sucks", "line": 6}],
263
+ "keyword": "Scenario",
264
+ "name": "",
265
+ "description": "",
266
+ "line": 7,
267
+ "steps": [
268
+ {
269
+ "keyword": "Then ",
270
+ "name": "I think it means \"fast\"",
271
+ "line": 8
272
+ }
273
+ ]
274
+ }
275
+ ]
276
+ }
277
+ """
278
+
279
+ Scenario: Feature with a description
280
+
281
+ We want people to be able to put markdown formatting into their descriptions
282
+ but this means we need to respect whitespace at the start and end of lines
283
+ in the description.
284
+
285
+ Pay close attention to the whitespace in this example.
286
+
287
+ Given the following text is parsed:
288
+ """
289
+ Feature: Foo
290
+ one line
291
+ another line
292
+
293
+ some pre-formatted stuff
294
+
295
+ Background: name
296
+ test
297
+ test
298
+
299
+ Scenario: name
300
+ test
301
+ test
302
+
303
+ Scenario Outline: name
304
+ test
305
+ test
306
+
307
+ Given <foo>
308
+
309
+ Examples: name
310
+ test
311
+ test
312
+ | foo |
313
+ | table |
314
+ """
315
+ Then the outputted JSON should be:
316
+ """
317
+ {
318
+ "keyword": "Feature",
319
+ "name": "Foo",
320
+ "description": "one line \nanother line \n\n some pre-formatted stuff",
321
+ "line": 1,
322
+ "elements": [
323
+ {
324
+ "description": " test \n test",
325
+ "keyword": "Background",
326
+ "line": 7,
327
+ "name": "name",
328
+ "type": "background"
329
+ },
330
+ {
331
+ "description": " test \n test",
332
+ "keyword": "Scenario",
333
+ "line": 11,
334
+ "name": "name",
335
+ "type": "scenario"
336
+ },
337
+ {
338
+ "description": " test \n test",
339
+ "examples": [
340
+ {
341
+ "description": " test \n test",
342
+ "keyword": "Examples",
343
+ "line": 21,
344
+ "name": "name",
345
+ "rows": [
346
+ {
347
+ "cells": [
348
+ "foo"
349
+ ],
350
+ "line": 24
351
+ },
352
+ {
353
+ "cells": [
354
+ "table"
355
+ ],
356
+ "line": 25
357
+ }
358
+ ]
359
+ }
360
+ ],
361
+ "keyword": "Scenario Outline",
362
+ "line": 15,
363
+ "name": "name",
364
+ "steps": [
365
+ {
366
+ "keyword": "Given ",
367
+ "line": 19,
368
+ "name": "<foo>"
369
+ }
370
+ ],
371
+ "type": "scenario_outline"
372
+ }
373
+ ]
374
+ }
375
+ """
376
+
377
+