cuke_modeler 1.4.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +329 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +25 -18
  5. data/cuke_modeler.gemspec +15 -9
  6. data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +12 -0
  7. data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +12 -0
  8. data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +12 -0
  9. data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +12 -0
  10. data/lib/cuke_modeler/adapters/{gherkin_6_adapter.rb → gherkin_9_adapter.rb} +75 -64
  11. data/lib/cuke_modeler/containing.rb +16 -0
  12. data/lib/cuke_modeler/described.rb +1 -0
  13. data/lib/cuke_modeler/models/background.rb +1 -1
  14. data/lib/cuke_modeler/models/cell.rb +1 -1
  15. data/lib/cuke_modeler/models/comment.rb +1 -1
  16. data/lib/cuke_modeler/models/directory.rb +2 -2
  17. data/lib/cuke_modeler/models/doc_string.rb +1 -1
  18. data/lib/cuke_modeler/models/example.rb +1 -1
  19. data/lib/cuke_modeler/models/feature.rb +1 -1
  20. data/lib/cuke_modeler/models/feature_file.rb +2 -2
  21. data/lib/cuke_modeler/models/outline.rb +1 -1
  22. data/lib/cuke_modeler/models/row.rb +1 -1
  23. data/lib/cuke_modeler/models/scenario.rb +1 -1
  24. data/lib/cuke_modeler/models/step.rb +32 -3
  25. data/lib/cuke_modeler/models/table.rb +1 -1
  26. data/lib/cuke_modeler/models/tag.rb +1 -1
  27. data/lib/cuke_modeler/named.rb +1 -0
  28. data/lib/cuke_modeler/nested.rb +1 -0
  29. data/lib/cuke_modeler/parsed.rb +1 -0
  30. data/lib/cuke_modeler/parsing.rb +88 -92
  31. data/lib/cuke_modeler/sourceable.rb +1 -0
  32. data/lib/cuke_modeler/stepped.rb +1 -0
  33. data/lib/cuke_modeler/taggable.rb +1 -0
  34. data/lib/cuke_modeler/version.rb +1 -1
  35. data/testing/cucumber/features/analysis/step_comparison.feature +25 -0
  36. data/testing/cucumber/features/analysis/test_comparison.feature +1 -1
  37. metadata +55 -142
  38. data/.gitignore +0 -18
  39. data/.simplecov +0 -7
  40. data/.travis.yml +0 -54
  41. data/Gemfile +0 -36
  42. data/History.md +0 -191
  43. data/Rakefile +0 -63
  44. data/appveyor.yml +0 -43
  45. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -273
  46. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -296
  47. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -308
  48. data/testing/cucumber/step_definitions/action_steps.rb +0 -13
  49. data/testing/cucumber/step_definitions/background_steps.rb +0 -1
  50. data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
  51. data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
  52. data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
  53. data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
  54. data/testing/cucumber/step_definitions/modeling_steps.rb +0 -44
  55. data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
  56. data/testing/cucumber/step_definitions/step_steps.rb +0 -3
  57. data/testing/cucumber/step_definitions/table_steps.rb +0 -1
  58. data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
  59. data/testing/cucumber/step_definitions/verification_steps.rb +0 -173
  60. data/testing/cucumber/support/env.rb +0 -30
  61. data/testing/dialect_helper.rb +0 -48
  62. data/testing/file_helper.rb +0 -47
  63. data/testing/gemfiles/gherkin2.gemfile +0 -32
  64. data/testing/gemfiles/gherkin3.gemfile +0 -26
  65. data/testing/gemfiles/gherkin4.gemfile +0 -27
  66. data/testing/gemfiles/gherkin5.gemfile +0 -26
  67. data/testing/gemfiles/gherkin6.gemfile +0 -10
  68. data/testing/rspec/spec/integration/background_integration_spec.rb +0 -442
  69. data/testing/rspec/spec/integration/cell_integration_spec.rb +0 -335
  70. data/testing/rspec/spec/integration/comment_integration_spec.rb +0 -177
  71. data/testing/rspec/spec/integration/directory_integration_spec.rb +0 -218
  72. data/testing/rspec/spec/integration/doc_string_integration_spec.rb +0 -402
  73. data/testing/rspec/spec/integration/example_integration_spec.rb +0 -741
  74. data/testing/rspec/spec/integration/feature_file_integration_spec.rb +0 -272
  75. data/testing/rspec/spec/integration/feature_integration_spec.rb +0 -650
  76. data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +0 -166
  77. data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +0 -166
  78. data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +0 -165
  79. data/testing/rspec/spec/integration/gherkin_6_adapter_spec.rb +0 -166
  80. data/testing/rspec/spec/integration/model_integration_spec.rb +0 -15
  81. data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
  82. data/testing/rspec/spec/integration/outline_integration_spec.rb +0 -624
  83. data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -117
  84. data/testing/rspec/spec/integration/row_integration_spec.rb +0 -291
  85. data/testing/rspec/spec/integration/scenario_integration_spec.rb +0 -479
  86. data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
  87. data/testing/rspec/spec/integration/step_integration_spec.rb +0 -475
  88. data/testing/rspec/spec/integration/table_integration_spec.rb +0 -337
  89. data/testing/rspec/spec/integration/tag_integration_spec.rb +0 -259
  90. data/testing/rspec/spec/spec_helper.rb +0 -122
  91. data/testing/rspec/spec/unit/background_unit_spec.rb +0 -83
  92. data/testing/rspec/spec/unit/cell_unit_spec.rb +0 -68
  93. data/testing/rspec/spec/unit/comment_unit_spec.rb +0 -68
  94. data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
  95. data/testing/rspec/spec/unit/directory_unit_spec.rb +0 -127
  96. data/testing/rspec/spec/unit/doc_string_unit_spec.rb +0 -100
  97. data/testing/rspec/spec/unit/example_unit_spec.rb +0 -133
  98. data/testing/rspec/spec/unit/feature_file_unit_spec.rb +0 -125
  99. data/testing/rspec/spec/unit/feature_unit_spec.rb +0 -157
  100. data/testing/rspec/spec/unit/model_unit_spec.rb +0 -15
  101. data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
  102. data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
  103. data/testing/rspec/spec/unit/outline_unit_spec.rb +0 -117
  104. data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
  105. data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
  106. data/testing/rspec/spec/unit/row_unit_spec.rb +0 -68
  107. data/testing/rspec/spec/unit/scenario_unit_spec.rb +0 -86
  108. data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
  109. data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -25
  110. data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
  111. data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
  112. data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
  113. data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
  114. data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
  115. data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
  116. data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
  117. data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
  118. data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
  119. data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
  120. data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
  121. data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
  122. data/testing/rspec/spec/unit/step_unit_spec.rb +0 -109
  123. data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
  124. data/testing/rspec/spec/unit/table_unit_spec.rb +0 -77
  125. data/testing/rspec/spec/unit/tag_unit_spec.rb +0 -68
  126. data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
  127. data/testing/test_languages.json +0 -45
  128. data/todo.txt +0 -24
