cuke_modeler 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -4
- data/History.md +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +3 -3
- data/appveyor.yml +27 -9
- data/cuke_modeler.gemspec +1 -1
- data/lib/cuke_modeler/containing.rb +13 -0
- data/lib/cuke_modeler/parsing.rb +3 -2
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/gemfiles/gherkin5.gemfile +1 -0
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +14 -9
- data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +102 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c06eb0f7c8ad2e127b31d82a1ed6b1d5fcadeb37abbc24ae23fc9d6e2c04b95
|
4
|
+
data.tar.gz: 1e80f3199b425171a1f4fbc0eb386182469f21d242f9594928f4714b42bf3dc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e9880c514513eaef025dc5975aa4fa495bdb511d1496bcc4af8eba43931b1b8de57f755f7aed0d01c452e4068d30c88c1e1a73bf01e808e22d97bd7d39f4fae
|
7
|
+
data.tar.gz: 9de23cb51211b1469ddb0dc4e8cbe77eceea3c76aaf0fa2d1edca1bd3b0f16971578e58633b41f14e0f773f8f57efa9c246031215bf14262e78c358d6ace460c
|
data/.travis.yml
CHANGED
@@ -6,8 +6,10 @@ language: ruby
|
|
6
6
|
rvm:
|
7
7
|
- 1.8.7
|
8
8
|
- 1.9.3
|
9
|
-
- 2.3.
|
10
|
-
- 2.4.
|
9
|
+
- 2.3.8
|
10
|
+
- 2.4.5
|
11
|
+
- 2.5.3
|
12
|
+
- 2.6.0
|
11
13
|
- jruby-9.1.7.0
|
12
14
|
|
13
15
|
gemfile:
|
@@ -35,6 +37,11 @@ matrix:
|
|
35
37
|
- rvm: 1.9.3
|
36
38
|
gemfile: testing/gemfiles/gherkin6.gemfile
|
37
39
|
|
40
|
+
# TODO: use once protobuf is updated
|
41
|
+
# gherkin 6.x uses protobuf, which does not work with Ruby 2.6.x
|
42
|
+
- rvm: 2.6.0
|
43
|
+
gemfile: testing/gemfiles/gherkin6.gemfile
|
44
|
+
|
38
45
|
# TODO: turn this back on
|
39
46
|
# gherkin 6.x relies on 'google-protobuf', which does not currently work on JRuby (https://github.com/protocolbuffers/protobuf/issues/1594)
|
40
47
|
- rvm: jruby-9.1.7.0
|
@@ -47,8 +54,7 @@ matrix:
|
|
47
54
|
- rvm: 1.9.3
|
48
55
|
os: osx
|
49
56
|
|
50
|
-
# todo - Remove this once TravisCI fixes their bundler issue (https://github.com/alphagov/govuk_template/pull/186)
|
51
57
|
before_install:
|
52
|
-
- gem install bundler -v
|
58
|
+
- gem install bundler -v '< 2'
|
53
59
|
|
54
60
|
script: bundle exec rake cuke_modeler:ci_build
|
data/History.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/cuke_modeler.svg)](https://rubygems.org/gems/cuke_modeler)
|
2
|
-
[![Dependency Status](https://gemnasium.com/enkessler/cuke_modeler.svg)](https://gemnasium.com/enkessler/cuke_modeler)
|
3
2
|
[![Build Status](https://travis-ci.org/enkessler/cuke_modeler.svg?branch=dev)](https://travis-ci.org/enkessler/cuke_modeler)
|
4
3
|
[![Build status](https://ci.appveyor.com/api/projects/status/is8xqvoqn3pjh9l0/branch/dev?svg=true)](https://ci.appveyor.com/project/enkessler/cuke-modeler/branch/dev)
|
5
4
|
[![Coverage Status](https://coveralls.io/repos/github/enkessler/cuke_modeler/badge.svg?branch=dev)](https://coveralls.io/github/enkessler/cuke_modeler?branch=dev)
|
@@ -18,7 +17,7 @@ the rescue by providing a modeling layer that is easier to work with.
|
|
18
17
|
|
19
18
|
Whether you just want something that will let you easily inspect your test
|
20
19
|
suite or you are looking for a foundation tool upon which to build something
|
21
|
-
Really Neat, this gem has you covered.
|
20
|
+
[Really Neat](#projects), this gem has you covered.
|
22
21
|
|
23
22
|
|
24
23
|
## Installation
|
@@ -108,12 +107,13 @@ that feature is ultimately run with SpecFlow (Cucumber for C#), Lettuce
|
|
108
107
|
(Cucumber for Python), or some other flavor of Cucumber.
|
109
108
|
|
110
109
|
|
111
|
-
### Other gems that are
|
110
|
+
### <a id="projects"></a>Other gems that are powered by **cuke_modeler**
|
112
111
|
|
113
112
|
* [cql](https://github.com/enkessler/cql)
|
114
113
|
* [cuketagger](https://github.com/enkessler/cuketagger)
|
115
114
|
* [cuke_cataloger](https://github.com/enkessler/cuke_cataloger)
|
116
115
|
* [cuke_slicer](https://github.com/grange-insurance/cuke_slicer)
|
116
|
+
* [cuke_linter](https://github.com/enkessler/cuke_linter)
|
117
117
|
|
118
118
|
|
119
119
|
## Contributing
|
data/appveyor.yml
CHANGED
@@ -4,28 +4,46 @@ environment:
|
|
4
4
|
matrix:
|
5
5
|
|
6
6
|
# Gherkin 2.x does not appear to support 32-bit Ruby 2.x and it's not worth it to investigate if this is true or not
|
7
|
-
- RUBY_VERSION:
|
7
|
+
- RUBY_VERSION: 24-x64
|
8
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin2.gemfile
|
9
|
+
- RUBY_VERSION: 25-x64
|
8
10
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin2.gemfile
|
9
11
|
|
10
|
-
- RUBY_VERSION:
|
12
|
+
- RUBY_VERSION: 24
|
13
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
|
14
|
+
- RUBY_VERSION: 24-x64
|
15
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
|
16
|
+
- RUBY_VERSION: 25
|
11
17
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
|
12
|
-
- RUBY_VERSION:
|
18
|
+
- RUBY_VERSION: 25-x64
|
13
19
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin3.gemfile
|
14
20
|
|
15
|
-
- RUBY_VERSION:
|
21
|
+
- RUBY_VERSION: 24
|
22
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
|
23
|
+
- RUBY_VERSION: 24-x64
|
24
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
|
25
|
+
- RUBY_VERSION: 25
|
16
26
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
|
17
|
-
- RUBY_VERSION:
|
27
|
+
- RUBY_VERSION: 25-x64
|
18
28
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin4.gemfile
|
19
29
|
|
20
|
-
- RUBY_VERSION:
|
30
|
+
- RUBY_VERSION: 24
|
21
31
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin5.gemfile
|
22
|
-
- RUBY_VERSION:
|
32
|
+
- RUBY_VERSION: 24-x64
|
33
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin5.gemfile
|
34
|
+
- RUBY_VERSION: 25
|
35
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin5.gemfile
|
36
|
+
- RUBY_VERSION: 25-x64
|
23
37
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin5.gemfile
|
24
38
|
|
25
39
|
# Gherkin 6.x requires at least Ruby 2.2
|
26
|
-
- RUBY_VERSION:
|
40
|
+
- RUBY_VERSION: 24
|
41
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin6.gemfile
|
42
|
+
- RUBY_VERSION: 24-x64
|
43
|
+
BUNDLE_GEMFILE: testing/gemfiles/gherkin6.gemfile
|
44
|
+
- RUBY_VERSION: 25
|
27
45
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin6.gemfile
|
28
|
-
- RUBY_VERSION:
|
46
|
+
- RUBY_VERSION: 25-x64
|
29
47
|
BUNDLE_GEMFILE: testing/gemfiles/gherkin6.gemfile
|
30
48
|
|
31
49
|
install:
|
data/cuke_modeler.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency('json', '>= 1.0', '< 3.0')
|
23
23
|
spec.add_runtime_dependency('multi_json', '~> 1.0')
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "bundler"
|
26
26
|
spec.add_development_dependency "rake", '< 13.0.0'
|
27
27
|
spec.add_development_dependency 'cucumber', '< 5.0.0'
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
@@ -4,6 +4,19 @@ module CukeModeler
|
|
4
4
|
|
5
5
|
module Containing
|
6
6
|
|
7
|
+
def each_descendant(&block)
|
8
|
+
children.each do |child_model|
|
9
|
+
block.call(child_model)
|
10
|
+
child_model.each_descendant(&block) if child_model.respond_to?(:each_descendant)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def each_model(&block)
|
15
|
+
block.call(self)
|
16
|
+
|
17
|
+
each_descendant(&block)
|
18
|
+
end
|
19
|
+
|
7
20
|
|
8
21
|
private
|
9
22
|
|
data/lib/cuke_modeler/parsing.rb
CHANGED
@@ -44,8 +44,9 @@ module CukeModeler
|
|
44
44
|
require 'gherkin/parser'
|
45
45
|
require 'cuke_modeler/adapters/gherkin_4_adapter'
|
46
46
|
|
47
|
-
|
47
|
+
|
48
48
|
# todo - make these methods private?
|
49
|
+
# Filename isn't used by this version of Gherkin but keeping the parameter so that the calling method only has to know one method signature
|
49
50
|
def self.parsing_method(source_text, _filename)
|
50
51
|
Gherkin::Parser.new.parse(source_text)
|
51
52
|
end
|
@@ -59,6 +60,7 @@ module CukeModeler
|
|
59
60
|
require 'cuke_modeler/adapters/gherkin_3_adapter'
|
60
61
|
|
61
62
|
|
63
|
+
# Filename isn't used by this version of Gherkin but keeping the parameter so that the calling method only has to know one method signature
|
62
64
|
def self.parsing_method(source_text, _filename)
|
63
65
|
Gherkin::Parser.new.parse(source_text)
|
64
66
|
end
|
@@ -89,7 +91,6 @@ module CukeModeler
|
|
89
91
|
end
|
90
92
|
|
91
93
|
else
|
92
|
-
# TODO: test this
|
93
94
|
raise("Unknown Gherkin version: '#{gherkin_version}'")
|
94
95
|
end
|
95
96
|
|
data/lib/cuke_modeler/version.rb
CHANGED
@@ -16,6 +16,7 @@ if RUBY_VERSION =~ /^1\./
|
|
16
16
|
gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
|
17
17
|
gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
|
18
18
|
gem 'rake', '< 12.3.0' # Ruby 1.9.x support dropped after this version
|
19
|
+
gem 'cucumber-core', '< 3.0.0' # Ruby 1.9.x support dropped after this version
|
19
20
|
|
20
21
|
elsif RUBY_VERSION =~ /^2\./
|
21
22
|
|
@@ -9,7 +9,16 @@ describe 'Parsing, Integration' do
|
|
9
9
|
describe 'unique behavior' do
|
10
10
|
|
11
11
|
it 'will complain if using an unknown version of `gherkin`' do
|
12
|
-
|
12
|
+
original_version = Gem.loaded_specs['gherkin'].version
|
13
|
+
unknown_version = Gem::Version.new('0.0.0')
|
14
|
+
|
15
|
+
begin
|
16
|
+
Gem.loaded_specs['gherkin'].instance_variable_set(:@version, unknown_version)
|
17
|
+
|
18
|
+
expect { load "#{File.dirname(__FILE__)}/../../../../lib/cuke_modeler/parsing.rb" }.to raise_error("Unknown Gherkin version: '0.0.0'")
|
19
|
+
ensure
|
20
|
+
Gem.loaded_specs['gherkin'].instance_variable_set(:@version, original_version)
|
21
|
+
end
|
13
22
|
end
|
14
23
|
|
15
24
|
it 'loads the correct dialects based on the version of Gherkin used', :gherkin6 => true do
|
@@ -68,6 +77,10 @@ describe 'Parsing, Integration' do
|
|
68
77
|
expect { nodule.parse_text('bad file', 'file foo.txt') }.to raise_error(/'file foo\.txt'/)
|
69
78
|
end
|
70
79
|
|
80
|
+
it 'has a default file name used while parsing if one is not provided' do
|
81
|
+
expect { nodule.parse_text('bad file') }.to raise_error(ArgumentError, /'cuke_modeler_fake_file\.feature'/)
|
82
|
+
end
|
83
|
+
|
71
84
|
it 'includes the underlying error message in the error that it raises' do
|
72
85
|
begin
|
73
86
|
$old_method = CukeModeler::Parsing.method(:parsing_method)
|
@@ -104,14 +117,6 @@ describe 'Parsing, Integration' do
|
|
104
117
|
|
105
118
|
end
|
106
119
|
|
107
|
-
it 'has a default file name if one is not provided' do
|
108
|
-
expect { nodule.parse_text('bad file') }.to raise_error(ArgumentError, /'cuke_modeler_fake_file\.feature'/)
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'uses the given file name if one is provided' do
|
112
|
-
skip('finish me')
|
113
|
-
end
|
114
|
-
|
115
120
|
end
|
116
121
|
|
117
122
|
end
|
@@ -22,4 +22,106 @@ shared_examples_for 'a containing model' do
|
|
22
22
|
expect(model.children).to_not include(nil)
|
23
23
|
end
|
24
24
|
|
25
|
+
it 'can execute code on all models in its model tree' do
|
26
|
+
expect(model).to respond_to(:each_model)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'can execute code on all of its descendants' do
|
30
|
+
expect(model).to respond_to(:each_descendant)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
context 'without children' do
|
35
|
+
|
36
|
+
let(:parent_model) do
|
37
|
+
m = clazz.new
|
38
|
+
|
39
|
+
# Not all models have a name, so making sure that this one does
|
40
|
+
def m.name
|
41
|
+
'top level model'
|
42
|
+
end
|
43
|
+
|
44
|
+
# Redefining what children are returned for the model rather than fiddling with all of the different kinds of child models that various model classes have
|
45
|
+
def m.children
|
46
|
+
[]
|
47
|
+
end
|
48
|
+
|
49
|
+
m
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
it 'executes the provided code on each descendant of the model' do
|
54
|
+
names = []
|
55
|
+
|
56
|
+
parent_model.each_descendant do |descendant_model|
|
57
|
+
names << descendant_model.name
|
58
|
+
end
|
59
|
+
|
60
|
+
expect(names).to be_empty
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'executes the provided code on each model in its tree' do
|
64
|
+
names = []
|
65
|
+
|
66
|
+
parent_model.each_model do |model_node|
|
67
|
+
names << model_node.name
|
68
|
+
end
|
69
|
+
|
70
|
+
expect(names).to match_array(['top level model'])
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
context 'with children' do
|
77
|
+
|
78
|
+
let(:parent_model) do
|
79
|
+
m = clazz.new
|
80
|
+
|
81
|
+
# Not all models have a name, so making sure that this one does
|
82
|
+
def m.name
|
83
|
+
'top level model'
|
84
|
+
end
|
85
|
+
|
86
|
+
# Redefining what children are returned for the model rather than fiddling with all of the different kinds of child models that various model classes have
|
87
|
+
def m.children
|
88
|
+
containing_model_stub = Struct.new(:name, :children)
|
89
|
+
non_containing_model_stub = Struct.new(:name)
|
90
|
+
nested_child_object = containing_model_stub.new('grandchild object', [])
|
91
|
+
nested_child_object.extend(CukeModeler::Containing)
|
92
|
+
|
93
|
+
non_containing_child_object = non_containing_model_stub.new('child object 1')
|
94
|
+
|
95
|
+
child_object_with_children = containing_model_stub.new('child object 2', [nested_child_object])
|
96
|
+
child_object_with_children.extend(CukeModeler::Containing)
|
97
|
+
|
98
|
+
[non_containing_child_object, child_object_with_children]
|
99
|
+
end
|
100
|
+
|
101
|
+
m
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
it 'executes the provided code on each descendant of the model' do
|
106
|
+
names = []
|
107
|
+
|
108
|
+
parent_model.each_descendant do |descendant_model|
|
109
|
+
names << descendant_model.name
|
110
|
+
end
|
111
|
+
|
112
|
+
expect(names).to match_array(['child object 1', 'child object 2', 'grandchild object'])
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'executes the provided code on each model in its tree' do
|
116
|
+
names = []
|
117
|
+
|
118
|
+
parent_model.each_model do |model_node|
|
119
|
+
names << model_node.name
|
120
|
+
end
|
121
|
+
|
122
|
+
expect(names).to match_array(['top level model', 'child object 1', 'child object 2', 'grandchild object'])
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
25
127
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuke_modeler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kessler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|
@@ -62,16 +62,16 @@ dependencies:
|
|
62
62
|
name: bundler
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - "
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rake
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|