cuke_modeler 2.1.0 → 3.0.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 +18 -1
  3. data/README.md +11 -14
  4. data/cuke_modeler.gemspec +12 -9
  5. data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +12 -0
  6. data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +12 -0
  7. data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +12 -0
  8. data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +12 -0
  9. data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +313 -5
  10. data/lib/cuke_modeler/models/background.rb +1 -1
  11. data/lib/cuke_modeler/models/cell.rb +1 -1
  12. data/lib/cuke_modeler/models/comment.rb +1 -1
  13. data/lib/cuke_modeler/models/directory.rb +2 -2
  14. data/lib/cuke_modeler/models/doc_string.rb +1 -1
  15. data/lib/cuke_modeler/models/example.rb +1 -1
  16. data/lib/cuke_modeler/models/feature.rb +1 -1
  17. data/lib/cuke_modeler/models/feature_file.rb +2 -2
  18. data/lib/cuke_modeler/models/outline.rb +1 -1
  19. data/lib/cuke_modeler/models/row.rb +1 -1
  20. data/lib/cuke_modeler/models/scenario.rb +1 -1
  21. data/lib/cuke_modeler/models/step.rb +1 -1
  22. data/lib/cuke_modeler/models/table.rb +1 -1
  23. data/lib/cuke_modeler/models/tag.rb +1 -1
  24. data/lib/cuke_modeler/parsing.rb +29 -58
  25. data/lib/cuke_modeler/version.rb +1 -1
  26. metadata +33 -151
  27. data/.gitignore +0 -18
  28. data/.simplecov +0 -7
  29. data/.travis.yml +0 -81
  30. data/Gemfile +0 -44
  31. data/Rakefile +0 -73
  32. data/appveyor.yml +0 -88
  33. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -274
  34. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -297
  35. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -309
  36. data/lib/cuke_modeler/adapters/gherkin_5_adapter.rb +0 -12
  37. data/lib/cuke_modeler/adapters/gherkin_6_adapter.rb +0 -310
  38. data/lib/cuke_modeler/adapters/gherkin_7_adapter.rb +0 -307
  39. data/lib/cuke_modeler/adapters/gherkin_8_adapter.rb +0 -12
  40. data/testing/cucumber/step_definitions/action_steps.rb +0 -13
  41. data/testing/cucumber/step_definitions/background_steps.rb +0 -1
  42. data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
  43. data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
  44. data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
  45. data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
  46. data/testing/cucumber/step_definitions/modeling_steps.rb +0 -49
  47. data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
  48. data/testing/cucumber/step_definitions/step_steps.rb +0 -3
  49. data/testing/cucumber/step_definitions/table_steps.rb +0 -1
  50. data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
  51. data/testing/cucumber/step_definitions/verification_steps.rb +0 -181
  52. data/testing/cucumber/support/env.rb +0 -30
  53. data/testing/dialect_helper.rb +0 -48
  54. data/testing/file_helper.rb +0 -47
  55. data/testing/gemfiles/gherkin2.gemfile +0 -33
  56. data/testing/gemfiles/gherkin3.gemfile +0 -26
  57. data/testing/gemfiles/gherkin4.gemfile +0 -27
  58. data/testing/gemfiles/gherkin5.gemfile +0 -27
  59. data/testing/gemfiles/gherkin6.gemfile +0 -10
  60. data/testing/gemfiles/gherkin7.gemfile +0 -9
  61. data/testing/gemfiles/gherkin8.gemfile +0 -9
  62. data/testing/gemfiles/gherkin9.gemfile +0 -9
  63. data/testing/helper_methods.rb +0 -23
  64. data/testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb +0 -166
  65. data/testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb +0 -166
  66. data/testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb +0 -165
  67. data/testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb +0 -165
  68. data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +0 -159
  69. data/testing/rspec/spec/integration/adapters/gherkin_7_adapter_spec.rb +0 -162
  70. data/testing/rspec/spec/integration/adapters/gherkin_8_adapter_spec.rb +0 -162
  71. data/testing/rspec/spec/integration/adapters/gherkin_9_adapter_spec.rb +0 -162
  72. data/testing/rspec/spec/integration/models/background_integration_spec.rb +0 -438
  73. data/testing/rspec/spec/integration/models/cell_integration_spec.rb +0 -338
  74. data/testing/rspec/spec/integration/models/comment_integration_spec.rb +0 -180
  75. data/testing/rspec/spec/integration/models/directory_integration_spec.rb +0 -218
  76. data/testing/rspec/spec/integration/models/doc_string_integration_spec.rb +0 -398
  77. data/testing/rspec/spec/integration/models/example_integration_spec.rb +0 -753
  78. data/testing/rspec/spec/integration/models/feature_file_integration_spec.rb +0 -276
  79. data/testing/rspec/spec/integration/models/feature_integration_spec.rb +0 -655
  80. data/testing/rspec/spec/integration/models/model_integration_spec.rb +0 -15
  81. data/testing/rspec/spec/integration/models/outline_integration_spec.rb +0 -619
  82. data/testing/rspec/spec/integration/models/row_integration_spec.rb +0 -303
  83. data/testing/rspec/spec/integration/models/scenario_integration_spec.rb +0 -475
  84. data/testing/rspec/spec/integration/models/step_integration_spec.rb +0 -573
  85. data/testing/rspec/spec/integration/models/table_integration_spec.rb +0 -333
  86. data/testing/rspec/spec/integration/models/tag_integration_spec.rb +0 -271
  87. data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
  88. data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -143
  89. data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
  90. data/testing/rspec/spec/spec_helper.rb +0 -129
  91. data/testing/rspec/spec/unit/cuke_modeler_unit_spec.rb +0 -25
  92. data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
  93. data/testing/rspec/spec/unit/models/background_unit_spec.rb +0 -83
  94. data/testing/rspec/spec/unit/models/cell_unit_spec.rb +0 -68
  95. data/testing/rspec/spec/unit/models/comment_unit_spec.rb +0 -68
  96. data/testing/rspec/spec/unit/models/directory_unit_spec.rb +0 -127
  97. data/testing/rspec/spec/unit/models/doc_string_unit_spec.rb +0 -100
  98. data/testing/rspec/spec/unit/models/example_unit_spec.rb +0 -133
  99. data/testing/rspec/spec/unit/models/feature_file_unit_spec.rb +0 -125
  100. data/testing/rspec/spec/unit/models/feature_unit_spec.rb +0 -157
  101. data/testing/rspec/spec/unit/models/model_unit_spec.rb +0 -15
  102. data/testing/rspec/spec/unit/models/outline_unit_spec.rb +0 -117
  103. data/testing/rspec/spec/unit/models/row_unit_spec.rb +0 -68
  104. data/testing/rspec/spec/unit/models/scenario_unit_spec.rb +0 -86
  105. data/testing/rspec/spec/unit/models/step_unit_spec.rb +0 -109
  106. data/testing/rspec/spec/unit/models/table_unit_spec.rb +0 -77
  107. data/testing/rspec/spec/unit/models/tag_unit_spec.rb +0 -68
  108. data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
  109. data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
  110. data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
  111. data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
  112. data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
  113. data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -127
  114. data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
  115. data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
  116. data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
  117. data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
  118. data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
  119. data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
  120. data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
  121. data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
  122. data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
  123. data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
  124. data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
  125. data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
  126. data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
  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 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e45af46cbcc095433e4bf40fd868daed964bbbc53dac06d3d3de6ca6a4c2db1