@@ -1,296 +0,0 @@
1
- module CukeModeler
2
-
3
- # An adapter that can convert the output of version 3.x of the *gherkin* gem into input that is consumable by this gem.
4
-
5
- class Gherkin3Adapter
6
-
7
- # Adapts the given AST into the shape that this gem expects
8
- def adapt(parsed_ast)
9
- parsed_data = {}
10
-
11
- # No data exists stored above feature level
12
- parsed_data['cuke_modeler_parsing_data'] = nil
13
-
14
- # Comments are stored on the feature in gherkin 3.x
15
- parsed_data['comments'] = []
16
- parsed_ast[:comments].each do |comment|
17
- adapt_comment!(comment)
18
- end
19
- parsed_data['comments'].concat(parsed_ast.delete(:comments))
20
-
21
- # An AST is just one feature
22
- adapt_feature!(parsed_ast)
23
-
24
- parsed_data['feature'] = parsed_ast
25
-
26
- [parsed_data]
27
- end
28
-
29
- # Adapts the AST sub-tree that is rooted at the given feature node.
30
- def adapt_feature!(parsed_feature)
31
- # Saving off the original data
32
- parsed_feature['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_feature))
33
-
34
- # Removing parsed data for child elements in order to avoid duplicating data
35
- parsed_feature['cuke_modeler_parsing_data'][:tags] = nil
36
- parsed_feature['cuke_modeler_parsing_data'][:scenarioDefinitions] = nil
37
- parsed_feature['cuke_modeler_parsing_data'][:background] = nil
38
- parsed_feature['cuke_modeler_parsing_data'][:comments] = nil
39
-
40
- parsed_feature['keyword'] = parsed_feature.delete(:keyword)
41
- parsed_feature['name'] = parsed_feature.delete(:name)
42
- parsed_feature['description'] = parsed_feature.delete(:description) || ''
43
- parsed_feature['line'] = parsed_feature.delete(:location)[:line]
44
-
45
- parsed_feature['elements'] = []
46
- adapt_child_elements!(parsed_feature)
47
- parsed_feature['elements'].concat(parsed_feature.delete(:scenarioDefinitions))
48
- parsed_feature['elements'] << parsed_feature.delete(:background) if parsed_feature[:background]
49
-
50
- parsed_feature['tags'] = []
51
- parsed_feature[:tags].each do |tag|
52
- adapt_tag!(tag)
53
- end
54
- parsed_feature['tags'].concat(parsed_feature.delete(:tags))
55
- end
56
-
57
- # Adapts the AST sub-tree that is rooted at the given background node.
58
- def adapt_background!(parsed_background)
59
- # Saving off the original data
60
- parsed_background['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_background))
61
-
62
- # Removing parsed data for child elements in order to avoid duplicating data
63
- parsed_background['cuke_modeler_parsing_data'][:steps] = nil
64
-
65
- parsed_background['type'] = parsed_background.delete(:type).to_s
66
- parsed_background['keyword'] = parsed_background.delete(:keyword).to_s
67
- parsed_background['name'] = parsed_background.delete(:name)
68
- parsed_background['description'] = parsed_background.delete(:description) || ''
69
- parsed_background['line'] = parsed_background.delete(:location)[:line]
70
-
71
- parsed_background['steps'] = []
72
- parsed_background[:steps].each do |step|
73
- adapt_step!(step)
74
- end
75
- parsed_background['steps'].concat(parsed_background.delete(:steps))
76
- end
77
-
78
- # Adapts the AST sub-tree that is rooted at the given scenario node.
79
- def adapt_scenario!(parsed_test)
80
- # Removing parsed data for child elements in order to avoid duplicating data
81
- parsed_test['cuke_modeler_parsing_data'][:tags] = nil
82
- parsed_test['cuke_modeler_parsing_data'][:steps] = nil
83
-
84
-
85
- parsed_test['name'] = parsed_test.delete(:name)
86
- parsed_test['description'] = parsed_test.delete(:description) || ''
87
- parsed_test['line'] = parsed_test.delete(:location)[:line]
88
-
89
- parsed_test['tags'] = []
90
- parsed_test[:tags].each do |tag|
91
- adapt_tag!(tag)
92
- end
93
- parsed_test['tags'].concat(parsed_test.delete(:tags))
94
-
95
- parsed_test['steps'] = []
96
- parsed_test[:steps].each do |step|
97
- adapt_step!(step)
98
- end
99
- parsed_test['steps'].concat(parsed_test.delete(:steps))
100
- end
101
-
102
- # Adapts the AST sub-tree that is rooted at the given outline node.
103
- def adapt_outline!(parsed_test)
104
- # Removing parsed data for child elements in order to avoid duplicating data
105
- parsed_test['cuke_modeler_parsing_data'][:tags] = nil
106
- parsed_test['cuke_modeler_parsing_data'][:steps] = nil
107
- parsed_test['cuke_modeler_parsing_data'][:examples] = nil
108
-
109
- parsed_test['name'] = parsed_test.delete(:name)
110
- parsed_test['description'] = parsed_test.delete(:description) || ''
111
- parsed_test['line'] = parsed_test.delete(:location)[:line]
112
-
113
- parsed_test['tags'] = []
114
- parsed_test[:tags].each do |tag|
115
- adapt_tag!(tag)
116
- end
117
- parsed_test['tags'].concat(parsed_test.delete(:tags))
118
-
119
- parsed_test['steps'] = []
120
- parsed_test[:steps].each do |step|
121
- adapt_step!(step)
122
- end
123
- parsed_test['steps'].concat(parsed_test.delete(:steps))
124
-
125
- parsed_test['examples'] = []
126
- parsed_test[:examples].each do |step|
127
- adapt_example!(step)
128
- end
129
- parsed_test['examples'].concat(parsed_test.delete(:examples))
130
- end
131
-
132
- # Adapts the AST sub-tree that is rooted at the given example node.
133
- def adapt_example!(parsed_example)
134
- # Saving off the original data
135
- parsed_example['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_example))
136
-
137
- # Removing parsed data for child elements in order to avoid duplicating data
138
- parsed_example['cuke_modeler_parsing_data'][:tags] = nil
139
- parsed_example['cuke_modeler_parsing_data'][:tableHeader] = nil
140
- parsed_example['cuke_modeler_parsing_data'][:tableBody] = nil
141
-
142
- parsed_example['keyword'] = parsed_example.delete(:keyword)
143
- parsed_example['name'] = parsed_example.delete(:name)
144
- parsed_example['line'] = parsed_example.delete(:location)[:line]
145
- parsed_example['description'] = parsed_example.delete(:description) || ''
146
-
147
- parsed_example['rows'] = []
148
- adapt_table_row!(parsed_example[:tableHeader])
149
- parsed_example['rows'] << parsed_example.delete(:tableHeader)
150
-
151
- parsed_example[:tableBody].each do |row|
152
- adapt_table_row!(row)
153
- end
154
- parsed_example['rows'].concat(parsed_example.delete(:tableBody))
155
-
156
- parsed_example['tags'] = []
157
- parsed_example[:tags].each do |tag|
158
- adapt_tag!(tag)
159
- end
160
- parsed_example['tags'].concat(parsed_example.delete(:tags))
161
- end
162
-
163
- # Adapts the AST sub-tree that is rooted at the given tag node.
164
- def adapt_tag!(parsed_tag)
165
- # Saving off the original data
166
- parsed_tag['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_tag))
167
-
168
- parsed_tag['name'] = parsed_tag.delete(:name)
169
- parsed_tag['line'] = parsed_tag.delete(:location)[:line]
170
- end
171
-
172
- # Adapts the AST sub-tree that is rooted at the given comment node.
173
- def adapt_comment!(parsed_comment)
174
- # Saving off the original data
175
- parsed_comment['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_comment))
176
-
177
- parsed_comment['text'] = parsed_comment.delete(:text)
178
- parsed_comment['line'] = parsed_comment.delete(:location)[:line]
179
- end
180
-
181
- # Adapts the AST sub-tree that is rooted at the given step node.
182
- def adapt_step!(parsed_step)
183
- # Saving off the original data
184
- parsed_step['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step))
185
-
186
- # Removing parsed data for child elements in order to avoid duplicating data
187
- parsed_step['cuke_modeler_parsing_data'][:argument] = nil
188
-
189
- parsed_step['keyword'] = parsed_step.delete(:keyword)
190
- parsed_step['name'] = parsed_step.delete(:text)
191
- parsed_step['line'] = parsed_step.delete(:location)[:line]
192
-
193
-
194
- step_argument = parsed_step[:argument]
195
-
196
- if step_argument
197
- case step_argument[:type]
198
- when :DocString
199
- adapt_doc_string!(step_argument)
200
- parsed_step['doc_string'] = parsed_step.delete(:argument)
201
- when :DataTable
202
- adapt_step_table!(step_argument)
203
- parsed_step['table'] = parsed_step.delete(:argument)
204
- else
205
- raise(ArgumentError, "Unknown step argument type: #{step_argument[:type]}")
206
- end
207
- end
208
- end
209
-
210
- # Adapts the AST sub-tree that is rooted at the given doc string node.
211
- def adapt_doc_string!(parsed_doc_string)
212
- # Saving off the original data
213
- parsed_doc_string['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_doc_string))
214
-
215
- parsed_doc_string['value'] = parsed_doc_string.delete(:content)
216
- parsed_doc_string['content_type'] = parsed_doc_string.delete(:contentType)
217
- parsed_doc_string['line'] = parsed_doc_string.delete(:location)[:line]
218
- end
219
-
220
- # Adapts the AST sub-tree that is rooted at the given table node.
221
- def adapt_step_table!(parsed_step_table)
222
- # Saving off the original data
223
- parsed_step_table['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step_table))
224
-
225
- # Removing parsed data for child elements in order to avoid duplicating data
226
- parsed_step_table['cuke_modeler_parsing_data'][:rows] = nil
227
-
228
- parsed_step_table['rows'] = []
229
- parsed_step_table[:rows].each do |row|
230
- adapt_table_row!(row)
231
- end
232
- parsed_step_table['rows'].concat(parsed_step_table.delete(:rows))
233
- parsed_step_table['line'] = parsed_step_table.delete(:location)[:line]
234
- end
235
-
236
- # Adapts the AST sub-tree that is rooted at the given row node.
237
- def adapt_table_row!(parsed_table_row)
238
- # Saving off the original data
239
- parsed_table_row['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_table_row))
240
-
241
- # Removing parsed data for child elements in order to avoid duplicating data which the child elements will themselves include
242
- parsed_table_row['cuke_modeler_parsing_data'][:cells] = nil
243
-
244
-
245
- parsed_table_row['line'] = parsed_table_row.delete(:location)[:line]
246
-
247
- parsed_table_row['cells'] = []
248
- parsed_table_row[:cells].each do |row|
249
- adapt_table_cell!(row)
250
- end
251
- parsed_table_row['cells'].concat(parsed_table_row.delete(:cells))
252
- end
253
-
254
- # Adapts the AST sub-tree that is rooted at the given cell node.
255
- def adapt_table_cell!(parsed_cell)
256
- # Saving off the original data
257
- parsed_cell['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_cell))
258
-
259
- parsed_cell['value'] = parsed_cell.delete(:value)
260
- parsed_cell['line'] = parsed_cell.delete(:location)[:line]
261
- end
262
-
263
-
264
- private
265
-
266
-
267
- def adapt_child_elements!(parsed_feature)
268
- adapt_background!(parsed_feature[:background]) if parsed_feature[:background]
269
- adapt_tests!(parsed_feature)
270
- end
271
-
272
- def adapt_tests!(parsed_feature)
273
- parsed_feature[:scenarioDefinitions].each do |test|
274
- adapt_test!(test)
275
- end
276
- end
277
-
278
- def adapt_test!(parsed_test)
279
- # Saving off the original data
280
- parsed_test['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_test))
281
-
282
- parsed_test['keyword'] = parsed_test.delete(:keyword)
283
- parsed_test['type'] = parsed_test.delete(:type).to_s
284
-
285
- case parsed_test['type']
286
- when 'Scenario'
287
- adapt_scenario!(parsed_test)
288
- when 'ScenarioOutline'
289
- adapt_outline!(parsed_test)
290
- else
291
- raise(ArgumentError, "Unknown test type: #{parsed_test['type']}")
292
- end
293
- end
294
-
295
- end
296
- end
@@ -1,308 +0,0 @@
1
- module CukeModeler
2
-
3
- # An adapter that can convert the output of version 4.x and 5.x of the *gherkin* gem into input that is consumable by this gem.
4
-
5
- class Gherkin4Adapter
6
-
7
- # Adapts the given AST into the shape that this gem expects
8
- def adapt(parsed_ast)
9
- # Saving off the original data
10
- parsed_ast['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_ast))
11
-
12
- # Removing parsed data for child elements in order to avoid duplicating data
13
- parsed_ast['cuke_modeler_parsing_data'][:feature] = nil
14
- parsed_ast['cuke_modeler_parsing_data'][:comments] = nil
15
-
16
- # Comments are stored on the feature file in gherkin 4.x
17
- parsed_ast['comments'] = []
18
- parsed_ast[:comments].each do |comment|
19
- adapt_comment!(comment)
20
- end
21
- parsed_ast['comments'].concat(parsed_ast.delete(:comments))
22
-
23
- adapt_feature!(parsed_ast[:feature]) if parsed_ast[:feature]
24
- parsed_ast['feature'] = parsed_ast.delete(:feature)
25
-
26
- [parsed_ast]
27
- end
28
-
29
- # Adapts the AST sub-tree that is rooted at the given feature node.
30
- def adapt_feature!(parsed_feature)
31
- # Saving off the original data
32
- parsed_feature['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_feature))
33
-
34
- # Removing parsed data for child elements in order to avoid duplicating data
35
- parsed_feature['cuke_modeler_parsing_data'][:tags] = nil
36
- parsed_feature['cuke_modeler_parsing_data'][:children] = nil
37
-
38
- parsed_feature['keyword'] = parsed_feature.delete(:keyword)
39
- parsed_feature['name'] = parsed_feature.delete(:name)
40
- parsed_feature['description'] = parsed_feature.delete(:description) || ''
41
- parsed_feature['line'] = parsed_feature.delete(:location)[:line]
42
-
43
- parsed_feature['elements'] = []
44
- adapt_child_elements!(parsed_feature[:children])
45
- parsed_feature['elements'].concat(parsed_feature.delete(:children))
46
-
47
- parsed_feature['tags'] = []
48
- parsed_feature[:tags].each do |tag|
49
- adapt_tag!(tag)
50
- end
51
- parsed_feature['tags'].concat(parsed_feature.delete(:tags))
52
- end
53
-
54
- # Adapts the AST sub-tree that is rooted at the given background node.
55
- def adapt_background!(parsed_background)
56
- # Saving off the original data
57
- parsed_background['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_background))
58
-
59
- # Removing parsed data for child elements in order to avoid duplicating data
60
- parsed_background['cuke_modeler_parsing_data'][:steps] = nil
61
-
62
- parsed_background['type'] = parsed_background.delete(:type).to_s
63
- parsed_background['keyword'] = parsed_background.delete(:keyword).to_s
64
- parsed_background['name'] = parsed_background.delete(:name)
65
- parsed_background['description'] = parsed_background.delete(:description) || ''
66
- parsed_background['line'] = parsed_background.delete(:location)[:line]
67
-
68
- parsed_background['steps'] = []
69
- parsed_background[:steps].each do |step|
70
- adapt_step!(step)
71
- end
72
- parsed_background['steps'].concat(parsed_background.delete(:steps))
73
- end
74
-
75
- # Adapts the AST sub-tree that is rooted at the given scenario node.
76
- def adapt_scenario!(parsed_test)
77
- # Removing parsed data for child elements in order to avoid duplicating data
78
- parsed_test['cuke_modeler_parsing_data'][:tags] = nil
79
- parsed_test['cuke_modeler_parsing_data'][:steps] = nil
80
-
81
- parsed_test['name'] = parsed_test.delete(:name)
82
- parsed_test['description'] = parsed_test.delete(:description) || ''
83
- parsed_test['line'] = parsed_test.delete(:location)[:line]
84
-
85
- parsed_test['tags'] = []
86
- parsed_test[:tags].each do |tag|
87
- adapt_tag!(tag)
88
- end
89
- parsed_test['tags'].concat(parsed_test.delete(:tags))
90
-
91
- parsed_test['steps'] = []
92
- parsed_test[:steps].each do |step|
93
- adapt_step!(step)
94
- end
95
- parsed_test['steps'].concat(parsed_test.delete(:steps))
96
- end
97
-
98
- # Adapts the AST sub-tree that is rooted at the given outline node.
99
- def adapt_outline!(parsed_test)
100
- # Removing parsed data for child elements in order to avoid duplicating data
101
- parsed_test['cuke_modeler_parsing_data'][:tags] = nil
102
- parsed_test['cuke_modeler_parsing_data'][:steps] = nil
103
- parsed_test['cuke_modeler_parsing_data'][:examples] = nil
104
-
105
- parsed_test['name'] = parsed_test.delete(:name)
106
- parsed_test['description'] = parsed_test.delete(:description) || ''
107
- parsed_test['line'] = parsed_test.delete(:location)[:line]
108
-
109
- parsed_test['tags'] = []
110
- parsed_test[:tags].each do |tag|
111
- adapt_tag!(tag)
112
- end
113
- parsed_test['tags'].concat(parsed_test.delete(:tags))
114
-
115
- parsed_test['steps'] = []
116
- parsed_test[:steps].each do |step|
117
- adapt_step!(step)
118
- end
119
- parsed_test['steps'].concat(parsed_test.delete(:steps))
120
-
121
- parsed_test['examples'] = []
122
- parsed_test[:examples].each do |step|
123
- adapt_example!(step)
124
- end
125
- parsed_test['examples'].concat(parsed_test.delete(:examples))
126
- end
127
-
128
- # Adapts the AST sub-tree that is rooted at the given example node.
129
- def adapt_example!(parsed_example)
130
- # Saving off the original data
131
- parsed_example['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_example))
132
-
133
- # Removing parsed data for child elements in order to avoid duplicating data
134
- parsed_example['cuke_modeler_parsing_data'][:tags] = nil
135
- parsed_example['cuke_modeler_parsing_data'][:tableHeader] = nil
136
- parsed_example['cuke_modeler_parsing_data'][:tableBody] = nil
137
-
138
- parsed_example['keyword'] = parsed_example.delete(:keyword)
139
- parsed_example['name'] = parsed_example.delete(:name)
140
- parsed_example['line'] = parsed_example.delete(:location)[:line]
141
- parsed_example['description'] = parsed_example.delete(:description) || ''
142
-
143
- parsed_example['rows'] = []
144
-
145
- if parsed_example[:tableHeader]
146
- adapt_table_row!(parsed_example[:tableHeader])
147
- parsed_example['rows'] << parsed_example.delete(:tableHeader)
148
- end
149
-
150
- if parsed_example[:tableBody]
151
-
152
- parsed_example[:tableBody].each do |row|
153
- adapt_table_row!(row)
154
- end
155
- parsed_example['rows'].concat(parsed_example.delete(:tableBody))
156
- end
157
-
158
-
159
- parsed_example['tags'] = []
160
- parsed_example[:tags].each do |tag|
161
- adapt_tag!(tag)
162
- end
163
- parsed_example['tags'].concat(parsed_example.delete(:tags))
164
- end
165
-
166
- # Adapts the AST sub-tree that is rooted at the given tag node.
167
- def adapt_tag!(parsed_tag)
168
- # Saving off the original data
169
- parsed_tag['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_tag))
170
-
171
- parsed_tag['name'] = parsed_tag.delete(:name)
172
- parsed_tag['line'] = parsed_tag.delete(:location)[:line]
173
- end
174
-
175
- # Adapts the AST sub-tree that is rooted at the given comment node.
176
- def adapt_comment!(parsed_comment)
177
- # Saving off the original data
178
- parsed_comment['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_comment))
179
-
180
- parsed_comment['text'] = parsed_comment.delete(:text)
181
- parsed_comment['line'] = parsed_comment.delete(:location)[:line]
182
- end
183
-
184
- # Adapts the AST sub-tree that is rooted at the given step node.
185
- def adapt_step!(parsed_step)
186
- # Saving off the original data
187
- parsed_step['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step))
188
-
189
- # Removing parsed data for child elements in order to avoid duplicating data
190
- parsed_step['cuke_modeler_parsing_data'][:argument] = nil
191
-
192
- parsed_step['keyword'] = parsed_step.delete(:keyword)
193
- parsed_step['name'] = parsed_step.delete(:text)
194
- parsed_step['line'] = parsed_step.delete(:location)[:line]
195
-
196
-
197
- step_argument = parsed_step[:argument]
198
-
199
- if step_argument
200
- case step_argument[:type]
201
- when :DocString
202
- adapt_doc_string!(step_argument)
203
- parsed_step['doc_string'] = parsed_step.delete(:argument)
204
- when :DataTable
205
- adapt_step_table!(step_argument)
206
- parsed_step['table'] = parsed_step.delete(:argument)
207
- else
208
- raise(ArgumentError, "Unknown step argument type: #{step_argument[:type]}")
209
- end
210
- end
211
- end
212
-
213
- # Adapts the AST sub-tree that is rooted at the given doc string node.
214
- def adapt_doc_string!(parsed_doc_string)
215
- # Saving off the original data
216
- parsed_doc_string['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_doc_string))
217
-
218
- parsed_doc_string['value'] = parsed_doc_string.delete(:content)
219
- parsed_doc_string['content_type'] = parsed_doc_string.delete(:contentType)
220
- parsed_doc_string['line'] = parsed_doc_string.delete(:location)[:line]
221
- end
222
-
223
- # Adapts the AST sub-tree that is rooted at the given table node.
224
- def adapt_step_table!(parsed_step_table)
225
- # Saving off the original data
226
- parsed_step_table['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step_table))
227
-
228
- # Removing parsed data for child elements in order to avoid duplicating data
229
- parsed_step_table['cuke_modeler_parsing_data'][:rows] = nil
230
-
231
- parsed_step_table['rows'] = []
232
- parsed_step_table[:rows].each do |row|
233
- adapt_table_row!(row)
234
- end
235
- parsed_step_table['rows'].concat(parsed_step_table.delete(:rows))
236
- parsed_step_table['line'] = parsed_step_table.delete(:location)[:line]
237
- end
238
-
239
- # Adapts the AST sub-tree that is rooted at the given row node.
240
- def adapt_table_row!(parsed_table_row)
241
- # Saving off the original data
242
- parsed_table_row['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_table_row))
243
-
244
- # Removing parsed data for child elements in order to avoid duplicating data which the child elements will themselves include
245
- parsed_table_row['cuke_modeler_parsing_data'][:cells] = nil
246
-
247
-
248
- parsed_table_row['line'] = parsed_table_row.delete(:location)[:line]
249
-
250
- parsed_table_row['cells'] = []
251
- parsed_table_row[:cells].each do |row|
252
- adapt_table_cell!(row)
253
- end
254
- parsed_table_row['cells'].concat(parsed_table_row.delete(:cells))
255
- end
256
-
257
- # Adapts the AST sub-tree that is rooted at the given cell node.
258
- def adapt_table_cell!(parsed_cell)
259
- # Saving off the original data
260
- parsed_cell['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_cell))
261
-
262
- parsed_cell['value'] = parsed_cell.delete(:value)
263
- parsed_cell['line'] = parsed_cell.delete(:location)[:line]
264
- end
265
-
266
-
267
- private
268
-
269
-
270
- def adapt_child_elements!(parsed_children)
271
- return if parsed_children.empty?
272
-
273
- if parsed_children.first[:type] == :Background
274
- adapt_background!(parsed_children.first)
275
-
276
- remaining_children = parsed_children[1..-1]
277
- end
278
-
279
- adapt_tests!(remaining_children || parsed_children)
280
- end
281
-
282
- def adapt_tests!(parsed_tests)
283
- return unless parsed_tests
284
-
285
- parsed_tests.each do |test|
286
- adapt_test!(test)
287
- end
288
- end
289
-
290
- def adapt_test!(parsed_test)
291
- # Saving off the original data
292
- parsed_test['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_test))
293
-
294
- parsed_test['keyword'] = parsed_test.delete(:keyword)
295
- parsed_test['type'] = parsed_test.delete(:type).to_s
296
-
297
- case parsed_test['type']
298
- when 'Scenario'
299
- adapt_scenario!(parsed_test)
300
- when 'ScenarioOutline'
301
- adapt_outline!(parsed_test)
302
- else
303
- raise(ArgumentError, "Unknown test type: #{parsed_test['type']}")
304
- end
305
- end
306
-
307
- end
308
- end