cuke_modeler 1.4.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +329 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +25 -18
  5. data/cuke_modeler.gemspec +15 -9
  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_6_adapter.rb → gherkin_9_adapter.rb} +75 -64
  11. data/lib/cuke_modeler/containing.rb +16 -0
  12. data/lib/cuke_modeler/described.rb +1 -0
  13. data/lib/cuke_modeler/models/background.rb +1 -1
  14. data/lib/cuke_modeler/models/cell.rb +1 -1
  15. data/lib/cuke_modeler/models/comment.rb +1 -1
  16. data/lib/cuke_modeler/models/directory.rb +2 -2
  17. data/lib/cuke_modeler/models/doc_string.rb +1 -1
  18. data/lib/cuke_modeler/models/example.rb +1 -1
  19. data/lib/cuke_modeler/models/feature.rb +1 -1
  20. data/lib/cuke_modeler/models/feature_file.rb +2 -2
  21. data/lib/cuke_modeler/models/outline.rb +1 -1
  22. data/lib/cuke_modeler/models/row.rb +1 -1
  23. data/lib/cuke_modeler/models/scenario.rb +1 -1
  24. data/lib/cuke_modeler/models/step.rb +32 -3
  25. data/lib/cuke_modeler/models/table.rb +1 -1
  26. data/lib/cuke_modeler/models/tag.rb +1 -1
  27. data/lib/cuke_modeler/named.rb +1 -0
  28. data/lib/cuke_modeler/nested.rb +1 -0
  29. data/lib/cuke_modeler/parsed.rb +1 -0
  30. data/lib/cuke_modeler/parsing.rb +88 -92
  31. data/lib/cuke_modeler/sourceable.rb +1 -0
  32. data/lib/cuke_modeler/stepped.rb +1 -0
  33. data/lib/cuke_modeler/taggable.rb +1 -0
  34. data/lib/cuke_modeler/version.rb +1 -1
  35. data/testing/cucumber/features/analysis/step_comparison.feature +25 -0
  36. data/testing/cucumber/features/analysis/test_comparison.feature +1 -1
  37. metadata +55 -142
  38. data/.gitignore +0 -18
  39. data/.simplecov +0 -7
  40. data/.travis.yml +0 -54
  41. data/Gemfile +0 -36
  42. data/History.md +0 -191
  43. data/Rakefile +0 -63
  44. data/appveyor.yml +0 -43
  45. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -273
  46. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -296
  47. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -308
  48. data/testing/cucumber/step_definitions/action_steps.rb +0 -13
  49. data/testing/cucumber/step_definitions/background_steps.rb +0 -1
  50. data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
  51. data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
  52. data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
  53. data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
  54. data/testing/cucumber/step_definitions/modeling_steps.rb +0 -44
  55. data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
  56. data/testing/cucumber/step_definitions/step_steps.rb +0 -3
  57. data/testing/cucumber/step_definitions/table_steps.rb +0 -1
  58. data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
  59. data/testing/cucumber/step_definitions/verification_steps.rb +0 -173
  60. data/testing/cucumber/support/env.rb +0 -30
  61. data/testing/dialect_helper.rb +0 -48
  62. data/testing/file_helper.rb +0 -47
  63. data/testing/gemfiles/gherkin2.gemfile +0 -32
  64. data/testing/gemfiles/gherkin3.gemfile +0 -26
  65. data/testing/gemfiles/gherkin4.gemfile +0 -27
  66. data/testing/gemfiles/gherkin5.gemfile +0 -26
  67. data/testing/gemfiles/gherkin6.gemfile +0 -10
  68. data/testing/rspec/spec/integration/background_integration_spec.rb +0 -442
  69. data/testing/rspec/spec/integration/cell_integration_spec.rb +0 -335
  70. data/testing/rspec/spec/integration/comment_integration_spec.rb +0 -177
  71. data/testing/rspec/spec/integration/directory_integration_spec.rb +0 -218
  72. data/testing/rspec/spec/integration/doc_string_integration_spec.rb +0 -402
  73. data/testing/rspec/spec/integration/example_integration_spec.rb +0 -741
  74. data/testing/rspec/spec/integration/feature_file_integration_spec.rb +0 -272
  75. data/testing/rspec/spec/integration/feature_integration_spec.rb +0 -650
  76. data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +0 -166
  77. data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +0 -166
  78. data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +0 -165
  79. data/testing/rspec/spec/integration/gherkin_6_adapter_spec.rb +0 -166
  80. data/testing/rspec/spec/integration/model_integration_spec.rb +0 -15
  81. data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
  82. data/testing/rspec/spec/integration/outline_integration_spec.rb +0 -624
  83. data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -117
  84. data/testing/rspec/spec/integration/row_integration_spec.rb +0 -291
  85. data/testing/rspec/spec/integration/scenario_integration_spec.rb +0 -479
  86. data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
  87. data/testing/rspec/spec/integration/step_integration_spec.rb +0 -475
  88. data/testing/rspec/spec/integration/table_integration_spec.rb +0 -337
  89. data/testing/rspec/spec/integration/tag_integration_spec.rb +0 -259
  90. data/testing/rspec/spec/spec_helper.rb +0 -122
  91. data/testing/rspec/spec/unit/background_unit_spec.rb +0 -83
  92. data/testing/rspec/spec/unit/cell_unit_spec.rb +0 -68
  93. data/testing/rspec/spec/unit/comment_unit_spec.rb +0 -68
  94. data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
  95. data/testing/rspec/spec/unit/directory_unit_spec.rb +0 -127
  96. data/testing/rspec/spec/unit/doc_string_unit_spec.rb +0 -100
  97. data/testing/rspec/spec/unit/example_unit_spec.rb +0 -133
  98. data/testing/rspec/spec/unit/feature_file_unit_spec.rb +0 -125
  99. data/testing/rspec/spec/unit/feature_unit_spec.rb +0 -157
  100. data/testing/rspec/spec/unit/model_unit_spec.rb +0 -15
  101. data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
  102. data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
  103. data/testing/rspec/spec/unit/outline_unit_spec.rb +0 -117
  104. data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
  105. data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
  106. data/testing/rspec/spec/unit/row_unit_spec.rb +0 -68
  107. data/testing/rspec/spec/unit/scenario_unit_spec.rb +0 -86
  108. data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
  109. data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -25
  110. data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
  111. data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
  112. data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
  113. data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
  114. data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
  115. data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
  116. data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
  117. data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
  118. data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
  119. data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
  120. data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
  121. data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
  122. data/testing/rspec/spec/unit/step_unit_spec.rb +0 -109
  123. data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
  124. data/testing/rspec/spec/unit/table_unit_spec.rb +0 -77
  125. data/testing/rspec/spec/unit/tag_unit_spec.rb +0 -68
  126. data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
  127. data/testing/test_languages.json +0 -45
  128. data/todo.txt +0 -24
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- .idea/*
data/.simplecov DELETED
@@ -1,7 +0,0 @@
1
- SimpleCov.start do
2
- root File.dirname(__FILE__)
3
-
4
- add_filter '/testing/'
5
-
6
- merge_timeout 300
7
- end
@@ -1,54 +0,0 @@
1
- os:
2
- - linux
3
- - osx
4
-
5
- language: ruby
6
- rvm:
7
- - 1.8.7
8
- - 1.9.3
9
- - 2.3.3
10
- - 2.4.0
11
- - jruby-9.1.7.0
12
-
13
- gemfile:
14
- - testing/gemfiles/gherkin2.gemfile
15
- - testing/gemfiles/gherkin3.gemfile
16
- - testing/gemfiles/gherkin4.gemfile
17
- - testing/gemfiles/gherkin5.gemfile
18
- - testing/gemfiles/gherkin6.gemfile
19
-
20
- matrix:
21
- exclude:
22
- # gherkin 3.x does not work with Ruby 1.8.x
23
- - rvm: 1.8.7
24
- gemfile: testing/gemfiles/gherkin3.gemfile
25
- # gherkin 4.x does not work with Ruby 1.8.x
26
- - rvm: 1.8.7
27
- gemfile: testing/gemfiles/gherkin4.gemfile
28
- # gherkin 5.x does not work with Ruby 1.8.x
29
- - rvm: 1.8.7
30
- gemfile: testing/gemfiles/gherkin5.gemfile
31
- # gherkin 6.x does not work with Ruby 1.8.x
32
- - rvm: 1.8.7
33
- gemfile: testing/gemfiles/gherkin6.gemfile
34
- # gherkin 6.x does not work with Ruby 1.9.x
35
- - rvm: 1.9.3
36
- gemfile: testing/gemfiles/gherkin6.gemfile
37
-
38
- # TODO: turn this back on
39
- # gherkin 6.x relies on 'google-protobuf', which does not currently work on JRuby (https://github.com/protocolbuffers/protobuf/issues/1594)
40
- - rvm: jruby-9.1.7.0
41
- gemfile: testing/gemfiles/gherkin6.gemfile
42
-
43
- # Travis does not provide 1.8.7 on OSX
44
- - rvm: 1.8.7
45
- os: osx
46
- # Travis does not provide 1.9.3 on OSX
47
- - rvm: 1.9.3
48
- os: osx
49
-
50
- # todo - Remove this once TravisCI fixes their bundler issue (https://github.com/alphagov/govuk_template/pull/186)
51
- before_install:
52
- - gem install bundler -v 1.9.10
53
-
54
- script: bundle exec rake cuke_modeler:ci_build
data/Gemfile DELETED
@@ -1,36 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- # Specify your gem's dependencies in cuke_modeler.gemspec
4
- gemspec
5
-
6
- # cuke_modeler can play with pretty much any version of these but they all play differently with Ruby
7
-
8
- if RUBY_VERSION =~ /^1\./
9
-
10
- if RbConfig::CONFIG['host_os'].downcase =~ /mswin|msys|mingw32/
11
- gem 'ffi', '< 1.9.15' # The 'ffi' gem, for Windows, requires Ruby 2.x on/after this version
12
- end
13
-
14
- gem 'unf_ext', '< 0.0.7.3' # Requires Ruby 2.x on/after this version
15
- gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
16
- gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
17
- gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
18
-
19
- if RUBY_VERSION =~ /^1\.8/
20
- gem 'cucumber', '~> 1.0' # Ruby 1.8.x support dropped after this version
21
- gem 'gherkin', '< 2.12.1' # Ruby 1.8.x support dropped after this version
22
- gem 'rake', '< 11.0' # Ruby 1.8.x support dropped after this version
23
- else
24
- gem 'rake', '< 12.3.0' # Ruby 1.9.x support dropped after this version
25
- gem 'cucumber', '< 3.0.0' # Ruby 1.9.x support dropped after this version
26
- end
27
-
28
- elsif RUBY_VERSION =~ /^2\./
29
-
30
- if RUBY_VERSION =~ /^2\.[23456789]/
31
- gem 'test-unit'
32
- end
33
-
34
- gem 'gherkin', '~> 6.0'
35
- gem 'cucumber', '~>4.0.rc'
36
- end
data/History.md DELETED
@@ -1,191 +0,0 @@
1
- ### Version 1.4.0 / 2018-11-14
2
-
3
- * Now compatible with Gherkin 6.x.
4
-
5
-
6
- ### Version 1.3.0 / 2017-10-19
7
-
8
- * Now compatible with Gherkin 5.x.
9
-
10
-
11
- ### Version 1.2.1 / 2017-04-25
12
-
13
- * Now officially compatible with Rake 12.x.
14
-
15
-
16
- ### Version 1.2.0 / 2016-11-23
17
-
18
- * The comments in a feature file are now a modeled element.
19
-
20
-
21
- ### Version 1.1.1 / 2016-10-28
22
-
23
- * Bug fix - Abstract instantiation of models when using a non-default dialect
24
- now works correctly.
25
-
26
-
27
- ### Version 1.1.0 / 2016-10-28
28
-
29
- * Support added for non-English dialects. This gem should now be able to model
30
- feature files using any dialect supported by the 'gherkin' gem.
31
-
32
- * Models for elements of Gherkin that have keywords (e.g. 'Feature', 'Scenario',
33
- 'Examples') now keep track of the keyword used by the element that they model.
34
-
35
- * Bug fix - Fixed a bug that was causing example models to output extra newline
36
- characters under certain circumstances.
37
-
38
-
39
- ### Version 1.0.4 / 2016-10-07
40
-
41
- * Bug Fix - Fixed a bug that caused some models to include nil objects in their
42
- children collection if they did not have the relevant child object.
43
-
44
-
45
- ### Version 1.0.3 / 2016-09-12
46
-
47
- * Fixed a gem dependency that was accidentally declared with '<=' instead of '<'.
48
-
49
-
50
- ### Version 1.0.2 / 2016-09-12
51
-
52
- * A more detailed gem description and summary have been added to the gemspec.
53
-
54
- * The gem now declares version limits on its dependencies.
55
-
56
- * Badges for the current status of the project have been added to the Readme.
57
-
58
-
59
- ### Version 1.0.1 / 2016-09-10
60
-
61
- * In the Readme file, added a link to the published documentation.
62
-
63
-
64
- ### Version 1.0.0 / 2016-09-08
65
-
66
- * All modeled elements of a Cucumber test suite are now modeled with actual
67
- classes. Previously, some elements (such as tags or rows in an example table)
68
- were modeled with simple strings.
69
-
70
- * A base model class has been added in order to simplify adding new element
71
- models. Other classes and modules used for organizing common model behavior
72
- have been created/removed/renamed.
73
-
74
- * Feature file models now only have a single feature model instead of a
75
- collection of them (that would only ever have one item in it).
76
-
77
- * Rows in an example table and rows in a step table no longer use two different
78
- classes for modeling.
79
-
80
- * Background models can now be compared to other models that have steps (i.e.
81
- scenarios and outlines).
82
-
83
- * All models for Gherkin elements now track the line number from which they
84
- originate in a source file.
85
-
86
- * The source line of a model is now a mutable attribute instead of being read
87
- only.
88
-
89
- * The file path of a feature file is now a mutable attribute instead of being
90
- read only.
91
-
92
- * Standardized the initial values of the attributes of abstractly created
93
- models so that they are consistent across model types.
94
-
95
- * Added specific ancestor types for scenario, outline, and background models as
96
- alternatives to the generic 'test' ancestor type.
97
-
98
- * Extra whitespace around parsed element descriptions is now trimmed away
99
- before being stored in a model.
100
-
101
- * Adding rows to examples via hashes can now be done without regard to the
102
- order of the keys in the hash. The correct order can be determined by the
103
- model.
104
-
105
- * The saved parsing data that is generated by the 'gherkin' gem is no longer
106
- duplicated for each model, resulting in significantly less memory usage.
107
-
108
- * String output of models has been improved. More special characters in Gherkin
109
- (e.g. vertical bars in rows) are appropriately escaped in the string output
110
- of a model and several minor bugs related to using model string output as the
111
- input text for new models have been fixed.
112
-
113
- * Removed the backdoor used to pass around model data during the model creation
114
- process. Model input can now only be text.
115
-
116
- * Simple counting methods have been removed. Ruby's collection methods are just
117
- as easy to use directly when dealing with classes that contain collections
118
- and the removal of these counting methods simplifies the codebase.
119
-
120
- * The 'World' module has been removed. The scope of this gem is to model files
121
- written in Gherkin. Concepts like 'step definitions' and 'hooks' are better
122
- left to libraries that include (possibly programming language specific) test
123
- execution logic within their scope of concern.
124
-
125
- * Step models no longer have 'arguments' because they require the concept of
126
- step definitions, which are no longer within the scope of this gem.
127
-
128
- * Removed deprecated behavior
129
- - Marked
130
- - Doc strings no longer use an array of strings to model their content
131
- - Tables no longer use nested arrays of strings to model their rows
132
- - Models that have descriptions no longer use an array of strings to
133
- model their description
134
- - The convenient (read: awkward) #step_text has been removed.
135
- - Unmarked
136
- - Examples no longer use an array of hashes to model their rows
137
-
138
- * Various methods have been renamed.
139
-
140
-
141
- ### Version 0.4.1 / 2016-05-12
142
-
143
- * Increased the flexibility of input when adding rows to an Example object. Non-
144
- string values can now be used as input and they will be converted into
145
- strings. Original input objects are not modified.
146
-
147
- * Added some error checking around adding value rows to an Example object
148
- without adding a parameter row as well.
149
-
150
-
151
- ### Version 0.4.0 / 2016-05-01
152
-
153
- * The path of a Directory object is now a changeable attribute instead of only
154
- being populated if the instance was given a diretory to model.
155
-
156
- * Bug fix - Fixed a bug that occurred if a Directory object was asked for its
157
- \#name when it was created as 'abstract' instead of modeling an existing
158
- directory.
159
-
160
-
161
- ### Version 0.3.0 / 2016-04-24
162
-
163
- * Support for version 4.x of the 'gherkin' gem added.
164
-
165
- * Bug fix - Fixed a bug that was preventing Example objects from being created
166
- from text if that text had less Gherkin structure than normal.
167
-
168
-
169
- ### Version 0.2.0 / 2016-02-21
170
-
171
- * Better error feedback when parsing errors are encountered. It is now easier
172
- to tell which file contained invalid Gherkin.
173
-
174
-
175
- ### Version 0.1.0 / 2016-02-10
176
-
177
- * Support for version 3.x of the 'gherkin' gem added.
178
-
179
- * Bug fix - The saved parsing data that is generated by the 'gherkin' gem is no
180
- longer modified by the rest of the model creation process.
181
-
182
-
183
- ### Version 0.0.2 / 2015-11-22
184
-
185
- * Bug fix - Fixed a bug that was causing object comparison using #== to not
186
- work when comparing some models to other types of objects.
187
-
188
-
189
- ### Version 0.0.1 / 2014-06-02
190
-
191
- * Initial release
data/Rakefile DELETED
@@ -1,63 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require 'coveralls/rake/task'
3
-
4
- require 'racatt'
5
-
6
-
7
- namespace 'cuke_modeler' do
8
-
9
- task :clear_coverage do
10
- code_coverage_directory = "#{File.dirname(__FILE__)}/coverage"
11
-
12
- FileUtils.remove_dir(code_coverage_directory, true)
13
- end
14
-
15
-
16
- Racatt.create_tasks
17
-
18
- # Redefining the task from 'racatt' in order to clear the code coverage results
19
- task :test_everything => :clear_coverage
20
-
21
-
22
- # The task that CI will use
23
- Coveralls::RakeTask.new
24
- task :ci_build => [:smart_test, 'coveralls:push']
25
-
26
- desc 'Test gem based on Ruby/dependency versions'
27
- task :smart_test do |t, args|
28
- rspec_args = '--tag ~@wip --pattern testing/rspec/spec/**/*_spec.rb'
29
-
30
- cucumber_version = Gem.loaded_specs['cucumber'].version.version
31
-
32
- if cucumber_version =~ /^[123]\./
33
- cucumber_args = 'testing/cucumber/features -r testing/cucumber/support -r testing/cucumber/step_definitions -f progress -t ~@wip'
34
- else
35
- cucumber_args = "testing/cucumber/features -r testing/cucumber/support -r testing/cucumber/step_definitions -f progress -t 'not @wip'"
36
- end
37
-
38
- Rake::Task['cuke_modeler:test_everything'].invoke(rspec_args, cucumber_args)
39
- end
40
-
41
-
42
- # The task used to publish the current feature file documentation to Relish
43
- desc 'Publish feature files to Relish'
44
- task :publish_features do
45
- # Get existing versions
46
- this_dir = File.dirname(__FILE__)
47
- output = `relish versions enkessler/CukeModeler`
48
-
49
- # Add the current version if it doesn't exist
50
- unless output =~ /#{Regexp.escape(CukeModeler::VERSION)}/
51
- output = `relish versions:add enkessler/CukeModeler:#{CukeModeler::VERSION}`
52
- puts output
53
- end
54
-
55
- # Publish the features
56
- output = `relish push enkessler/CukeModeler:#{CukeModeler::VERSION} path #{this_dir}/testing/cucumber`
57
- puts output
58
- end
59
-
60
- end
61
-
62
-
63
- task :default => 'cuke_modeler:smart_test'
@@ -1,43 +0,0 @@
1
- version: '1.0.{build}'
2
-
3
- environment:
4
- matrix:
5
-
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
- - RUBY_VERSION: 23-x64
8
- BUNDLE_GEMFILE: testing/gemfiles/gherkin2.gemfile
9
-
10
- - RUBY_VERSION: 23
11
- BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
12
- - RUBY_VERSION: 23-x64
13
- BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
14
-
15
- - RUBY_VERSION: 23
16
- BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
17
- - RUBY_VERSION: 23-x64
18
- BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
19
-
20
- - RUBY_VERSION: 23
21
- BUNDLE_GEMFILE: testing/gemfiles/gherkin5.gemfile
22
- - RUBY_VERSION: 23-x64
23
- BUNDLE_GEMFILE: testing/gemfiles/gherkin5.gemfile
24
-
25
- # Gherkin 6.x requires at least Ruby 2.2
26
- - RUBY_VERSION: 23
27
- BUNDLE_GEMFILE: testing/gemfiles/gherkin6.gemfile
28
- - RUBY_VERSION: 23-x64
29
- BUNDLE_GEMFILE: testing/gemfiles/gherkin6.gemfile
30
-
31
- install:
32
- - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
33
- - bundle install
34
-
35
- build: off
36
-
37
- before_test:
38
- - ruby -v
39
- - gem -v
40
- - bundle -v
41
-
42
- test_script:
43
- - bundle exec rake
@@ -1,273 +0,0 @@
1
- module CukeModeler
2
-
3
- # An adapter that can convert the output of version 2.x of the *gherkin* gem into input that is consumable by this gem.
4
-
5
- class Gherkin2Adapter
6
-
7
- # Adapts the given AST into the shape that this gem expects
8
- def adapt(parsed_ast)
9
- parsed_data = {}
10
-
11
- # The entire AST is just an array with one feature and we don't want to save any child data so...an empty array
12
- parsed_data['cuke_modeler_parsing_data'] = []
13
-
14
- # Comments are stored on child elements in gherkin 2.x
15
- comments = []
16
-
17
- # An AST is just one feature
18
- adapt_feature!(parsed_ast.first, comments) if parsed_ast.first
19
- parsed_data['feature'] = parsed_ast.first
20
-
21
- # Adapt and store comments once they have all been gathered
22
- comments.each do |comment|
23
- adapt_comment!(comment)
24
- end
25
- parsed_data['comments'] = comments
26
-
27
-
28
- [parsed_data]
29
- end
30
-
31
- # Adapts the AST sub-tree that is rooted at the given feature node.
32
- def adapt_feature!(parsed_feature, gathered_comments)
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
38
- parsed_feature['cuke_modeler_parsing_data']['elements'] = nil
39
-
40
- if parsed_feature['comments']
41
- parsed_feature['cuke_modeler_parsing_data']['comments'] = nil
42
- gathered_comments.concat(parsed_feature['comments'])
43
- end
44
-
45
- adapt_child_elements!(parsed_feature, gathered_comments)
46
-
47
- if parsed_feature['tags']
48
- parsed_feature['tags'].each do |tag|
49
- adapt_tag!(tag)
50
- end
51
- end
52
- end
53
-
54
- # Adapts the AST sub-tree that is rooted at the given background node.
55
- def adapt_background!(parsed_background, gathered_comments)
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']['steps'] = nil
61
-
62
- if parsed_background['comments']
63
- parsed_background['cuke_modeler_parsing_data']['comments'] = nil
64
- gathered_comments.concat(parsed_background['comments'])
65
- end
66
-
67
- if parsed_background['steps']
68
- parsed_background['steps'].each do |step|
69
- adapt_step!(step, gathered_comments)
70
- end
71
- end
72
- end
73
-
74
- # Adapts the AST sub-tree that is rooted at the given scenario node.
75
- def adapt_scenario!(parsed_scenario, gathered_comments)
76
- # Saving off the original data
77
- parsed_scenario['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_scenario))
78
-
79
- # Removing parsed data for child elements in order to avoid duplicating data
80
- parsed_scenario['cuke_modeler_parsing_data']['tags'] = nil
81
- parsed_scenario['cuke_modeler_parsing_data']['steps'] = nil
82
-
83
- if parsed_scenario['comments']
84
- parsed_scenario['cuke_modeler_parsing_data']['comments'] = nil
85
- gathered_comments.concat(parsed_scenario['comments'])
86
- end
87
-
88
- if parsed_scenario['tags']
89
- parsed_scenario['tags'].each do |tag|
90
- adapt_tag!(tag)
91
- end
92
- end
93
-
94
- if parsed_scenario['steps']
95
- parsed_scenario['steps'].each do |step|
96
- adapt_step!(step, gathered_comments)
97
- end
98
- end
99
- end
100
-
101
- # Adapts the AST sub-tree that is rooted at the given outline node.
102
- def adapt_outline!(parsed_outline, gathered_comments)
103
- # Saving off the original data
104
- parsed_outline['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_outline))
105
-
106
- # Removing parsed data for child elements in order to avoid duplicating data
107
- parsed_outline['cuke_modeler_parsing_data']['tags'] = nil
108
- parsed_outline['cuke_modeler_parsing_data']['steps'] = nil
109
- parsed_outline['cuke_modeler_parsing_data']['examples'] = nil
110
-
111
- if parsed_outline['comments']
112
- parsed_outline['cuke_modeler_parsing_data']['comments'] = nil
113
- gathered_comments.concat(parsed_outline['comments'])
114
- end
115
-
116
- if parsed_outline['tags']
117
- parsed_outline['tags'].each do |tag|
118
- adapt_tag!(tag)
119
- end
120
- end
121
-
122
- if parsed_outline['steps']
123
- parsed_outline['steps'].each do |step|
124
- adapt_step!(step, gathered_comments)
125
- end
126
- end
127
-
128
- if parsed_outline['examples']
129
- parsed_outline['examples'].each do |example|
130
- adapt_example!(example, gathered_comments)
131
- end
132
- end
133
- end
134
-
135
- # Adapts the AST sub-tree that is rooted at the given example node.
136
- def adapt_example!(parsed_example, gathered_comments)
137
- # Saving off the original data
138
- parsed_example['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_example))
139
-
140
- # Removing parsed data for child elements in order to avoid duplicating data
141
- parsed_example['cuke_modeler_parsing_data']['tags'] = nil
142
- parsed_example['cuke_modeler_parsing_data']['rows'] = nil
143
-
144
- if parsed_example['comments']
145
- parsed_example['cuke_modeler_parsing_data']['comments'] = nil
146
- gathered_comments.concat(parsed_example['comments'])
147
- end
148
-
149
- parsed_example['rows'].each do |row|
150
- adapt_table_row!(row, gathered_comments)
151
- end
152
-
153
- if parsed_example['tags']
154
- parsed_example['tags'].each do |tag|
155
- adapt_tag!(tag)
156
- end
157
- end
158
- end
159
-
160
- # Adapts the AST sub-tree that is rooted at the given tag node.
161
- def adapt_tag!(parsed_tag)
162
- # Saving off the original data
163
- parsed_tag['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_tag))
164
- end
165
-
166
- # Adapts the AST sub-tree that is rooted at the given comment node.
167
- def adapt_comment!(parsed_comment)
168
- # Saving off the original data
169
- parsed_comment['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_comment))
170
-
171
- parsed_comment['text'] = parsed_comment.delete('value')
172
- parsed_comment['line'] = parsed_comment.delete('line')
173
- end
174
-
175
- # Adapts the AST sub-tree that is rooted at the given step node.
176
- def adapt_step!(parsed_step, gathered_comments)
177
- # Saving off the original data
178
- parsed_step['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step))
179
-
180
- # Removing parsed data for child elements in order to avoid duplicating data
181
- parsed_step['cuke_modeler_parsing_data']['rows'] = nil if parsed_step['cuke_modeler_parsing_data']['rows']
182
- parsed_step['cuke_modeler_parsing_data']['doc_string'] = nil if parsed_step['cuke_modeler_parsing_data']['doc_string']
183
-
184
- if parsed_step['comments']
185
- parsed_step['cuke_modeler_parsing_data']['comments'] = nil
186
- gathered_comments.concat(parsed_step['comments'])
187
- end
188
-
189
- adapt_doc_string!(parsed_step['doc_string']) if parsed_step['doc_string']
190
-
191
- if parsed_step['rows']
192
- parsed_step['table'] = {'rows' => parsed_step['rows']}
193
- adapt_step_table!(parsed_step['table'], gathered_comments)
194
- end
195
- end
196
-
197
- # Adapts the AST sub-tree that is rooted at the given doc string node.
198
- def adapt_doc_string!(parsed_doc_string)
199
- # Saving off the original data
200
- parsed_doc_string['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_doc_string))
201
- end
202
-
203
- # Adapts the AST sub-tree that is rooted at the given table node.
204
- def adapt_step_table!(parsed_step_table, gathered_comments)
205
- # Saving off the original data
206
- parsed_step_table['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step_table['rows']))
207
-
208
- # Removing parsed data for child elements in order to avoid duplicating data
209
- parsed_step_table['cuke_modeler_parsing_data'].clear
210
-
211
-
212
- parsed_step_table['line'] = parsed_step_table['rows'].first['line']
213
-
214
- parsed_step_table['rows'].each do |row|
215
- adapt_table_row!(row, gathered_comments)
216
- end
217
- end
218
-
219
- # Adapts the AST sub-tree that is rooted at the given row node.
220
- def adapt_table_row!(parsed_table_row, gathered_comments)
221
- # Saving off the original data
222
- parsed_table_row['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_table_row))
223
-
224
- # Removing parsed data for child elements in order to avoid duplicating data which the child elements will themselves include
225
- parsed_table_row['cuke_modeler_parsing_data']['cells'] = nil
226
-
227
- if parsed_table_row['comments']
228
- parsed_table_row['cuke_modeler_parsing_data']['comments'] = nil
229
- gathered_comments.concat(parsed_table_row['comments'])
230
- end
231
-
232
- parsed_table_row['cells'].collect! do |cell|
233
- create_cell_for(cell, parsed_table_row['line'])
234
- end
235
- end
236
-
237
- # Adapts the AST sub-tree that is rooted at the given cell node.
238
- def create_cell_for(parsed_cell, line_number)
239
- cell = {}
240
-
241
- # Saving off the original data
242
- cell['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_cell))
243
-
244
- cell['value'] = parsed_cell
245
- cell['line'] = line_number
246
-
247
-
248
- cell
249
- end
250
-
251
-
252
- private
253
-
254
-
255
- def adapt_child_elements!(parsed_feature, gathered_comments)
256
- if parsed_feature['elements']
257
- parsed_feature['elements'].each do |element|
258
- case element['type']
259
- when 'background'
260
- adapt_background!(element, gathered_comments)
261
- when 'scenario'
262
- adapt_scenario!(element, gathered_comments)
263
- when 'scenario_outline'
264
- adapt_outline!(element, gathered_comments)
265
- else
266
- raise(ArgumentError, "Unknown element type: #{element['type']}")
267
- end
268
- end
269
- end
270
- end
271
-
272
- end
273
- end