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.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -2
  3. data/README.md +14 -16
  4. data/cuke_modeler.gemspec +12 -9
  5. data/lib/cuke_modeler.rb +1 -0
  6. data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +12 -0
  7. data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +12 -0
  8. data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +12 -0
  9. data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +12 -0
  10. data/lib/cuke_modeler/adapters/gherkin_14_adapter.rb +12 -0
  11. data/lib/cuke_modeler/adapters/gherkin_15_adapter.rb +12 -0
  12. data/lib/cuke_modeler/adapters/{gherkin_6_adapter.rb → gherkin_9_adapter.rb} +104 -69
  13. data/lib/cuke_modeler/containing.rb +15 -5
  14. data/lib/cuke_modeler/models/background.rb +1 -1
  15. data/lib/cuke_modeler/models/cell.rb +1 -1
  16. data/lib/cuke_modeler/models/comment.rb +1 -1
  17. data/lib/cuke_modeler/models/directory.rb +2 -2
  18. data/lib/cuke_modeler/models/doc_string.rb +1 -1
  19. data/lib/cuke_modeler/models/example.rb +1 -1
  20. data/lib/cuke_modeler/models/feature.rb +16 -5
  21. data/lib/cuke_modeler/models/feature_file.rb +2 -2
  22. data/lib/cuke_modeler/models/outline.rb +1 -1
  23. data/lib/cuke_modeler/models/row.rb +1 -1
  24. data/lib/cuke_modeler/models/rule.rb +99 -0
  25. data/lib/cuke_modeler/models/scenario.rb +1 -1
  26. data/lib/cuke_modeler/models/step.rb +1 -1
  27. data/lib/cuke_modeler/models/table.rb +1 -1
  28. data/lib/cuke_modeler/models/tag.rb +1 -1
  29. data/lib/cuke_modeler/parsing.rb +89 -110
  30. data/lib/cuke_modeler/version.rb +1 -1
  31. data/testing/cucumber/features/modeling/feature_modeling.feature +28 -7
  32. data/testing/cucumber/features/modeling/feature_output.feature +45 -23
  33. data/testing/cucumber/features/modeling/rule_modeling.feature +108 -0
  34. data/testing/cucumber/features/modeling/rule_output.feature +111 -0
  35. metadata +39 -140
  36. data/.gitignore +0 -18
  37. data/.simplecov +0 -7
  38. data/.travis.yml +0 -63
  39. data/Gemfile +0 -37
  40. data/Rakefile +0 -73
  41. data/appveyor.yml +0 -61
  42. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -274
  43. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -297
  44. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -309
  45. data/testing/cucumber/step_definitions/action_steps.rb +0 -13
  46. data/testing/cucumber/step_definitions/background_steps.rb +0 -1
  47. data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
  48. data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
  49. data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
  50. data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
  51. data/testing/cucumber/step_definitions/modeling_steps.rb +0 -49
  52. data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
  53. data/testing/cucumber/step_definitions/step_steps.rb +0 -3
  54. data/testing/cucumber/step_definitions/table_steps.rb +0 -1
  55. data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
  56. data/testing/cucumber/step_definitions/verification_steps.rb +0 -181
  57. data/testing/cucumber/support/env.rb +0 -30
  58. data/testing/dialect_helper.rb +0 -48
  59. data/testing/file_helper.rb +0 -47
  60. data/testing/gemfiles/gherkin2.gemfile +0 -33
  61. data/testing/gemfiles/gherkin3.gemfile +0 -26
  62. data/testing/gemfiles/gherkin4.gemfile +0 -27
  63. data/testing/gemfiles/gherkin5.gemfile +0 -27
  64. data/testing/gemfiles/gherkin6.gemfile +0 -10
  65. data/testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb +0 -166
  66. data/testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb +0 -166
  67. data/testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb +0 -165
  68. data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +0 -166
  69. data/testing/rspec/spec/integration/models/background_integration_spec.rb +0 -442
  70. data/testing/rspec/spec/integration/models/cell_integration_spec.rb +0 -335
  71. data/testing/rspec/spec/integration/models/comment_integration_spec.rb +0 -177
  72. data/testing/rspec/spec/integration/models/directory_integration_spec.rb +0 -218
  73. data/testing/rspec/spec/integration/models/doc_string_integration_spec.rb +0 -402
  74. data/testing/rspec/spec/integration/models/example_integration_spec.rb +0 -741
  75. data/testing/rspec/spec/integration/models/feature_file_integration_spec.rb +0 -272
  76. data/testing/rspec/spec/integration/models/feature_integration_spec.rb +0 -650
  77. data/testing/rspec/spec/integration/models/model_integration_spec.rb +0 -15
  78. data/testing/rspec/spec/integration/models/outline_integration_spec.rb +0 -624
  79. data/testing/rspec/spec/integration/models/row_integration_spec.rb +0 -291
  80. data/testing/rspec/spec/integration/models/scenario_integration_spec.rb +0 -479
  81. data/testing/rspec/spec/integration/models/step_integration_spec.rb +0 -569
  82. data/testing/rspec/spec/integration/models/table_integration_spec.rb +0 -337
  83. data/testing/rspec/spec/integration/models/tag_integration_spec.rb +0 -259
  84. data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
  85. data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -122
  86. data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
  87. data/testing/rspec/spec/spec_helper.rb +0 -136
  88. data/testing/rspec/spec/unit/cuke_modeler_unit_spec.rb +0 -25
  89. data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
  90. data/testing/rspec/spec/unit/models/background_unit_spec.rb +0 -83
  91. data/testing/rspec/spec/unit/models/cell_unit_spec.rb +0 -68
  92. data/testing/rspec/spec/unit/models/comment_unit_spec.rb +0 -68
  93. data/testing/rspec/spec/unit/models/directory_unit_spec.rb +0 -127
  94. data/testing/rspec/spec/unit/models/doc_string_unit_spec.rb +0 -100
  95. data/testing/rspec/spec/unit/models/example_unit_spec.rb +0 -133
  96. data/testing/rspec/spec/unit/models/feature_file_unit_spec.rb +0 -125
  97. data/testing/rspec/spec/unit/models/feature_unit_spec.rb +0 -157
  98. data/testing/rspec/spec/unit/models/model_unit_spec.rb +0 -15
  99. data/testing/rspec/spec/unit/models/outline_unit_spec.rb +0 -117
  100. data/testing/rspec/spec/unit/models/row_unit_spec.rb +0 -68
  101. data/testing/rspec/spec/unit/models/scenario_unit_spec.rb +0 -86
  102. data/testing/rspec/spec/unit/models/step_unit_spec.rb +0 -109
  103. data/testing/rspec/spec/unit/models/table_unit_spec.rb +0 -77
  104. data/testing/rspec/spec/unit/models/tag_unit_spec.rb +0 -68
  105. data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
  106. data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
  107. data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
  108. data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
  109. data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
  110. data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -127
  111. data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
  112. data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
  113. data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
  114. data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
  115. data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
  116. data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
  117. data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
  118. data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
  119. data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
  120. data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
  121. data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
  122. data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
  123. data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
  124. data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
  125. data/testing/test_languages.json +0 -45
  126. data/todo.txt +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92ec631920bf8e2af7095588f0f85bf6f43e109737d39b7b2b92a5e71b00bd82