4
- data.tar.gz: 36e8660c3f4e993732113f79979168ac59b1bd33c35e8722fc06abdf4e54ce85
3
+ metadata.gz: 12a7bac33e0fe407f250239e15637b732497d9d106893ae9d08943bb2497821c
4
+ data.tar.gz: 26e6cf550dfdec1f87109651d73c01f403a97235277497ea7dc09017448a9a7c
5
5
  SHA512:
6
- metadata.gz: 39109727b23ffbed1015bc7d690367a10c8f8a88e12d099ba973fcd722cfc5fd0f15e9c5dfeef4a61793850b75a46feb9933f1bba66845cb7ccd72c323d26c36
7
- data.tar.gz: 11848c5307c7da2a0669e80dfef83cf535ba1259e3c04d05897b12ab5057760419f239ff7eaaebbc37fec33e7610cc11c771f81128d05f7a779794ad70770978
6
+ metadata.gz: 129e84d0e7d10a7b217c040d7f6cab3590096e76345f679f61a51b3833c0c771fbb2299d997fd319851042d4a40bb2990310112d7fa8836d260ff91107d760cd
7
+ data.tar.gz: 7dd7f4ebd77a9c9b898f4f07fcd33fe1e9216205b9d745ce7da5cff54dc6ba5febe6ed129594287d2c006165ef08a9717c88710b5cae346d15fe98c3e90844fe
@@ -8,6 +8,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
 
