cuke_modeler 2.0.0 → 2.1.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 +4 -4
- data/.travis.yml +51 -33
- data/CHANGELOG.md +13 -2
- data/Gemfile +9 -2
- data/appveyor.yml +29 -2
- data/cuke_modeler.gemspec +1 -1
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +1 -1
- data/lib/cuke_modeler/adapters/gherkin_5_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_7_adapter.rb +307 -0
- data/lib/cuke_modeler/adapters/gherkin_8_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +12 -0
- data/lib/cuke_modeler/parsing.rb +116 -108
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/gemfiles/gherkin7.gemfile +9 -0
- data/testing/gemfiles/gherkin8.gemfile +9 -0
- data/testing/gemfiles/gherkin9.gemfile +9 -0
- data/testing/helper_methods.rb +23 -0
- data/testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb +1 -1
- data/testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb +1 -1
- data/testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb +1 -1
- data/testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb +165 -0
- data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +1 -8
- data/testing/rspec/spec/integration/adapters/gherkin_7_adapter_spec.rb +162 -0
- data/testing/rspec/spec/integration/adapters/gherkin_8_adapter_spec.rb +162 -0
- data/testing/rspec/spec/integration/adapters/gherkin_9_adapter_spec.rb +162 -0
- data/testing/rspec/spec/integration/models/background_integration_spec.rb +19 -23
- data/testing/rspec/spec/integration/models/cell_integration_spec.rb +27 -24
- data/testing/rspec/spec/integration/models/comment_integration_spec.rb +26 -23
- data/testing/rspec/spec/integration/models/doc_string_integration_spec.rb +19 -23
- data/testing/rspec/spec/integration/models/example_integration_spec.rb +50 -38
- data/testing/rspec/spec/integration/models/feature_file_integration_spec.rb +32 -28
- data/testing/rspec/spec/integration/models/feature_integration_spec.rb +28 -23
- data/testing/rspec/spec/integration/models/outline_integration_spec.rb +39 -44
- data/testing/rspec/spec/integration/models/row_integration_spec.rb +35 -23
- data/testing/rspec/spec/integration/models/scenario_integration_spec.rb +19 -23
- data/testing/rspec/spec/integration/models/step_integration_spec.rb +51 -47
- data/testing/rspec/spec/integration/models/table_integration_spec.rb +19 -23
- data/testing/rspec/spec/integration/models/tag_integration_spec.rb +35 -23
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +27 -6
- data/testing/rspec/spec/spec_helper.rb +39 -46
- metadata +16 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e45af46cbcc095433e4bf40fd868daed964bbbc53dac06d3d3de6ca6a4c2db1
|
4
|
+
data.tar.gz: 36e8660c3f4e993732113f79979168ac59b1bd33c35e8722fc06abdf4e54ce85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39109727b23ffbed1015bc7d690367a10c8f8a88e12d099ba973fcd722cfc5fd0f15e9c5dfeef4a61793850b75a46feb9933f1bba66845cb7ccd72c323d26c36
|
7
|
+
data.tar.gz: 11848c5307c7da2a0669e80dfef83cf535ba1259e3c04d05897b12ab5057760419f239ff7eaaebbc37fec33e7610cc11c771f81128d05f7a779794ad70770978
|
data/.travis.yml
CHANGED
@@ -21,43 +21,61 @@ gemfile:
|
|
21
21
|
- testing/gemfiles/gherkin4.gemfile
|
22
22
|
- testing/gemfiles/gherkin5.gemfile
|
23
23
|
- testing/gemfiles/gherkin6.gemfile
|
24
|
+
- testing/gemfiles/gherkin7.gemfile
|
25
|
+
- testing/gemfiles/gherkin8.gemfile
|
26
|
+
- testing/gemfiles/gherkin9.gemfile
|
24
27
|
|
25
28
|
matrix:
|
26
29
|
exclude:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
30
|
+
|
31
|
+
# gherkin 3.x+ does not work with Ruby 1.8.x
|
32
|
+
- rvm: 1.8.7
|
33
|
+
gemfile: testing/gemfiles/gherkin3.gemfile
|
34
|
+
- rvm: 1.8.7
|
35
|
+
gemfile: testing/gemfiles/gherkin4.gemfile
|
36
|
+
- rvm: 1.8.7
|
37
|
+
gemfile: testing/gemfiles/gherkin5.gemfile
|
38
|
+
- rvm: 1.8.7
|
39
|
+
gemfile: testing/gemfiles/gherkin6.gemfile
|
40
|
+
- rvm: 1.8.7
|
41
|
+
gemfile: testing/gemfiles/gherkin7.gemfile
|
42
|
+
- rvm: 1.8.7
|
43
|
+
gemfile: testing/gemfiles/gherkin8.gemfile
|
44
|
+
- rvm: 1.8.7
|
45
|
+
gemfile: testing/gemfiles/gherkin9.gemfile
|
46
|
+
|
47
|
+
# gherkin 6.x+ does not work with Ruby 1.9.x
|
48
|
+
- rvm: 1.9.3
|
49
|
+
gemfile: testing/gemfiles/gherkin6.gemfile
|
50
|
+
- rvm: 1.9.3
|
51
|
+
gemfile: testing/gemfiles/gherkin7.gemfile
|
52
|
+
- rvm: 1.9.3
|
53
|
+
gemfile: testing/gemfiles/gherkin8.gemfile
|
54
|
+
- rvm: 1.9.3
|
55
|
+
gemfile: testing/gemfiles/gherkin9.gemfile
|
56
|
+
|
57
|
+
# TODO: turn this back on
|
58
|
+
# gherkin 6.x+ relies on 'google-protobuf', which does not currently work on JRuby (https://github.com/protocolbuffers/protobuf/issues/1594)
|
59
|
+
- rvm: jruby-9.1.7.0
|
60
|
+
gemfile: testing/gemfiles/gherkin6.gemfile
|
61
|
+
- rvm: jruby-9.1.7.0
|
62
|
+
gemfile: testing/gemfiles/gherkin7.gemfile
|
63
|
+
- rvm: jruby-9.1.7.0
|
64
|
+
gemfile: testing/gemfiles/gherkin8.gemfile
|
65
|
+
- rvm: jruby-9.1.7.0
|
66
|
+
gemfile: testing/gemfiles/gherkin9.gemfile
|
67
|
+
|
68
|
+
# Travis does not provide 1.8.7 on OSX
|
69
|
+
- rvm: 1.8.7
|
70
|
+
os: osx
|
71
|
+
# Travis does not provide 1.9.3 on OSX
|
72
|
+
- rvm: 1.9.3
|
73
|
+
os: osx
|
74
|
+
# Ruby 2.3.x is currently broken on TravisCI for OSX and is no longer a supported Ruby version, anyway.
|
75
|
+
- rvm: 2.3.8
|
76
|
+
os: osx
|
59
77
|
|
60
78
|
before_install:
|
61
79
|
- gem install bundler -v '< 2'
|
62
|
-
|
80
|
+
|
63
81
|
script: bundle exec rake cuke_modeler:ci_build
|
data/CHANGELOG.md
CHANGED
@@ -8,8 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
8
8
|
|
9
9
|
Nothing yet...
|
10
10
|
|
11
|
+
## [2.1.0] - 2020-05-27
|
11
12
|
|
12
|
-
|
13
|
+
### Added
|
14
|
+
- Support added for more versions of the `gherkin` gem
|
15
|
+
- 9.x
|
16
|
+
- 8.x
|
17
|
+
- 7.x
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
- Parsing errors are now correctly bubbled up when using Gherkin 6.x
|
21
|
+
|
22
|
+
## [2.0.0] - 2020-02-11
|
13
23
|
|
14
24
|
### Changed
|
15
25
|
|
@@ -277,7 +287,8 @@ Nothing yet...
|
|
277
287
|
- Initial release
|
278
288
|
|
279
289
|
|
280
|
-
[Unreleased]: https://github.com/enkessler/cuke_modeler/compare/v2.
|
290
|
+
[Unreleased]: https://github.com/enkessler/cuke_modeler/compare/v2.1.0...HEAD
|
291
|
+
[2.1.0]: https://github.com/enkessler/cuke_modeler/compare/v2.0.0...v2.1.0
|
281
292
|
[2.0.0]: https://github.com/enkessler/cuke_modeler/compare/v1.5.1...v2.0.0
|
282
293
|
[1.5.1]: https://github.com/enkessler/cuke_modeler/compare/v1.5.0...v1.5.1
|
283
294
|
[1.5.0]: https://github.com/enkessler/cuke_modeler/compare/v1.4.0...v1.5.0
|
data/Gemfile
CHANGED
@@ -21,17 +21,24 @@ if RUBY_VERSION =~ /^1\./
|
|
21
21
|
gem 'gherkin', '< 2.12.1' # Ruby 1.8.x support dropped after this version
|
22
22
|
gem 'rainbow', '< 2.0' # Ruby 1.8.x support dropped after this version
|
23
23
|
gem 'rake', '< 11.0' # Ruby 1.8.x support dropped after this version
|
24
|
+
gem 'mime-types', '< 2.0' # Ruby 1.8.x support dropped after this version
|
24
25
|
else
|
25
26
|
gem 'rake', '< 12.3.0' # Ruby 1.9.x support dropped after this version
|
26
27
|
gem 'cucumber', '< 3.0.0' # Ruby 1.9.x support dropped after this version
|
28
|
+
gem 'rainbow', '< 3.0' # Ruby 1.9.x support dropped after this version
|
29
|
+
gem 'mime-types', '< 3.0' # Ruby 1.x support dropped after this version
|
27
30
|
end
|
28
31
|
|
32
|
+
gem 'simplecov', '< 0.18' # Ruby 1.x support dropped after this version
|
33
|
+
gem 'thor', '< 1.0' # Ruby 1.x support dropped after this version
|
29
34
|
elsif RUBY_VERSION =~ /^2\./
|
30
35
|
|
31
36
|
if RUBY_VERSION =~ /^2\.[23456789]/
|
32
37
|
gem 'test-unit'
|
33
38
|
end
|
34
39
|
|
35
|
-
gem 'gherkin', '~> 6.0'
|
36
|
-
gem 'cucumber', '~>4.0.rc'
|
37
40
|
end
|
41
|
+
|
42
|
+
# Note: When testing against 6.x, the latest version (6.0.17) is missing an executable for Windows 64-bit
|
43
|
+
# gem 'gherkin', '>= 6.0', '< 6.0.17'
|
44
|
+
gem 'gherkin', '~> 9.0'
|
data/appveyor.yml
CHANGED
@@ -3,7 +3,7 @@ version: '1.0.{build}'
|
|
3
3
|
environment:
|
4
4
|
matrix:
|
5
5
|
|
6
|
-
|
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
|
7
7
|
- RUBY_VERSION: 24-x64
|
8
8
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin2.gemfile
|
9
9
|
- RUBY_VERSION: 25-x64
|
@@ -36,7 +36,7 @@ environment:
|
|
36
36
|
- RUBY_VERSION: 25-x64
|
37
37
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin5.gemfile
|
38
38
|
|
39
|
-
# Gherkin 6.x requires at least Ruby 2.2
|
39
|
+
# Gherkin 6.x+ requires at least Ruby 2.2
|
40
40
|
- RUBY_VERSION: 24
|
41
41
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin6.gemfile
|
42
42
|
- RUBY_VERSION: 24-x64
|
@@ -46,6 +46,33 @@ environment:
|
|
46
46
|
- RUBY_VERSION: 25-x64
|
47
47
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin6.gemfile
|
48
48
|
|
49
|
+
- RUBY_VERSION: 24
|
50
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin7.gemfile
|
51
|
+
- RUBY_VERSION: 24-x64
|
52
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin7.gemfile
|
53
|
+
- RUBY_VERSION: 25
|
54
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin7.gemfile
|
55
|
+
- RUBY_VERSION: 25-x64
|
56
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin7.gemfile
|
57
|
+
|
58
|
+
- RUBY_VERSION: 24
|
59
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin8.gemfile
|
60
|
+
- RUBY_VERSION: 24-x64
|
61
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin8.gemfile
|
62
|
+
- RUBY_VERSION: 25
|
63
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin8.gemfile
|
64
|
+
- RUBY_VERSION: 25-x64
|
65
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin8.gemfile
|
66
|
+
|
67
|
+
- RUBY_VERSION: 24
|
68
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin9.gemfile
|
69
|
+
- RUBY_VERSION: 24-x64
|
70
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin9.gemfile
|
71
|
+
- RUBY_VERSION: 25
|
72
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin9.gemfile
|
73
|
+
- RUBY_VERSION: 25-x64
|
74
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin9.gemfile
|
75
|
+
|
49
76
|
install:
|
50
77
|
- set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
|
51
78
|
- bundle install
|
data/cuke_modeler.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.required_ruby_version = '>= 1.8.7', '< 3.0'
|
22
22
|
|
23
|
-
spec.add_runtime_dependency 'gherkin', '<
|
23
|
+
spec.add_runtime_dependency 'gherkin', '< 10.0'
|
24
24
|
spec.add_runtime_dependency('json', '>= 1.0', '< 3.0')
|
25
25
|
spec.add_runtime_dependency('multi_json', '~> 1.0')
|
26
26
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module CukeModeler
|
2
2
|
|
3
3
|
# NOT A PART OF THE PUBLIC API
|
4
|
-
# An adapter that can convert the output of version 4.x
|
4
|
+
# An adapter that can convert the output of version 4.x of the *gherkin* gem into input that is consumable by this gem.
|
5
5
|
|
6
6
|
class Gherkin4Adapter
|
7
7
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative 'gherkin_4_adapter'
|
2
|
+
|
3
|
+
module CukeModeler
|
4
|
+
|
5
|
+
# NOT A PART OF THE PUBLIC API
|
6
|
+
# An adapter that can convert the output of version 5.x of the *gherkin* gem into input that is consumable by this gem.
|
7
|
+
|
8
|
+
class Gherkin5Adapter < Gherkin4Adapter
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,307 @@
|
|
1
|
+
module CukeModeler
|
2
|
+
|
3
|
+
# NOT A PART OF THE PUBLIC API
|
4
|
+
# An adapter that can convert the output of version 7.x of the *gherkin* gem into input that is consumable by this gem.
|
5
|
+
|
6
|
+
class Gherkin7Adapter
|
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
|
+
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
|
+
parsed_example[:table_body].each do |row|
|
156
|
+
adapt_table_row!(row)
|
157
|
+
end
|
158
|
+
parsed_example['rows'].concat(parsed_example.delete(:table_body))
|
159
|
+
end
|
160
|
+
|
161
|
+
parsed_example['tags'] = []
|
162
|
+
parsed_example[:tags].each do |tag|
|
163
|
+
adapt_tag!(tag)
|
164
|
+
end
|
165
|
+
parsed_example['tags'].concat(parsed_example.delete(:tags))
|
166
|
+
end
|
167
|
+
|
168
|
+
# Adapts the AST sub-tree that is rooted at the given tag node.
|
169
|
+
def adapt_tag!(parsed_tag)
|
170
|
+
# Saving off the original data
|
171
|
+
parsed_tag['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_tag))
|
172
|
+
|
173
|
+
parsed_tag['name'] = parsed_tag.delete(:name)
|
174
|
+
parsed_tag['line'] = parsed_tag.delete(:location)[:line]
|
175
|
+
end
|
176
|
+
|
177
|
+
# Adapts the AST sub-tree that is rooted at the given comment node.
|
178
|
+
def adapt_comment!(parsed_comment)
|
179
|
+
# Saving off the original data
|
180
|
+
parsed_comment['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_comment))
|
181
|
+
|
182
|
+
parsed_comment['text'] = parsed_comment.delete(:text)
|
183
|
+
parsed_comment['line'] = parsed_comment.delete(:location)[:line]
|
184
|
+
end
|
185
|
+
|
186
|
+
# Adapts the AST sub-tree that is rooted at the given step node.
|
187
|
+
def adapt_step!(parsed_step)
|
188
|
+
# Saving off the original data
|
189
|
+
parsed_step['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step))
|
190
|
+
|
191
|
+
# Removing parsed data for child elements in order to avoid duplicating data
|
192
|
+
parsed_step['cuke_modeler_parsing_data'][:data_table] = nil
|
193
|
+
parsed_step['cuke_modeler_parsing_data'][:doc_string] = nil
|
194
|
+
|
195
|
+
parsed_step['keyword'] = parsed_step.delete(:keyword)
|
196
|
+
parsed_step['name'] = parsed_step.delete(:text)
|
197
|
+
parsed_step['line'] = parsed_step.delete(:location)[:line]
|
198
|
+
|
199
|
+
|
200
|
+
case
|
201
|
+
when parsed_step[:doc_string]
|
202
|
+
adapt_doc_string!(parsed_step[:doc_string])
|
203
|
+
parsed_step['doc_string'] = parsed_step.delete(:doc_string)
|
204
|
+
when parsed_step[:data_table]
|
205
|
+
adapt_step_table!(parsed_step[:data_table])
|
206
|
+
parsed_step['table'] = parsed_step.delete(:data_table)
|
207
|
+
else
|
208
|
+
# Step has no extra argument
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# Adapts the AST sub-tree that is rooted at the given doc string node.
|
213
|
+
def adapt_doc_string!(parsed_doc_string)
|
214
|
+
# Saving off the original data
|
215
|
+
parsed_doc_string['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_doc_string))
|
216
|
+
|
217
|
+
parsed_doc_string['value'] = parsed_doc_string.delete(:content)
|
218
|
+
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
|
219
|
+
parsed_doc_string['line'] = parsed_doc_string.delete(:location)[:line]
|
220
|
+
end
|
221
|
+
|
222
|
+
# Adapts the AST sub-tree that is rooted at the given table node.
|
223
|
+
def adapt_step_table!(parsed_step_table)
|
224
|
+
# Saving off the original data
|
225
|
+
parsed_step_table['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step_table))
|
226
|
+
|
227
|
+
# Removing parsed data for child elements in order to avoid duplicating data
|
228
|
+
parsed_step_table['cuke_modeler_parsing_data'][:rows] = nil
|
229
|
+
|
230
|
+
parsed_step_table['rows'] = []
|
231
|
+
parsed_step_table[:rows].each do |row|
|
232
|
+
adapt_table_row!(row)
|
233
|
+
end
|
234
|
+
parsed_step_table['rows'].concat(parsed_step_table.delete(:rows))
|
235
|
+
parsed_step_table['line'] = parsed_step_table.delete(:location)[:line]
|
236
|
+
end
|
237
|
+
|
238
|
+
# Adapts the AST sub-tree that is rooted at the given row node.
|
239
|
+
def adapt_table_row!(parsed_table_row)
|
240
|
+
# Saving off the original data
|
241
|
+
parsed_table_row['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_table_row))
|
242
|
+
|
243
|
+
# Removing parsed data for child elements in order to avoid duplicating data which the child elements will themselves include
|
244
|
+
parsed_table_row['cuke_modeler_parsing_data'][:cells] = nil
|
245
|
+
|
246
|
+
|
247
|
+
parsed_table_row['line'] = parsed_table_row.delete(:location)[:line]
|
248
|
+
|
249
|
+
parsed_table_row['cells'] = []
|
250
|
+
parsed_table_row[:cells].each do |row|
|
251
|
+
adapt_table_cell!(row)
|
252
|
+
end
|
253
|
+
parsed_table_row['cells'].concat(parsed_table_row.delete(:cells))
|
254
|
+
end
|
255
|
+
|
256
|
+
# Adapts the AST sub-tree that is rooted at the given cell node.
|
257
|
+
def adapt_table_cell!(parsed_cell)
|
258
|
+
# Saving off the original data
|
259
|
+
parsed_cell['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_cell))
|
260
|
+
|
261
|
+
parsed_cell['value'] = parsed_cell.delete(:value)
|
262
|
+
parsed_cell['line'] = parsed_cell.delete(:location)[:line]
|
263
|
+
end
|
264
|
+
|
265
|
+
|
266
|
+
private
|
267
|
+
|
268
|
+
|
269
|
+
def adapt_child_elements!(parsed_children)
|
270
|
+
return if parsed_children.empty?
|
271
|
+
|
272
|
+
background_child = parsed_children.find { |child| child[:background] }
|
273
|
+
|
274
|
+
if background_child
|
275
|
+
adapt_background!(background_child)
|
276
|
+
|
277
|
+
remaining_children = parsed_children.reject { |child| child[:background] }
|
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
|
+
|
296
|
+
case
|
297
|
+
when parsed_test[:scenario] && parsed_test[:scenario][:examples].any?
|
298
|
+
adapt_outline!(parsed_test)
|
299
|
+
when parsed_test[:scenario]
|
300
|
+
adapt_scenario!(parsed_test)
|
301
|
+
else
|
302
|
+
raise(ArgumentError, "Unknown test type with keys: #{parsed_test.keys}")
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
307
|
+
end
|