4
- data.tar.gz: c8d6abcdf38a6d71a9281c841a60feb0cf839bfa4c13430009ab56458b7d7ac2
3
+ metadata.gz: 3c0d1e0901ca4b0af16683c5f92dac6ee799058c6adadf58a9323e4c59e70813
4
+ data.tar.gz: 8303d94eb1f5d0acc163a08435f9dda0bcda9b07a23375985aedde9fc3fd3138
5
5
  SHA512:
6
- metadata.gz: a96083807968d997553eb00ab15f1432e89d96527a0d8a814902c1410a87ea11232ff9de904a063782f5efad3aa6a35c6d9ddbd169e3e2bf248cd11c0ccd6710
7
- data.tar.gz: 111e2d71eb17c5ac1cd4378bc92672eb76ac412dc6943fc29430eeb6aeacda2955f77171347e633e8fa71fef1a803913affb7a0994bb4e6fee6084e75bbdb760
6
+ metadata.gz: 7948e5a8cf13728afeb2820ff66baefb31d878c96fc41145effc109d1d6fd6adc8e4c288928273e0b04bdd909c85b120e777c11594ce5fd7720e801d5aaae530
7
+ data.tar.gz: bd9cd348ed6f090f0231de118e5fe9d28ca9da014e0b2c1481deef4d604adbf1050d6350abf708555a6bd2651099d05f8134f1b074a5b02e1ae97fa38ccf872b
@@ -8,8 +8,60 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
 
