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