cuke_modeler 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +16 -0
- data/Gemfile +11 -3
- data/History.md +5 -0
- data/LICENSE.txt +1 -1
- data/Rakefile +8 -1
- data/appveyor.yml +7 -12
- data/cuke_modeler.gemspec +2 -2
- data/lib/cuke_modeler/adapters/gherkin_6_adapter.rb +309 -0
- data/lib/cuke_modeler/parsing.rb +28 -5
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/cucumber/step_definitions/feature_file_steps.rb +1 -1
- data/testing/cucumber/step_definitions/modeling_steps.rb +2 -2
- data/testing/cucumber/step_definitions/verification_steps.rb +3 -2
- data/testing/file_helper.rb +3 -0
- data/testing/gemfiles/gherkin2.gemfile +7 -0
- data/testing/gemfiles/gherkin3.gemfile +6 -0
- data/testing/gemfiles/gherkin4.gemfile +7 -0
- data/testing/gemfiles/gherkin5.gemfile +6 -0
- data/testing/gemfiles/gherkin6.gemfile +10 -0
- data/testing/rspec/spec/integration/background_integration_spec.rb +80 -72
- data/testing/rspec/spec/integration/cell_integration_spec.rb +28 -20
- data/testing/rspec/spec/integration/comment_integration_spec.rb +11 -3
- data/testing/rspec/spec/integration/directory_integration_spec.rb +2 -2
- data/testing/rspec/spec/integration/doc_string_integration_spec.rb +26 -18
- data/testing/rspec/spec/integration/example_integration_spec.rb +75 -61
- data/testing/rspec/spec/integration/feature_file_integration_spec.rb +30 -20
- data/testing/rspec/spec/integration/feature_integration_spec.rb +106 -98
- data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +11 -11
- data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +11 -11
- data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +12 -12
- data/testing/rspec/spec/integration/gherkin_6_adapter_spec.rb +166 -0
- data/testing/rspec/spec/integration/outline_integration_spec.rb +116 -102
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +16 -4
- data/testing/rspec/spec/integration/row_integration_spec.rb +26 -18
- data/testing/rspec/spec/integration/scenario_integration_spec.rb +82 -74
- data/testing/rspec/spec/integration/step_integration_spec.rb +65 -49
- data/testing/rspec/spec/integration/table_integration_spec.rb +25 -17
- data/testing/rspec/spec/integration/tag_integration_spec.rb +27 -19
- data/testing/rspec/spec/spec_helper.rb +64 -35
- data/todo.txt +3 -1
- metadata +10 -8
- data/testing/cucumber/support/transforms.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 76a8b71aee8bdbf79c8cf429c31fc694edaa85514a5ca5620952b033e8f237cb
|
4
|
+
data.tar.gz: 2a935d1f999d3b0a31a0a72c6b2dd2c4f419a5c79bcbe8bb88e012280bcee06b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9608da985b4103317a66f4490a32925ec48a084cee57ecb273e4536b5d1fb30564edc0355917f30e9c98e1f2da7531f28242874f85207aeb7f25d5a0835406ee
|
7
|
+
data.tar.gz: 769dbd96bb7c6f079166747666e6a5307e69949e5a9bc3af0d562c1ddac44873bda92a935b32bd3dec3f16bf66c6aaab093eace3534bbab7c30ce15caf1d4cc5
|
data/.travis.yml
CHANGED
@@ -15,6 +15,7 @@ gemfile:
|
|
15
15
|
- testing/gemfiles/gherkin3.gemfile
|
16
16
|
- testing/gemfiles/gherkin4.gemfile
|
17
17
|
- testing/gemfiles/gherkin5.gemfile
|
18
|
+
- testing/gemfiles/gherkin6.gemfile
|
18
19
|
|
19
20
|
matrix:
|
20
21
|
exclude:
|
@@ -27,9 +28,24 @@ matrix:
|
|
27
28
|
# gherkin 5.x does not work with Ruby 1.8.x
|
28
29
|
- rvm: 1.8.7
|
29
30
|
gemfile: testing/gemfiles/gherkin5.gemfile
|
31
|
+
# gherkin 6.x does not work with Ruby 1.8.x
|
32
|
+
- rvm: 1.8.7
|
33
|
+
gemfile: testing/gemfiles/gherkin6.gemfile
|
34
|
+
# gherkin 6.x does not work with Ruby 1.9.x
|
35
|
+
- rvm: 1.9.3
|
36
|
+
gemfile: testing/gemfiles/gherkin6.gemfile
|
37
|
+
|
38
|
+
# TODO: turn this back on
|
39
|
+
# gherkin 6.x relies on 'google-protobuf', which does not currently work on JRuby (https://github.com/protocolbuffers/protobuf/issues/1594)
|
40
|
+
- rvm: jruby-9.1.7.0
|
41
|
+
gemfile: testing/gemfiles/gherkin6.gemfile
|
42
|
+
|
30
43
|
# Travis does not provide 1.8.7 on OSX
|
31
44
|
- rvm: 1.8.7
|
32
45
|
os: osx
|
46
|
+
# Travis does not provide 1.9.3 on OSX
|
47
|
+
- rvm: 1.9.3
|
48
|
+
os: osx
|
33
49
|
|
34
50
|
# todo - Remove this once TravisCI fixes their bundler issue (https://github.com/alphagov/govuk_template/pull/186)
|
35
51
|
before_install:
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source '
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in cuke_modeler.gemspec
|
4
4
|
gemspec
|
@@ -7,6 +7,11 @@ gemspec
|
|
7
7
|
|
8
8
|
if RUBY_VERSION =~ /^1\./
|
9
9
|
|
10
|
+
if RbConfig::CONFIG['host_os'].downcase =~ /mswin|msys|mingw32/
|
11
|
+
gem 'ffi', '< 1.9.15' # The 'ffi' gem, for Windows, requires Ruby 2.x on/after this version
|
12
|
+
end
|
13
|
+
|
14
|
+
gem 'unf_ext', '< 0.0.7.3' # Requires Ruby 2.x on/after this version
|
10
15
|
gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
|
11
16
|
gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
|
12
17
|
gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
|
@@ -15,6 +20,9 @@ if RUBY_VERSION =~ /^1\./
|
|
15
20
|
gem 'cucumber', '~> 1.0' # Ruby 1.8.x support dropped after this version
|
16
21
|
gem 'gherkin', '< 2.12.1' # Ruby 1.8.x support dropped after this version
|
17
22
|
gem 'rake', '< 11.0' # Ruby 1.8.x support dropped after this version
|
23
|
+
else
|
24
|
+
gem 'rake', '< 12.3.0' # Ruby 1.9.x support dropped after this version
|
25
|
+
gem 'cucumber', '< 3.0.0' # Ruby 1.9.x support dropped after this version
|
18
26
|
end
|
19
27
|
|
20
28
|
elsif RUBY_VERSION =~ /^2\./
|
@@ -23,6 +31,6 @@ elsif RUBY_VERSION =~ /^2\./
|
|
23
31
|
gem 'test-unit'
|
24
32
|
end
|
25
33
|
|
26
|
-
gem 'gherkin', '~>
|
27
|
-
|
34
|
+
gem 'gherkin', '~> 6.0'
|
35
|
+
gem 'cucumber', '~>4.0.rc'
|
28
36
|
end
|
data/History.md
CHANGED
data/LICENSE.txt
CHANGED
data/Rakefile
CHANGED
@@ -26,7 +26,14 @@ namespace 'cuke_modeler' do
|
|
26
26
|
desc 'Test gem based on Ruby/dependency versions'
|
27
27
|
task :smart_test do |t, args|
|
28
28
|
rspec_args = '--tag ~@wip --pattern testing/rspec/spec/**/*_spec.rb'
|
29
|
-
|
29
|
+
|
30
|
+
cucumber_version = Gem.loaded_specs['cucumber'].version.version
|
31
|
+
|
32
|
+
if cucumber_version =~ /^[123]\./
|
33
|
+
cucumber_args = 'testing/cucumber/features -r testing/cucumber/support -r testing/cucumber/step_definitions -f progress -t ~@wip'
|
34
|
+
else
|
35
|
+
cucumber_args = "testing/cucumber/features -r testing/cucumber/support -r testing/cucumber/step_definitions -f progress -t 'not @wip'"
|
36
|
+
end
|
30
37
|
|
31
38
|
Rake::Task['cuke_modeler:test_everything'].invoke(rspec_args, cucumber_args)
|
32
39
|
end
|
data/appveyor.yml
CHANGED
@@ -2,37 +2,32 @@ version: '1.0.{build}'
|
|
2
2
|
|
3
3
|
environment:
|
4
4
|
matrix:
|
5
|
-
|
6
|
-
BUNDLE_GEMFILE: testing/gemfiles/gherkin2.gemfile
|
7
|
-
# AppVeyor does not have a 64-bit Ruby 1.9.3
|
5
|
+
|
8
6
|
# Gherkin 2.x does not appear to support 32-bit Ruby 2.x and it's not worth it to investigate if this is true or not
|
9
7
|
- RUBY_VERSION: 23-x64
|
10
8
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin2.gemfile
|
11
9
|
|
12
|
-
- RUBY_VERSION: 193
|
13
|
-
BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
|
14
|
-
# AppVeyor does not have a 64-bit Ruby 1.9.3
|
15
10
|
- RUBY_VERSION: 23
|
16
11
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
|
17
12
|
- RUBY_VERSION: 23-x64
|
18
13
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
|
19
14
|
|
20
|
-
- RUBY_VERSION: 193
|
21
|
-
BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
|
22
|
-
# AppVeyor does not have a 64-bit Ruby 1.9.3
|
23
15
|
- RUBY_VERSION: 23
|
24
16
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
|
25
17
|
- RUBY_VERSION: 23-x64
|
26
18
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
|
27
19
|
|
28
|
-
- RUBY_VERSION: 193
|
29
|
-
BUNDLE_GEMFILE: testing/gemfiles/gherkin5.gemfile
|
30
|
-
# AppVeyor does not have a 64-bit Ruby 1.9.3
|
31
20
|
- RUBY_VERSION: 23
|
32
21
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin5.gemfile
|
33
22
|
- RUBY_VERSION: 23-x64
|
34
23
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin5.gemfile
|
35
24
|
|
25
|
+
# Gherkin 6.x requires at least Ruby 2.2
|
26
|
+
- RUBY_VERSION: 23
|
27
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin6.gemfile
|
28
|
+
- RUBY_VERSION: 23-x64
|
29
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin6.gemfile
|
30
|
+
|
36
31
|
install:
|
37
32
|
- set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
|
38
33
|
- bundle install
|
data/cuke_modeler.gemspec
CHANGED
@@ -18,13 +18,13 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'gherkin', '<
|
21
|
+
spec.add_runtime_dependency 'gherkin', '< 7.0'
|
22
22
|
spec.add_runtime_dependency('json', '>= 1.0', '< 3.0')
|
23
23
|
spec.add_runtime_dependency('multi_json', '~> 1.0')
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.5"
|
26
26
|
spec.add_development_dependency "rake", '< 13.0.0'
|
27
|
-
spec.add_development_dependency 'cucumber', '<
|
27
|
+
spec.add_development_dependency 'cucumber', '< 5.0.0'
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
29
|
spec.add_development_dependency 'simplecov', '< 1.0.0'
|
30
30
|
spec.add_development_dependency 'racatt', '~> 1.0'
|
@@ -0,0 +1,309 @@
|
|
1
|
+
module CukeModeler
|
2
|
+
|
3
|
+
# An adapter that can convert the output of version 6.x of the *gherkin* gem into input that is consumable by this gem.
|
4
|
+
|
5
|
+
class Gherkin6Adapter
|
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'][:background][:steps] = nil
|
61
|
+
|
62
|
+
parsed_background['type'] = 'Background'
|
63
|
+
parsed_background['keyword'] = parsed_background[:background].delete(:keyword)
|
64
|
+
parsed_background['name'] = parsed_background[:background].delete(:name)
|
65
|
+
parsed_background['description'] = parsed_background[:background].delete(:description)
|
66
|
+
parsed_background['line'] = parsed_background[:background].delete(:location)[:line]
|
67
|
+
|
68
|
+
parsed_background['steps'] = []
|
69
|
+
parsed_background[:background][:steps].each do |step|
|
70
|
+
adapt_step!(step)
|
71
|
+
end
|
72
|
+
parsed_background['steps'].concat(parsed_background[: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'][:scenario][:tags] = nil
|
79
|
+
parsed_test['cuke_modeler_parsing_data'][:scenario][:steps] = nil
|
80
|
+
|
81
|
+
parsed_test['type'] = 'Scenario'
|
82
|
+
parsed_test['keyword'] = parsed_test[:scenario].delete(:keyword)
|
83
|
+
parsed_test['name'] = parsed_test[:scenario].delete(:name)
|
84
|
+
parsed_test['description'] = parsed_test[:scenario].delete(:description)
|
85
|
+
parsed_test['line'] = parsed_test[:scenario].delete(:location)[:line]
|
86
|
+
|
87
|
+
parsed_test['tags'] = []
|
88
|
+
parsed_test[:scenario][:tags].each do |tag|
|
89
|
+
adapt_tag!(tag)
|
90
|
+
end
|
91
|
+
parsed_test['tags'].concat(parsed_test[:scenario].delete(:tags))
|
92
|
+
|
93
|
+
parsed_test['steps'] = []
|
94
|
+
parsed_test[:scenario][:steps].each do |step|
|
95
|
+
adapt_step!(step)
|
96
|
+
end
|
97
|
+
parsed_test['steps'].concat(parsed_test[:scenario].delete(:steps))
|
98
|
+
end
|
99
|
+
|
100
|
+
# Adapts the AST sub-tree that is rooted at the given outline node.
|
101
|
+
def adapt_outline!(parsed_test)
|
102
|
+
# Removing parsed data for child elements in order to avoid duplicating data
|
103
|
+
parsed_test['cuke_modeler_parsing_data'][:scenario][:tags] = nil
|
104
|
+
parsed_test['cuke_modeler_parsing_data'][:scenario][:steps] = nil
|
105
|
+
parsed_test['cuke_modeler_parsing_data'][:scenario][:examples] = nil
|
106
|
+
|
107
|
+
parsed_test['type'] = 'ScenarioOutline'
|
108
|
+
parsed_test['keyword'] = parsed_test[:scenario].delete(:keyword)
|
109
|
+
parsed_test['name'] = parsed_test[:scenario].delete(:name)
|
110
|
+
parsed_test['description'] = parsed_test[:scenario].delete(:description)
|
111
|
+
parsed_test['line'] = parsed_test[:scenario].delete(:location)[:line]
|
112
|
+
|
113
|
+
parsed_test['tags'] = []
|
114
|
+
parsed_test[:scenario][:tags].each do |tag|
|
115
|
+
adapt_tag!(tag)
|
116
|
+
end
|
117
|
+
parsed_test['tags'].concat(parsed_test[:scenario].delete(:tags))
|
118
|
+
|
119
|
+
parsed_test['steps'] = []
|
120
|
+
parsed_test[:scenario][:steps].each do |step|
|
121
|
+
adapt_step!(step)
|
122
|
+
end
|
123
|
+
parsed_test['steps'].concat(parsed_test[:scenario].delete(:steps))
|
124
|
+
|
125
|
+
parsed_test['examples'] = []
|
126
|
+
parsed_test[:scenario][:examples].each do |step|
|
127
|
+
adapt_example!(step)
|
128
|
+
end
|
129
|
+
parsed_test['examples'].concat(parsed_test[:scenario].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'][:table_header] = nil
|
140
|
+
parsed_example['cuke_modeler_parsing_data'][:table_body] = 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
|
+
|
149
|
+
if parsed_example[:table_header]
|
150
|
+
adapt_table_row!(parsed_example[:table_header])
|
151
|
+
parsed_example['rows'] << parsed_example.delete(:table_header)
|
152
|
+
end
|
153
|
+
|
154
|
+
if parsed_example[:table_body]
|
155
|
+
|
156
|
+
parsed_example[:table_body].each do |row|
|
157
|
+
adapt_table_row!(row)
|
158
|
+
end
|
159
|
+
parsed_example['rows'].concat(parsed_example.delete(:table_body))
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
parsed_example['tags'] = []
|
164
|
+
parsed_example[:tags].each do |tag|
|
165
|
+
adapt_tag!(tag)
|
166
|
+
end
|
167
|
+
parsed_example['tags'].concat(parsed_example.delete(:tags))
|
168
|
+
end
|
169
|
+
|
170
|
+
# Adapts the AST sub-tree that is rooted at the given tag node.
|
171
|
+
def adapt_tag!(parsed_tag)
|
172
|
+
# Saving off the original data
|
173
|
+
parsed_tag['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_tag))
|
174
|
+
|
175
|
+
parsed_tag['name'] = parsed_tag.delete(:name)
|
176
|
+
parsed_tag['line'] = parsed_tag.delete(:location)[:line]
|
177
|
+
end
|
178
|
+
|
179
|
+
# Adapts the AST sub-tree that is rooted at the given comment node.
|
180
|
+
def adapt_comment!(parsed_comment)
|
181
|
+
# Saving off the original data
|
182
|
+
parsed_comment['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_comment))
|
183
|
+
|
184
|
+
parsed_comment['text'] = parsed_comment.delete(:text)
|
185
|
+
parsed_comment['line'] = parsed_comment.delete(:location)[:line]
|
186
|
+
end
|
187
|
+
|
188
|
+
# Adapts the AST sub-tree that is rooted at the given step node.
|
189
|
+
def adapt_step!(parsed_step)
|
190
|
+
# Saving off the original data
|
191
|
+
parsed_step['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step))
|
192
|
+
|
193
|
+
# Removing parsed data for child elements in order to avoid duplicating data
|
194
|
+
parsed_step['cuke_modeler_parsing_data'][:data_table] = nil
|
195
|
+
parsed_step['cuke_modeler_parsing_data'][:doc_string] = nil
|
196
|
+
|
197
|
+
parsed_step['keyword'] = parsed_step.delete(:keyword)
|
198
|
+
parsed_step['name'] = parsed_step.delete(:text)
|
199
|
+
parsed_step['line'] = parsed_step.delete(:location)[:line]
|
200
|
+
|
201
|
+
|
202
|
+
case
|
203
|
+
when parsed_step[:doc_string]
|
204
|
+
adapt_doc_string!(parsed_step[:doc_string])
|
205
|
+
parsed_step['doc_string'] = parsed_step.delete(:doc_string)
|
206
|
+
when parsed_step[:data_table]
|
207
|
+
adapt_step_table!(parsed_step[:data_table])
|
208
|
+
parsed_step['table'] = parsed_step.delete(:data_table)
|
209
|
+
else
|
210
|
+
# Step has no extra argument
|
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(:content_type).strip # TODO: fix bug in Gherkin so that this whitespace is already trimmed off
|
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
|
+
background_child = parsed_children.find { |child| child[:background] }
|
275
|
+
|
276
|
+
if background_child
|
277
|
+
adapt_background!(background_child)
|
278
|
+
|
279
|
+
remaining_children = parsed_children.reject { |child| child[:background] }
|
280
|
+
end
|
281
|
+
|
282
|
+
adapt_tests!(remaining_children || parsed_children)
|
283
|
+
end
|
284
|
+
|
285
|
+
def adapt_tests!(parsed_tests)
|
286
|
+
return unless parsed_tests
|
287
|
+
|
288
|
+
parsed_tests.each do |test|
|
289
|
+
adapt_test!(test)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
def adapt_test!(parsed_test)
|
294
|
+
# Saving off the original data
|
295
|
+
parsed_test['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_test))
|
296
|
+
|
297
|
+
|
298
|
+
case
|
299
|
+
when parsed_test[:scenario] && parsed_test[:scenario][:examples].any?
|
300
|
+
adapt_outline!(parsed_test)
|
301
|
+
when parsed_test[:scenario]
|
302
|
+
adapt_scenario!(parsed_test)
|
303
|
+
else
|
304
|
+
raise(ArgumentError, "Unknown test type with keys: #{parsed_test.keys}")
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
end
|
309
|
+
end
|