9
9
  Nothing yet...
10
10
 
11
+ ## [3.0.0] - 2020-06-08
12
+
13
+ ### Changed
14
+ - This gem now wraps the `cucumber-gherkin` gem instead of the `gherkin` gem, now that `cucumber-gherkin` has superseded `gherkin`.
15
+ - Support for versions of Ruby earlier than 2.3 has been dropped due to that being the minimum required version of Ruby required by the `cucumber-gherkin` gem.
16
+ - When using the parsing functionality provided by this gem, the standardized AST returned when parsing Gherkin text is now returned directly as a Hash instead of also being wrapped in an array. The array was an artifact of basing the AST on the earliest versions of `gherkin` that were supported.
17
+ - No longer including every file in the Git repository as part of the gem. Only the files needed for using the gem (and the informative ones like the README) will be packaged into the released gem.
18
+
19
+ ### Added
20
+ - Support added for more versions of the `cucumber-gherkin` gem
21
+ - 13.x
22
+ - 12.x
23
+ - 11.x
24
+ - 10.x
25
+ - 9.x
26
+
11
27
  ## [2.1.0] - 2020-05-27
12
28
 
13
29
  ### Added
@@ -287,7 +303,8 @@ Nothing yet...
287
303
  - Initial release
288
304
 
289
305
 
290
- [Unreleased]: https://github.com/enkessler/cuke_modeler/compare/v2.1.0...HEAD
306
+ [Unreleased]: https://github.com/enkessler/cuke_modeler/compare/v3.0.0...HEAD
307
+ [3.0.0]: https://github.com/enkessler/cuke_modeler/compare/v2.1.0...v3.0.0
291
308
  [2.1.0]: https://github.com/enkessler/cuke_modeler/compare/v2.0.0...v2.1.0
292
309
  [2.0.0]: https://github.com/enkessler/cuke_modeler/compare/v1.5.1...v2.0.0
293
310
  [1.5.1]: https://github.com/enkessler/cuke_modeler/compare/v1.5.0...v1.5.1
