cuke_modeler 1.5.0 → 3.1.0

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