9
9
  Nothing yet...
10
10
 
11
+ ## [3.3.0] - 2020-08-15
11
12
 
12
- ## [2.0.0] - 2019-02-11
13
+ ### Added
14
+ - Support added for more versions of the `cucumber-gherkin` gem
15
+ - 15.x
16
+
17
+ ## [3.2.0] - 2020-07-27
18
+
19
+ ### Added
20
+ - The `Rule` keyword is now a modeled element.
21
+
22
+ ### Deprecated
23
+ - `Feature#test_case_count` will be removed on the next major release. It's a random analysis method in what is
24
+ otherwise a purely abstraction layer library. The [CQL](https://github.com/enkessler/cql) gem is better suited to such tasks.
25
+
26
+ ## [3.1.0] - 2020-06-28
27
+
28
+ ### Added
29
+ - Support added for more versions of the `cucumber-gherkin` gem
30
+ - 14.x
31
+
32
+ ### Fixed
33
+ - Text is converted to UTF-8 encoding before being passed to the underlying Gherkin gem. This is due to UTF-8 being
34
+ the only encoding supported by Gherkin. The `gherkin` gem did the conversion automatically and so this conversion
35
+ was not necessary previously but the `cucumber-gherkin` gem does not do any automatic conversion.
36
+
37
+ ## [3.0.0] - 2020-06-08
38
+
39
+ ### Changed
40
+ - This gem now wraps the `cucumber-gherkin` gem instead of the `gherkin` gem, now that `cucumber-gherkin` has superseded `gherkin`.
41
+ - 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.
42
+ - 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.
43
+ - 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.
44
+
45
+ ### Added
46
+ - Support added for more versions of the `cucumber-gherkin` gem
47
+ - 13.x
48
+ - 12.x
49
+ - 11.x
50
+ - 10.x
51
+ - 9.x
52
+
53
+ ## [2.1.0] - 2020-05-27
54
+
55
+ ### Added
56
+ - Support added for more versions of the `gherkin` gem
57
+ - 9.x
58
+ - 8.x
59
+ - 7.x
60
+
61
+ ### Fixed
62
+ - Parsing errors are now correctly bubbled up when using Gherkin 6.x
63
+
64
+ ## [2.0.0] - 2020-02-11
13
65
 
14
66
  ### Changed
15
67
 
@@ -277,7 +329,12 @@ Nothing yet...
277
329
  - Initial release
278
330
 
279
331
 
280
- [Unreleased]: https://github.com/enkessler/cuke_modeler/compare/v2.0.0...HEAD
332
+ [Unreleased]: https://github.com/enkessler/cuke_modeler/compare/v3.3.0...HEAD
333
+ [3.3.0]: https://github.com/enkessler/cuke_modeler/compare/v3.2.0...v3.3.0
334
+ [3.2.0]: https://github.com/enkessler/cuke_modeler/compare/v3.1.0...v3.2.0
335
+ [3.1.0]: https://github.com/enkessler/cuke_modeler/compare/v3.0.0...v3.1.0
336
+ [3.0.0]: https://github.com/enkessler/cuke_modeler/compare/v2.1.0...v3.0.0
337
+ [2.1.0]: https://github.com/enkessler/cuke_modeler/compare/v2.0.0...v2.1.0
281
338
  [2.0.0]: https://github.com/enkessler/cuke_modeler/compare/v1.5.1...v2.0.0
282
339
  [1.5.1]: https://github.com/enkessler/cuke_modeler/compare/v1.5.0...v1.5.1
283
340
  [1.5.0]: https://github.com/enkessler/cuke_modeler/compare/v1.4.0...v1.5.0
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
 
@@ -82,13 +82,14 @@ and setting their attributes afterward.
82
82
  One could, if so inclined, use this method to dynamically edit or even create
83
83
  an entire test suite!
84
84
 
85
- For more information on the different models and how to use them, see the
85
+ For more information on the different models (which more or less have the same relation
86
+ to each other as described in the AST [here](https://github.com/cucumber/cucumber/tree/master/gherkin#ast)) and how to use them, see the
86
87
  [documentation](https://app.cucumber.pro/projects/cuke_modeler).
87
88
 
88
89
  ## Modeling dialects other than English
89
90
 
90
91
  The modeling functionality provided by this gem will work with any dialect that
91
- is supported by the **gherkin** gem. For modeling at the feature level or higher,
92
+ is supported by the **cucumber-gherkin** gem. For modeling at the feature level or higher,
92
93
  no additional effort is needed because the `# language` header at the top of a
93
94
  feature already indicates that a non-default dialect is being used.
94
95
 
@@ -126,13 +127,10 @@ that feature is ultimately run with SpecFlow (Cucumber for C#), Lettuce
126
127
  * [cuke_linter](https://github.com/enkessler/cuke_linter)
127
128
 
128
129
 
129
- ## Contributing
130
+ ## Development and Contributing
130
131
 
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
132
+ See [CONTRIBUTING.md](https://github.com/enkessler/cuke_modeler/blob/master/CONTRIBUTING.md)
133
+
134
+ ## License
135
+
136
+ 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', '< 7.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', '< 16.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
@@ -19,6 +19,7 @@ require 'cuke_modeler/models/model'
19
19
  require 'cuke_modeler/models/feature_file'
20
20
  require 'cuke_modeler/models/directory'
21
21
  require 'cuke_modeler/models/feature'
22
+ require 'cuke_modeler/models/rule'
22
23
  require 'cuke_modeler/models/background'
23
24
  require 'cuke_modeler/models/scenario'
24
25
  require 'cuke_modeler/models/outline'
@@ -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
@@ -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 14.x of the *cucumber-gherkin* gem into input that is consumable by this gem.
8
+
9
+ class Gherkin14Adapter < 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 15.x of the *cucumber-gherkin* gem into input that is consumable by this gem.
8
+
9
+ class Gherkin15Adapter < Gherkin9Adapter
10
+
11
+ end
12
+ end
@@ -1,9 +1,9 @@
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 6.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.
5
5
 
6
- class Gherkin6Adapter
6
+ class Gherkin9Adapter
7
7
 
8
8
  # Adapts the given AST into the shape that this gem expects
9
9
  def adapt(parsed_ast)
@@ -11,20 +11,21 @@ module CukeModeler
11
11
  parsed_ast['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_ast))
12
12
 
13
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
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
16
 
17
- # Comments are stored on the feature file in gherkin 4.x
18
17
  parsed_ast['comments'] = []
19
- parsed_ast[:comments].each do |comment|
20
- adapt_comment!(comment)
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))
21
23
  end
22
- parsed_ast['comments'].concat(parsed_ast.delete(:comments))
23
24
 
24
25
  adapt_feature!(parsed_ast[:feature]) if parsed_ast[:feature]
25
26
  parsed_ast['feature'] = parsed_ast.delete(:feature)
26
27
 
27
- [parsed_ast]
28
+ parsed_ast
28
29
  end
29
30
 
30
31
  # Adapts the AST sub-tree that is rooted at the given feature node.
@@ -33,23 +34,27 @@ module CukeModeler
33
34
  parsed_feature['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_feature))
34
35
 
35
36
  # 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
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]
38
39
 
39
40
  parsed_feature['keyword'] = parsed_feature.delete(:keyword)
40
41
  parsed_feature['name'] = parsed_feature.delete(:name)
41
- parsed_feature['description'] = parsed_feature.delete(:description)
42
+ parsed_feature['description'] = parsed_feature.delete(:description) || ''
42
43
  parsed_feature['line'] = parsed_feature.delete(:location)[:line]
43
44
 
44
45
  parsed_feature['elements'] = []
45
- adapt_child_elements!(parsed_feature[:children])
46
- parsed_feature['elements'].concat(parsed_feature.delete(:children))
46
+ if parsed_feature[:children]
47
+ adapt_child_elements!(parsed_feature[:children])
48
+ parsed_feature['elements'].concat(parsed_feature.delete(:children))
49
+ end
47
50
 
48
51
  parsed_feature['tags'] = []
49
- parsed_feature[:tags].each do |tag|
50
- adapt_tag!(tag)
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))
51
57
  end
52
- parsed_feature['tags'].concat(parsed_feature.delete(:tags))
53
58
  end
54
59
 
55
60
  # Adapts the AST sub-tree that is rooted at the given background node.
@@ -58,76 +63,109 @@ module CukeModeler
58
63
  parsed_background['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_background))
59
64
 
60
65
  # Removing parsed data for child elements in order to avoid duplicating data
61
- parsed_background['cuke_modeler_parsing_data'][:background][:steps] = nil
66
+ parsed_background['cuke_modeler_parsing_data'][:background][:steps] = nil if parsed_background['cuke_modeler_parsing_data'][:background][:steps]
62
67
 
63
68
  parsed_background['type'] = 'Background'
64
69
  parsed_background['keyword'] = parsed_background[:background].delete(:keyword)
65
70
  parsed_background['name'] = parsed_background[:background].delete(:name)
66
- parsed_background['description'] = parsed_background[:background].delete(:description)
71
+ parsed_background['description'] = parsed_background[:background].delete(:description) || ''
67
72
  parsed_background['line'] = parsed_background[:background].delete(:location)[:line]
68
73
 
69
74
  parsed_background['steps'] = []
70
- parsed_background[:background][:steps].each do |step|
71
- adapt_step!(step)
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 rule node.
84
+ def adapt_rule!(parsed_rule)
85
+ # Saving off the original data
86
+ parsed_rule['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_rule))
87
+
88
+ # Removing parsed data for child elements in order to avoid duplicating data
89
+ parsed_rule['cuke_modeler_parsing_data'][:rule][:children] = nil if parsed_rule['cuke_modeler_parsing_data'][:rule][:children]
90
+
91
+ parsed_rule['type'] = 'Rule'
92
+ parsed_rule['keyword'] = parsed_rule[:rule].delete(:keyword)
93
+ parsed_rule['name'] = parsed_rule[:rule].delete(:name)
94
+ parsed_rule['description'] = parsed_rule[:rule].delete(:description) || ''
95
+ parsed_rule['line'] = parsed_rule[:rule].delete(:location)[:line]
96
+
97
+ parsed_rule['elements'] = []
98
+ if parsed_rule[:rule][:children]
99
+ adapt_child_elements!(parsed_rule[:rule][:children])
100
+ parsed_rule['elements'].concat(parsed_rule[:rule].delete(:children))
72
101
  end
73
- parsed_background['steps'].concat(parsed_background[:background].delete(:steps))
74
102
  end
75
103
 
76
104
  # Adapts the AST sub-tree that is rooted at the given scenario node.
77
105
  def adapt_scenario!(parsed_test)
78
106
  # Removing parsed data for child elements in order to avoid duplicating data
79
- parsed_test['cuke_modeler_parsing_data'][:scenario][:tags] = nil
80
- parsed_test['cuke_modeler_parsing_data'][:scenario][:steps] = nil
107
+ parsed_test['cuke_modeler_parsing_data'][:scenario][:tags] = nil if parsed_test['cuke_modeler_parsing_data'][:scenario][:tags]
108
+ parsed_test['cuke_modeler_parsing_data'][:scenario][:steps] = nil if parsed_test['cuke_modeler_parsing_data'][:scenario][:steps]
81
109
 
82
110
  parsed_test['type'] = 'Scenario'
83
111
  parsed_test['keyword'] = parsed_test[:scenario].delete(:keyword)
84
112
  parsed_test['name'] = parsed_test[:scenario].delete(:name)
85
- parsed_test['description'] = parsed_test[:scenario].delete(:description)
113
+ parsed_test['description'] = parsed_test[:scenario].delete(:description) || ''
86
114
  parsed_test['line'] = parsed_test[:scenario].delete(:location)[:line]
87
115
 
88
116
  parsed_test['tags'] = []
89
- parsed_test[:scenario][:tags].each do |tag|
90
- adapt_tag!(tag)
117
+ if parsed_test[:scenario][:tags]
118
+ parsed_test[:scenario][:tags].each do |tag|
119
+ adapt_tag!(tag)
120
+ end
121
+ parsed_test['tags'].concat(parsed_test[:scenario].delete(:tags))
91
122
  end
92
- parsed_test['tags'].concat(parsed_test[:scenario].delete(:tags))
93
123
 
94
124
  parsed_test['steps'] = []
95
- parsed_test[:scenario][:steps].each do |step|
96
- adapt_step!(step)
125
+ if parsed_test[:scenario][:steps]
126
+ parsed_test[:scenario][:steps].each do |step|
127
+ adapt_step!(step)
128
+ end
129
+ parsed_test['steps'].concat(parsed_test[:scenario].delete(:steps))
97
130
  end
98
- parsed_test['steps'].concat(parsed_test[:scenario].delete(:steps))
99
131
  end
100
132
 
101
133
  # Adapts the AST sub-tree that is rooted at the given outline node.
102
134
  def adapt_outline!(parsed_test)
103
135
  # Removing parsed data for child elements in order to avoid duplicating data
104
- parsed_test['cuke_modeler_parsing_data'][:scenario][:tags] = nil
105
- parsed_test['cuke_modeler_parsing_data'][:scenario][:steps] = nil
106
- parsed_test['cuke_modeler_parsing_data'][:scenario][:examples] = nil
136
+ parsed_test['cuke_modeler_parsing_data'][:scenario][:tags] = nil if parsed_test['cuke_modeler_parsing_data'][:scenario][:tags]
137
+ parsed_test['cuke_modeler_parsing_data'][:scenario][:steps] = nil if parsed_test['cuke_modeler_parsing_data'][:scenario][:steps]
138
+ parsed_test['cuke_modeler_parsing_data'][:scenario][:examples] = nil if parsed_test['cuke_modeler_parsing_data'][:scenario][:examples]
107
139
 
108
140
  parsed_test['type'] = 'ScenarioOutline'
109
141
  parsed_test['keyword'] = parsed_test[:scenario].delete(:keyword)
110
142
  parsed_test['name'] = parsed_test[:scenario].delete(:name)
111
- parsed_test['description'] = parsed_test[:scenario].delete(:description)
143
+ parsed_test['description'] = parsed_test[:scenario].delete(:description) || ''
112
144
  parsed_test['line'] = parsed_test[:scenario].delete(:location)[:line]
113
145
 
114
146
  parsed_test['tags'] = []
115
- parsed_test[:scenario][:tags].each do |tag|
116
- adapt_tag!(tag)
147
+ if parsed_test[:scenario][:tags]
148
+ parsed_test[:scenario][:tags].each do |tag|
149
+ adapt_tag!(tag)
150
+ end
151
+ parsed_test['tags'].concat(parsed_test[:scenario].delete(:tags))
117
152
  end
118
- parsed_test['tags'].concat(parsed_test[:scenario].delete(:tags))
119
153
 
120
154
  parsed_test['steps'] = []
121
- parsed_test[:scenario][:steps].each do |step|
122
- adapt_step!(step)
155
+ if parsed_test[:scenario][:steps]
156
+ parsed_test[:scenario][:steps].each do |step|
157
+ adapt_step!(step)
158
+ end
159
+ parsed_test['steps'].concat(parsed_test[:scenario].delete(:steps))
123
160
  end
124
- parsed_test['steps'].concat(parsed_test[:scenario].delete(:steps))
125
161
 
126
162
  parsed_test['examples'] = []
127
- parsed_test[:scenario][:examples].each do |step|
128
- adapt_example!(step)
163
+ if parsed_test[:scenario][:examples]
164
+ parsed_test[:scenario][:examples].each do |step|
165
+ adapt_example!(step)
166
+ end
167
+ parsed_test['examples'].concat(parsed_test[:scenario].delete(:examples))
129
168
  end
130
- parsed_test['examples'].concat(parsed_test[:scenario].delete(:examples))
131
169
  end
132
170
 
133
171
  # Adapts the AST sub-tree that is rooted at the given example node.
@@ -136,14 +174,14 @@ module CukeModeler
136
174
  parsed_example['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_example))
137
175
 
138
176
  # 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'][:table_header] = nil
141
- parsed_example['cuke_modeler_parsing_data'][:table_body] = nil
177
+ parsed_example['cuke_modeler_parsing_data'][:tags] = nil if parsed_example['cuke_modeler_parsing_data'][:tags]
178
+ parsed_example['cuke_modeler_parsing_data'][:table_header] = nil if parsed_example['cuke_modeler_parsing_data'][:table_header]
179
+ parsed_example['cuke_modeler_parsing_data'][:table_body] = nil if parsed_example['cuke_modeler_parsing_data'][:table_body]
142
180
 
143
181
  parsed_example['keyword'] = parsed_example.delete(:keyword)
144
182
  parsed_example['name'] = parsed_example.delete(:name)
145
183
  parsed_example['line'] = parsed_example.delete(:location)[:line]
146
- parsed_example['description'] = parsed_example.delete(:description)
184
+ parsed_example['description'] = parsed_example.delete(:description) || ''
147
185
 
148
186
  parsed_example['rows'] = []
149
187
 
@@ -153,19 +191,19 @@ module CukeModeler
153
191
  end
154
192
 
155
193
  if parsed_example[:table_body]
156
-
157
194
  parsed_example[:table_body].each do |row|
158
195
  adapt_table_row!(row)
159
196
  end
160
197
  parsed_example['rows'].concat(parsed_example.delete(:table_body))
161
198
  end
162
199
 
163
-
164
200
  parsed_example['tags'] = []
165
- parsed_example[:tags].each do |tag|
166
- adapt_tag!(tag)
201
+ if parsed_example[:tags]
202
+ parsed_example[:tags].each do |tag|
203
+ adapt_tag!(tag)
204
+ end
205
+ parsed_example['tags'].concat(parsed_example.delete(:tags))
167
206
  end
168
- parsed_example['tags'].concat(parsed_example.delete(:tags))
169
207
  end
170
208
 
171
209
  # Adapts the AST sub-tree that is rooted at the given tag node.
@@ -192,14 +230,13 @@ module CukeModeler
192
230
  parsed_step['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step))
193
231
 
194
232
  # Removing parsed data for child elements in order to avoid duplicating data
195
- parsed_step['cuke_modeler_parsing_data'][:data_table] = nil
196
- parsed_step['cuke_modeler_parsing_data'][:doc_string] = nil
233
+ parsed_step['cuke_modeler_parsing_data'][:data_table] = nil if parsed_step['cuke_modeler_parsing_data'][:data_table]
234
+ parsed_step['cuke_modeler_parsing_data'][:doc_string] = nil if parsed_step['cuke_modeler_parsing_data'][:doc_string]
197
235
 
198
236
  parsed_step['keyword'] = parsed_step.delete(:keyword)
199
237
  parsed_step['name'] = parsed_step.delete(:text)
200
238
  parsed_step['line'] = parsed_step.delete(:location)[:line]
201
239
 
202
-
203
240
  case
204
241
  when parsed_step[:doc_string]
205
242
  adapt_doc_string!(parsed_step[:doc_string])
@@ -218,7 +255,7 @@ module CukeModeler
218
255
  parsed_doc_string['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_doc_string))
219
256
 
220
257
  parsed_doc_string['value'] = parsed_doc_string.delete(:content)
221
- 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
258
+ parsed_doc_string['content_type'] = parsed_doc_string.delete(:media_type)
222
259
  parsed_doc_string['line'] = parsed_doc_string.delete(:location)[:line]
223
260
  end
224
261
 
@@ -246,7 +283,6 @@ module CukeModeler
246
283
  # Removing parsed data for child elements in order to avoid duplicating data which the child elements will themselves include
247
284
  parsed_table_row['cuke_modeler_parsing_data'][:cells] = nil
248
285
 
249
-
250
286
  parsed_table_row['line'] = parsed_table_row.delete(:location)[:line]
251
287
 
252
288
  parsed_table_row['cells'] = []
@@ -270,22 +306,22 @@ module CukeModeler
270
306
 
271
307
 
272
308
  def adapt_child_elements!(parsed_children)
273
- return if parsed_children.empty?
274
-
275
309
  background_child = parsed_children.find { |child| child[:background] }
310
+ rule_children = parsed_children.select { |child| child[:rule] }
311
+ remaining_children = parsed_children.reject { |child| child[:background] || child[:rule] }
276
312
 
277
- if background_child
278
- adapt_background!(background_child)
313
+ adapt_background!(background_child) if background_child
314
+ adapt_rules!(rule_children)
315
+ adapt_tests!(remaining_children)
316
+ end
279
317
 
280
- remaining_children = parsed_children.reject { |child| child[:background] }
318
+ def adapt_rules!(parsed_rules)
319
+ parsed_rules.each do |rule|
320
+ adapt_rule!(rule)
281
321
  end
282
-
283
- adapt_tests!(remaining_children || parsed_children)
284
322
  end
285
323
 
286
324
  def adapt_tests!(parsed_tests)
287
- return unless parsed_tests
288
-
289
325
  parsed_tests.each do |test|
290
326
  adapt_test!(test)
291
327
  end
@@ -295,9 +331,8 @@ module CukeModeler
295
331
  # Saving off the original data
296
332
  parsed_test['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_test))
297
333
 
298
-
299
334
  case
300
- when parsed_test[:scenario] && parsed_test[:scenario][:examples].any?
335
+ when (parsed_test[:scenario] && parsed_test[:scenario][:examples]) || (parsed_test[:scenario] && Parsing.dialects[Parsing.dialect]['scenarioOutline'].include?(parsed_test[:scenario][:keyword]))
301
336
  adapt_outline!(parsed_test)
302
337
  when parsed_test[:scenario]
303
338
  adapt_scenario!(parsed_test)