data/README.md CHANGED
@@ -8,11 +8,11 @@ User stuff:
8
8
  [![Yard Docs](http://img.shields.io/badge/Documentation-API-blue.svg)](https://www.rubydoc.info/gems/cuke_modeler)
9
9
 
10
10
  Developer stuff:
11
- [![Build Status](https://travis-ci.org/enkessler/cuke_modeler.svg?branch=dev)](https://travis-ci.org/enkessler/cuke_modeler)
12
- [![Build status](https://ci.appveyor.com/api/projects/status/is8xqvoqn3pjh9l0/branch/dev?svg=true)](https://ci.appveyor.com/project/enkessler/cuke-modeler/branch/dev)
13
- [![Coverage Status](https://coveralls.io/repos/github/enkessler/cuke_modeler/badge.svg?branch=dev)](https://coveralls.io/github/enkessler/cuke_modeler?branch=dev)
11
+ [![Build Status](https://travis-ci.org/enkessler/cuke_modeler.svg)](https://travis-ci.org/enkessler/cuke_modeler)
12
+ [![Build status](https://ci.appveyor.com/api/projects/status/is8xqvoqn3pjh9l0?svg=true)](https://ci.appveyor.com/project/enkessler/cuke-modeler)
13
+ [![Coverage Status](https://coveralls.io/repos/github/enkessler/cuke_modeler/badge.svg)](https://coveralls.io/github/enkessler/cuke_modeler)
14
14
  [![Maintainability](https://api.codeclimate.com/v1/badges/83986d8f7a918fed9707/maintainability)](https://codeclimate.com/github/enkessler/cuke_modeler/maintainability)
15
- [![Inline docs](http://inch-ci.org/github/enkessler/cuke_modeler.svg?branch=dev)](https://inch-ci.org/github/enkessler/cuke_modeler?branch=dev)
15
+ [![Inline docs](http://inch-ci.org/github/enkessler/cuke_modeler.svg)](https://inch-ci.org/github/enkessler/cuke_modeler)
16
16
 
17
17
  ---
18
18
 
@@ -21,7 +21,7 @@ Developer stuff:
21
21
  There comes a time in every programmer's adventures with Cucumber when they
22
22
  want to do Really Cool Stuff with their tests. This usually necessitates
23
23
  scanning all of their feature files and playing with the output. While the
24
- **[gherkin](https://github.com/cucumber/gherkin)** gem does a fine job of parsing feature files, reading or even manipulating
24
+ **[cucumber-gherkin](https://github.com/cucumber/cucumber/tree/master/gherkin)** gem does a fine job of parsing feature files, reading or even manipulating
25
25
  the resulting Abstract Syntax Tree is not always fun. **cuke_modeler** comes to
26
26
  the rescue by providing a modeling layer that is easier to work with.
27
27
 
@@ -126,13 +126,10 @@ that feature is ultimately run with SpecFlow (Cucumber for C#), Lettuce
126
126
  * [cuke_linter](https://github.com/enkessler/cuke_linter)
127
127
 
128
128
 
129
- ## Contributing
129
+ ## Development and Contributing
130
130
 
131
- 1. Fork it
132
- 2. Create your feature branch (**off of the development branch**)
133
- `git checkout -b my-new-feature`
134
- 3. Commit your changes
135
- `git commit -am 'Add some feature'`
136
- 4. Push to the branch
137
- `git push origin my-new-feature`
138
- 5. Create new Pull Request
131
+ See [CONTRIBUTING.md](https://github.com/enkessler/cuke_modeler/blob/master/CONTRIBUTING.md)
132
+
133
+ ## License
134
+
135
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -9,27 +9,30 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Eric Kessler"]
10
10
  spec.email = ["morrow748@gmail.com"]
11
11
  spec.summary = %q{A gem providing functionality to model Gherkin based test suites.}
12
- spec.description = %q{This gem facilitates modeling a test suite that is written in Gherkin (e.g. Cucumber, SpecFlow, Lettuce, etc.). It does this by providing an abstraction layer on top of the Abstract Syntax Tree that the 'gherkin' gem generates when parsing features, as well as providing models for feature files and directories in order to be able to have a fully traversable model tree of a test suite's structure. These models can then be analyzed or manipulated more easily than the underlying AST layer.}
12
+ spec.description = %q{This gem facilitates modeling a test suite that is written in Gherkin (e.g. Cucumber, SpecFlow, Lettuce, etc.). It does this by providing an abstraction layer on top of the Abstract Syntax Tree that the 'cucumber-gherkin' gem generates when parsing features, as well as providing models for feature files and directories in order to be able to have a fully traversable model tree of a test suite's structure. These models can then be analyzed or manipulated more easily than the underlying AST layer.}
13
13
  spec.homepage = 'https://github.com/enkessler/cuke_modeler'
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('', __dir__)) do
19
+ source_controlled_files = `git ls-files -z`.split("\x0")
20
+ source_controlled_files.keep_if { |file| file =~ %r{^(lib|testing/cucumber/features)} }
21
+ source_controlled_files + ['README.md', 'LICENSE.txt', 'CHANGELOG.md', 'cuke_modeler.gemspec']
22
+ end
19
23
  spec.require_paths = ["lib"]
20
24
 
21
- spec.required_ruby_version = '>= 1.8.7', '< 3.0'
25
+ spec.required_ruby_version = '>= 2.3', '< 3.0'
22
26
 
23
- spec.add_runtime_dependency 'gherkin', '< 10.0'
24
- spec.add_runtime_dependency('json', '>= 1.0', '< 3.0')
25
- spec.add_runtime_dependency('multi_json', '~> 1.0')
27
+ spec.add_runtime_dependency 'cucumber-gherkin', '< 14.0'
26
28
 
27
29
  spec.add_development_dependency 'bundler', '< 3.0'
28
30
  spec.add_development_dependency "rake", '< 13.0.0'
29
31
  spec.add_development_dependency 'cucumber', '< 5.0.0'
30
32
  spec.add_development_dependency 'rspec', '~> 3.0'
31
- spec.add_development_dependency 'simplecov', '< 1.0.0'
33
+ spec.add_development_dependency 'simplecov', '<= 0.16.1'
32
34
  spec.add_development_dependency 'racatt', '~> 1.0'
33
35
  spec.add_development_dependency 'coveralls', '< 1.0.0'
34
36
  spec.add_development_dependency 'rainbow', '< 4.0.0'
37
+ spec.add_development_dependency 'test-unit', '< 4.0.0'
35
38
  end
@@ -0,0 +1,12 @@
1
+ require_relative 'gherkin_9_adapter'
2
+
3
+
4
+ module CukeModeler
5
+
6
+ # NOT A PART OF THE PUBLIC API
7
+ # An adapter that can convert the output of version 10.x of the *cucumber-gherkin* gem into input that is consumable by this gem.
8
+
9
+ class Gherkin10Adapter < Gherkin9Adapter
10
+
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require_relative 'gherkin_9_adapter'
2
+
3
+
4
+ module CukeModeler
5
+
6
+ # NOT A PART OF THE PUBLIC API
7
+ # An adapter that can convert the output of version 11.x of the *cucumber-gherkin* gem into input that is consumable by this gem.
8
+
9
+ class Gherkin11Adapter < Gherkin9Adapter
10
+
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require_relative 'gherkin_9_adapter'
2
+
3
+
4
+ module CukeModeler
5
+
6
+ # NOT A PART OF THE PUBLIC API
7
+ # An adapter that can convert the output of version 12.x of the *cucumber-gherkin* gem into input that is consumable by this gem.
8
+
9
+ class Gherkin12Adapter < Gherkin9Adapter
10
+
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require_relative 'gherkin_9_adapter'
2
+
3
+
4
+ module CukeModeler
5
+
6
+ # NOT A PART OF THE PUBLIC API
7
+ # An adapter that can convert the output of version 13.x of the *cucumber-gherkin* gem into input that is consumable by this gem.
8
+
9
+ class Gherkin13Adapter < Gherkin9Adapter
10
+
11
+ end
12
+ end
@@ -1,12 +1,320 @@
1
- require_relative 'gherkin_7_adapter'
2
-
3
1
  module CukeModeler
4
2
 
5
3
  # NOT A PART OF THE PUBLIC API
6
- # An adapter that can convert the output of version 9.x of the *gherkin* gem into input that is consumable by this gem.
4
+ # An adapter that can convert the output of version 9.x of the *cucumber-gherkin* gem into input that is consumable by this gem.
7
5
 
8
- class Gherkin9Adapter < Gherkin7Adapter
6
+ class Gherkin9Adapter
9
7
 
10
- end
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 if parsed_ast['cuke_modeler_parsing_data'][:feature]
15
+ parsed_ast['cuke_modeler_parsing_data'][:comments] = nil if parsed_ast['cuke_modeler_parsing_data'][:comments]
16
+
17
+ parsed_ast['comments'] = []
18
+ if 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
+ end
24
+
25
+ adapt_feature!(parsed_ast[:feature]) if parsed_ast[:feature]
26
+ parsed_ast['feature'] = parsed_ast.delete(:feature)
27
+
28
+ parsed_ast
29
+ end
30
+
31
+ # Adapts the AST sub-tree that is rooted at the given feature node.
32
+ def adapt_feature!(parsed_feature)
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 if parsed_feature['cuke_modeler_parsing_data'][:tags]
38
+ parsed_feature['cuke_modeler_parsing_data'][:children] = nil if parsed_feature['cuke_modeler_parsing_data'][:children]
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
+ if parsed_feature[:children]
47
+ adapt_child_elements!(parsed_feature[:children])
48
+ parsed_feature['elements'].concat(parsed_feature.delete(:children))
49
+ end
50
+
51
+ parsed_feature['tags'] = []
52
+ if parsed_feature[:tags]
53
+ parsed_feature[:tags].each do |tag|
54
+ adapt_tag!(tag)
55
+ end
56
+ parsed_feature['tags'].concat(parsed_feature.delete(:tags))
57
+ end
58
+ end
59
+
60
+ # Adapts the AST sub-tree that is rooted at the given background node.
61
+ def adapt_background!(parsed_background)
62
+ # Saving off the original data
63
+ parsed_background['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_background))
64
+
65
+ # Removing parsed data for child elements in order to avoid duplicating data
66
+ parsed_background['cuke_modeler_parsing_data'][:background][:steps] = nil if parsed_background['cuke_modeler_parsing_data'][:background][:steps]
67
+
68
+ parsed_background['type'] = 'Background'
69
+ parsed_background['keyword'] = parsed_background[:background].delete(:keyword)
70
+ parsed_background['name'] = parsed_background[:background].delete(:name)
71
+ parsed_background['description'] = parsed_background[:background].delete(:description) || ''
72
+ parsed_background['line'] = parsed_background[:background].delete(:location)[:line]
73
+
74
+ parsed_background['steps'] = []
75
+ if parsed_background[:background][:steps]
76
+ parsed_background[:background][:steps].each do |step|
77
+ adapt_step!(step)
78
+ end
79
+ parsed_background['steps'].concat(parsed_background[:background].delete(:steps))
80
+ end
81
+ end
82
+
83
+ # Adapts the AST sub-tree that is rooted at the given scenario node.
84
+ def adapt_scenario!(parsed_test)
85
+ # Removing parsed data for child elements in order to avoid duplicating data
86
+ parsed_test['cuke_modeler_parsing_data'][:scenario][:tags] = nil if parsed_test['cuke_modeler_parsing_data'][:scenario][:tags]
87
+ parsed_test['cuke_modeler_parsing_data'][:scenario][:steps] = nil if parsed_test['cuke_modeler_parsing_data'][:scenario][:steps]
88
+
89
+ parsed_test['type'] = 'Scenario'
90
+ parsed_test['keyword'] = parsed_test[:scenario].delete(:keyword)
91
+ parsed_test['name'] = parsed_test[:scenario].delete(:name)
92
+ parsed_test['description'] = parsed_test[:scenario].delete(:description) || ''
93
+ parsed_test['line'] = parsed_test[:scenario].delete(:location)[:line]
94
+
95
+ parsed_test['tags'] = []
96
+ if parsed_test[:scenario][:tags]
97
+ parsed_test[:scenario][:tags].each do |tag|
98
+ adapt_tag!(tag)
99
+ end
100
+ parsed_test['tags'].concat(parsed_test[:scenario].delete(:tags))
101
+ end
102
+
103
+ parsed_test['steps'] = []
104
+ if parsed_test[:scenario][:steps]
105
+ parsed_test[:scenario][:steps].each do |step|
106
+ adapt_step!(step)
107
+ end
108
+ parsed_test['steps'].concat(parsed_test[:scenario].delete(:steps))
109
+ end
110
+ end
111
+
112
+ # Adapts the AST sub-tree that is rooted at the given outline node.
113
+ def adapt_outline!(parsed_test)
114
+ # Removing parsed data for child elements in order to avoid duplicating data
115
+ parsed_test['cuke_modeler_parsing_data'][:scenario][:tags] = nil if parsed_test['cuke_modeler_parsing_data'][:scenario][:tags]
116
+ parsed_test['cuke_modeler_parsing_data'][:scenario][:steps] = nil if parsed_test['cuke_modeler_parsing_data'][:scenario][:steps]
117
+ parsed_test['cuke_modeler_parsing_data'][:scenario][:examples] = nil if parsed_test['cuke_modeler_parsing_data'][:scenario][:examples]
118
+
119
+ parsed_test['type'] = 'ScenarioOutline'
120
+ parsed_test['keyword'] = parsed_test[:scenario].delete(:keyword)
121
+ parsed_test['name'] = parsed_test[:scenario].delete(:name)
122
+ parsed_test['description'] = parsed_test[:scenario].delete(:description) || ''
123
+ parsed_test['line'] = parsed_test[:scenario].delete(:location)[:line]
124
+
125
+ parsed_test['tags'] = []
126
+ if parsed_test[:scenario][:tags]
127
+ parsed_test[:scenario][:tags].each do |tag|
128
+ adapt_tag!(tag)
129
+ end
130
+ parsed_test['tags'].concat(parsed_test[:scenario].delete(:tags))
131
+ end
132
+
133
+ parsed_test['steps'] = []
134
+ if parsed_test[:scenario][:steps]
135
+ parsed_test[:scenario][:steps].each do |step|
136
+ adapt_step!(step)
137
+ end
138
+ parsed_test['steps'].concat(parsed_test[:scenario].delete(:steps))
139
+ end
140
+
141
+ parsed_test['examples'] = []
142
+ if parsed_test[:scenario][:examples]
143
+ parsed_test[:scenario][:examples].each do |step|
144
+ adapt_example!(step)
145
+ end
146
+ parsed_test['examples'].concat(parsed_test[:scenario].delete(:examples))
147
+ end
148
+ end
149
+
150
+ # Adapts the AST sub-tree that is rooted at the given example node.
151
+ def adapt_example!(parsed_example)
152
+ # Saving off the original data
153
+ parsed_example['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_example))
154
+
155
+ # Removing parsed data for child elements in order to avoid duplicating data
156
+ parsed_example['cuke_modeler_parsing_data'][:tags] = nil if parsed_example['cuke_modeler_parsing_data'][:tags]
157
+ parsed_example['cuke_modeler_parsing_data'][:table_header] = nil if parsed_example['cuke_modeler_parsing_data'][:table_header]
158
+ parsed_example['cuke_modeler_parsing_data'][:table_body] = nil if parsed_example['cuke_modeler_parsing_data'][:table_body]
159
+
160
+ parsed_example['keyword'] = parsed_example.delete(:keyword)
161
+ parsed_example['name'] = parsed_example.delete(:name)
162
+ parsed_example['line'] = parsed_example.delete(:location)[:line]
163
+ parsed_example['description'] = parsed_example.delete(:description) || ''
164
+
165
+ parsed_example['rows'] = []
166
+
167
+ if parsed_example[:table_header]
168
+ adapt_table_row!(parsed_example[:table_header])
169
+ parsed_example['rows'] << parsed_example.delete(:table_header)
170
+ end
171
+
172
+ if parsed_example[:table_body]
173
+ parsed_example[:table_body].each do |row|
174
+ adapt_table_row!(row)
175
+ end
176
+ parsed_example['rows'].concat(parsed_example.delete(:table_body))
177
+ end
178
+
179
+ parsed_example['tags'] = []
180
+ if parsed_example[:tags]
181
+ parsed_example[:tags].each do |tag|
182
+ adapt_tag!(tag)
183
+ end
184
+ parsed_example['tags'].concat(parsed_example.delete(:tags))
185
+ end
186
+ end
11
187
 
188
+ # Adapts the AST sub-tree that is rooted at the given tag node.
189
+ def adapt_tag!(parsed_tag)
190
+ # Saving off the original data
191
+ parsed_tag['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_tag))
192
+
193
+ parsed_tag['name'] = parsed_tag.delete(:name)
194
+ parsed_tag['line'] = parsed_tag.delete(:location)[:line]
195
+ end
196
+
197
+ # Adapts the AST sub-tree that is rooted at the given comment node.
198
+ def adapt_comment!(parsed_comment)
199
+ # Saving off the original data
200
+ parsed_comment['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_comment))
201
+
202
+ parsed_comment['text'] = parsed_comment.delete(:text)
203
+ parsed_comment['line'] = parsed_comment.delete(:location)[:line]
204
+ end
205
+
206
+ # Adapts the AST sub-tree that is rooted at the given step node.
207
+ def adapt_step!(parsed_step)
208
+ # Saving off the original data
209
+ parsed_step['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step))
210
+
211
+ # Removing parsed data for child elements in order to avoid duplicating data
212
+ parsed_step['cuke_modeler_parsing_data'][:data_table] = nil if parsed_step['cuke_modeler_parsing_data'][:data_table]
213
+ parsed_step['cuke_modeler_parsing_data'][:doc_string] = nil if parsed_step['cuke_modeler_parsing_data'][:doc_string]
214
+
215
+ parsed_step['keyword'] = parsed_step.delete(:keyword)
216
+ parsed_step['name'] = parsed_step.delete(:text)
217
+ parsed_step['line'] = parsed_step.delete(:location)[:line]
218
+
219
+ case
220
+ when parsed_step[:doc_string]
221
+ adapt_doc_string!(parsed_step[:doc_string])
222
+ parsed_step['doc_string'] = parsed_step.delete(:doc_string)
223
+ when parsed_step[:data_table]
224
+ adapt_step_table!(parsed_step[:data_table])
225
+ parsed_step['table'] = parsed_step.delete(:data_table)
226
+ else
227
+ # Step has no extra argument
228
+ end
229
+ end
230
+
231
+ # Adapts the AST sub-tree that is rooted at the given doc string node.
232
+ def adapt_doc_string!(parsed_doc_string)
233
+ # Saving off the original data
234
+ parsed_doc_string['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_doc_string))
235
+
236
+ parsed_doc_string['value'] = parsed_doc_string.delete(:content)
237
+ parsed_doc_string['content_type'] = parsed_doc_string.delete(:media_type)
238
+ parsed_doc_string['line'] = parsed_doc_string.delete(:location)[:line]
239
+ end
240
+
241
+ # Adapts the AST sub-tree that is rooted at the given table node.
242
+ def adapt_step_table!(parsed_step_table)
243
+ # Saving off the original data
244
+ parsed_step_table['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step_table))
245
+
246
+ # Removing parsed data for child elements in order to avoid duplicating data
247
+ parsed_step_table['cuke_modeler_parsing_data'][:rows] = nil
248
+
249
+ parsed_step_table['rows'] = []
250
+ parsed_step_table[:rows].each do |row|
251
+ adapt_table_row!(row)
252
+ end
253
+ parsed_step_table['rows'].concat(parsed_step_table.delete(:rows))
254
+ parsed_step_table['line'] = parsed_step_table.delete(:location)[:line]
255
+ end
256
+
257
+ # Adapts the AST sub-tree that is rooted at the given row node.
258
+ def adapt_table_row!(parsed_table_row)
259
+ # Saving off the original data
260
+ parsed_table_row['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_table_row))
261
+
262
+ # Removing parsed data for child elements in order to avoid duplicating data which the child elements will themselves include
263
+ parsed_table_row['cuke_modeler_parsing_data'][:cells] = nil
264
+
265
+ parsed_table_row['line'] = parsed_table_row.delete(:location)[:line]
266
+
267
+ parsed_table_row['cells'] = []
268
+ parsed_table_row[:cells].each do |row|
269
+ adapt_table_cell!(row)
270
+ end
271
+ parsed_table_row['cells'].concat(parsed_table_row.delete(:cells))
272
+ end
273
+
274
+ # Adapts the AST sub-tree that is rooted at the given cell node.
275
+ def adapt_table_cell!(parsed_cell)
276
+ # Saving off the original data
277
+ parsed_cell['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_cell))
278
+
279
+ parsed_cell['value'] = parsed_cell.delete(:value)
280
+ parsed_cell['line'] = parsed_cell.delete(:location)[:line]
281
+ end
282
+
283
+
284
+ private
285
+
286
+
287
+ def adapt_child_elements!(parsed_children)
288
+ background_child = parsed_children.find { |child| child[:background] }
289
+
290
+ if background_child
291
+ adapt_background!(background_child)
292
+
293
+ remaining_children = parsed_children.reject { |child| child[:background] }
294
+ end
295
+
296
+ adapt_tests!(remaining_children || parsed_children)
297
+ end
298
+
299
+ def adapt_tests!(parsed_tests)
300
+ parsed_tests.each do |test|
301
+ adapt_test!(test)
302
+ end
303
+ end
304
+
305
+ def adapt_test!(parsed_test)
306
+ # Saving off the original data
307
+ parsed_test['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_test))
308
+
309
+ case
310
+ when (parsed_test[:scenario] && parsed_test[:scenario][:examples]) || (parsed_test[:scenario] && Parsing.dialects[Parsing.dialect]['scenarioOutline'].include?(parsed_test[:scenario][:keyword]))
311
+ adapt_outline!(parsed_test)
312
+ when parsed_test[:scenario]
313
+ adapt_scenario!(parsed_test)
314
+ else
315
+ raise(ArgumentError, "Unknown test type with keys: #{parsed_test.keys}")
316
+ end
317
+ end
318
+
319
+ end
12
320
  end