cuke_modeler 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -3
- data/README.md +2 -1
- data/lib/cuke_modeler.rb +1 -0
- data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +30 -5
- data/lib/cuke_modeler/containing.rb +15 -5
- data/lib/cuke_modeler/models/feature.rb +15 -4
- data/lib/cuke_modeler/models/rule.rb +99 -0
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/cucumber/features/modeling/feature_modeling.feature +28 -7
- data/testing/cucumber/features/modeling/feature_output.feature +45 -23
- data/testing/cucumber/features/modeling/rule_modeling.feature +108 -0
- data/testing/cucumber/features/modeling/rule_output.feature +111 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b152c6307169c73e75c9e2b4798d29cab2c7b8ad7ed086c12a854739940d2eb
|
4
|
+
data.tar.gz: a50e43b9e28d514d22c0a756be7197e9a5395cdf38fcde50d34e8b1c0c41df53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 627d1c76575e4c2ed4b97ac2ee2db83c920997bc1296bdf6ecfc530ba92250d585c011fa9e315b2c52c28cd9c1f219da7cf1e79fe44e23d0ba868db3de48ffda
|
7
|
+
data.tar.gz: 3f1c554b800ed1a194d800d13ce9b39e5e4dd5655780e6e3ef007e7e2480d3139d5d8feec128d9db470cf3b8d0a996a5116af0a0770e80e20ee1899cbf661b3a
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
8
8
|
|
9
9
|
Nothing yet...
|
10
10
|
|
11
|
+
## [3.2.0] - 2020-07-27
|
12
|
+
|
13
|
+
### Added
|
14
|
+
- The `Rule` keyword is now a modeled element.
|
15
|
+
|
16
|
+
### Deprecated
|
17
|
+
- `Feature#test_case_count` will be removed on the next major release. It's a random analysis method in what is
|
18
|
+
otherwise a purely abstraction layer library. The [CQL](https://github.com/enkessler/cql) gem is better suited to such tasks.
|
19
|
+
|
11
20
|
## [3.1.0] - 2020-06-28
|
12
21
|
|
13
22
|
### Added
|
@@ -16,8 +25,8 @@ Nothing yet...
|
|
16
25
|
|
17
26
|
### Fixed
|
18
27
|
- Text is converted to UTF-8 encoding before being passed to the underlying Gherkin gem. This is due to UTF-8 being
|
19
|
-
the only encoding supported by Gherkin. The `gherkin` gem did the conversion automatically
|
20
|
-
gem does not.
|
28
|
+
the only encoding supported by Gherkin. The `gherkin` gem did the conversion automatically and so this conversion
|
29
|
+
was not necessary previously but the `cucumber-gherkin` gem does not do any automatic conversion.
|
21
30
|
|
22
31
|
## [3.0.0] - 2020-06-08
|
23
32
|
|
@@ -314,7 +323,8 @@ Nothing yet...
|
|
314
323
|
- Initial release
|
315
324
|
|
316
325
|
|
317
|
-
[Unreleased]: https://github.com/enkessler/cuke_modeler/compare/v3.
|
326
|
+
[Unreleased]: https://github.com/enkessler/cuke_modeler/compare/v3.2.0...HEAD
|
327
|
+
[3.2.0]: https://github.com/enkessler/cuke_modeler/compare/v3.1.0...v3.2.0
|
318
328
|
[3.1.0]: https://github.com/enkessler/cuke_modeler/compare/v3.0.0...v3.1.0
|
319
329
|
[3.0.0]: https://github.com/enkessler/cuke_modeler/compare/v2.1.0...v3.0.0
|
320
330
|
[2.1.0]: https://github.com/enkessler/cuke_modeler/compare/v2.0.0...v2.1.0
|
data/README.md
CHANGED
@@ -82,7 +82,8 @@ 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
|
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
|
data/lib/cuke_modeler.rb
CHANGED
@@ -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'
|
@@ -80,6 +80,27 @@ module CukeModeler
|
|
80
80
|
end
|
81
81
|
end
|
82
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))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
83
104
|
# Adapts the AST sub-tree that is rooted at the given scenario node.
|
84
105
|
def adapt_scenario!(parsed_test)
|
85
106
|
# Removing parsed data for child elements in order to avoid duplicating data
|
@@ -286,14 +307,18 @@ module CukeModeler
|
|
286
307
|
|
287
308
|
def adapt_child_elements!(parsed_children)
|
288
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] }
|
289
312
|
|
290
|
-
if background_child
|
291
|
-
|
313
|
+
adapt_background!(background_child) if background_child
|
314
|
+
adapt_rules!(rule_children)
|
315
|
+
adapt_tests!(remaining_children)
|
316
|
+
end
|
292
317
|
|
293
|
-
|
318
|
+
def adapt_rules!(parsed_rules)
|
319
|
+
parsed_rules.each do |rule|
|
320
|
+
adapt_rule!(rule)
|
294
321
|
end
|
295
|
-
|
296
|
-
adapt_tests!(remaining_children || parsed_children)
|
297
322
|
end
|
298
323
|
|
299
324
|
def adapt_tests!(parsed_tests)
|
@@ -32,7 +32,6 @@ module CukeModeler
|
|
32
32
|
|
33
33
|
model.parent_model = self
|
34
34
|
|
35
|
-
|
36
35
|
model
|
37
36
|
end
|
38
37
|
|
@@ -130,6 +129,15 @@ module CukeModeler
|
|
130
129
|
populate_children(feature_object, parsed_feature_data)
|
131
130
|
end
|
132
131
|
|
132
|
+
def populate_rule(rule_object, parsed_rule_data)
|
133
|
+
populate_parsing_data(rule_object, parsed_rule_data)
|
134
|
+
populate_source_line(rule_object, parsed_rule_data)
|
135
|
+
populate_keyword(rule_object, parsed_rule_data)
|
136
|
+
populate_name(rule_object, parsed_rule_data)
|
137
|
+
populate_description(rule_object, parsed_rule_data)
|
138
|
+
populate_children(rule_object, parsed_rule_data)
|
139
|
+
end
|
140
|
+
|
133
141
|
def populate_directory(directory_object, processed_directory_data)
|
134
142
|
directory_object.path = processed_directory_data['path']
|
135
143
|
|
@@ -213,18 +221,20 @@ module CukeModeler
|
|
213
221
|
end
|
214
222
|
end
|
215
223
|
|
216
|
-
def populate_children(
|
224
|
+
def populate_children(model, parsed_feature_data)
|
217
225
|
elements = parsed_feature_data['elements']
|
218
226
|
|
219
227
|
if elements
|
220
228
|
elements.each do |element|
|
221
229
|
case element['type']
|
222
230
|
when 'Scenario', 'scenario'
|
223
|
-
|
231
|
+
model.tests << build_child_model(Scenario, element)
|
224
232
|
when 'ScenarioOutline', 'scenario_outline'
|
225
|
-
|
233
|
+
model.tests << build_child_model(Outline, element)
|
226
234
|
when 'Background', 'background'
|
227
|
-
|
235
|
+
model.background = build_child_model(Background, element)
|
236
|
+
when 'Rule'
|
237
|
+
model.rules << build_child_model(Rule, element)
|
228
238
|
else
|
229
239
|
raise(ArgumentError, "Unknown element type: #{element['type']}")
|
230
240
|
end
|
@@ -17,6 +17,9 @@ module CukeModeler
|
|
17
17
|
# The Background object contained by the Feature
|
18
18
|
attr_accessor :background
|
19
19
|
|
20
|
+
# The Rule objects contained by the Feature
|
21
|
+
attr_accessor :rules
|
22
|
+
|
20
23
|
# The Scenario and Outline objects contained by the Feature
|
21
24
|
attr_accessor :tests
|
22
25
|
|
@@ -25,6 +28,7 @@ module CukeModeler
|
|
25
28
|
# object.
|
26
29
|
def initialize(source_text = nil)
|
27
30
|
@tags = []
|
31
|
+
@rules = []
|
28
32
|
@tests = []
|
29
33
|
|
30
34
|
super(source_text)
|
@@ -50,6 +54,8 @@ module CukeModeler
|
|
50
54
|
@tests.select { |test| test.is_a? Outline }
|
51
55
|
end
|
52
56
|
|
57
|
+
# TODO: Remove this method on next major version release
|
58
|
+
# DEPRECATED
|
53
59
|
# Returns the number of test cases contained in the feature. A test case is a
|
54
60
|
# single set of test values, such as an individual scenario or one example row
|
55
61
|
# of an outline.
|
@@ -63,7 +69,7 @@ module CukeModeler
|
|
63
69
|
|
64
70
|
# Returns the model objects that belong to this model.
|
65
71
|
def children
|
66
|
-
models = tests + tags
|
72
|
+
models = rules + tests + tags
|
67
73
|
models << background if background
|
68
74
|
|
69
75
|
models
|
@@ -79,6 +85,7 @@ module CukeModeler
|
|
79
85
|
text << "\n" + description_output_string unless (description.nil? || description.empty?)
|
80
86
|
text << "\n\n" + background_output_string if background
|
81
87
|
text << "\n\n" + tests_output_string unless tests.empty?
|
88
|
+
text << "\n\n" + rules_output_string unless rules.empty?
|
82
89
|
|
83
90
|
text
|
84
91
|
end
|
@@ -94,14 +101,18 @@ module CukeModeler
|
|
94
101
|
end
|
95
102
|
|
96
103
|
def background_output_string
|
97
|
-
|
104
|
+
child_element_output_string(background)
|
98
105
|
end
|
99
106
|
|
100
107
|
def tests_output_string
|
101
|
-
tests.collect { |test|
|
108
|
+
tests.collect { |test| child_element_output_string(test) }.join("\n\n")
|
109
|
+
end
|
110
|
+
|
111
|
+
def rules_output_string
|
112
|
+
rules.collect { |rule| child_element_output_string(rule) }.join("\n\n")
|
102
113
|
end
|
103
114
|
|
104
|
-
def
|
115
|
+
def child_element_output_string(model)
|
105
116
|
model.to_s.split("\n").collect { |line| line.empty? ? '' : " #{line}" }.join("\n")
|
106
117
|
end
|
107
118
|
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module CukeModeler
|
2
|
+
|
3
|
+
# A class modeling a rule in a Cucumber suite.
|
4
|
+
|
5
|
+
class Rule < Model
|
6
|
+
|
7
|
+
include Parsing
|
8
|
+
include Parsed
|
9
|
+
include Named
|
10
|
+
include Described
|
11
|
+
include Sourceable
|
12
|
+
|
13
|
+
|
14
|
+
# The keyword for the rule
|
15
|
+
attr_accessor :keyword
|
16
|
+
|
17
|
+
# The Background object contained by the Rule
|
18
|
+
attr_accessor :background
|
19
|
+
|
20
|
+
# The Scenario and Outline objects contained by the Rule
|
21
|
+
attr_accessor :tests
|
22
|
+
|
23
|
+
|
24
|
+
# Creates a new Rule object and, if *source_text* is provided, populates the
|
25
|
+
# object.
|
26
|
+
def initialize(source_text = nil)
|
27
|
+
@tests = []
|
28
|
+
|
29
|
+
super(source_text)
|
30
|
+
|
31
|
+
if source_text
|
32
|
+
parsed_rule_data = parse_source(source_text)
|
33
|
+
populate_rule(self, parsed_rule_data)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns *true* if the rule contains a background, *false* otherwise.
|
38
|
+
def has_background?
|
39
|
+
!@background.nil?
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns the scenario models contained in the rule.
|
43
|
+
def scenarios
|
44
|
+
@tests.select { |test| test.is_a? Scenario }
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns the outline models contained in the rule.
|
48
|
+
def outlines
|
49
|
+
@tests.select { |test| test.is_a? Outline }
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns the model objects that belong to this model.
|
53
|
+
def children
|
54
|
+
models = tests
|
55
|
+
models << background if background
|
56
|
+
|
57
|
+
models
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns a string representation of this model. For a rule model,
|
61
|
+
# this will be Gherkin text that is equivalent to the rule being modeled.
|
62
|
+
def to_s
|
63
|
+
text = ''
|
64
|
+
|
65
|
+
text << "#{@keyword}:#{name_output_string}"
|
66
|
+
text << "\n" + description_output_string unless (description.nil? || description.empty?)
|
67
|
+
text << "\n\n" + background_output_string if background
|
68
|
+
text << "\n\n" + tests_output_string unless tests.empty?
|
69
|
+
|
70
|
+
text
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
|
77
|
+
def parse_source(source_text)
|
78
|
+
base_file_string = "# language: #{Parsing.dialect}\n#{dialect_feature_keyword}: Fake feature to parse\n"
|
79
|
+
source_text = base_file_string + source_text
|
80
|
+
|
81
|
+
parsed_file = Parsing::parse_text(source_text, 'cuke_modeler_stand_alone_rule.feature')
|
82
|
+
|
83
|
+
parsed_file['feature']['elements'].first
|
84
|
+
end
|
85
|
+
|
86
|
+
def background_output_string
|
87
|
+
test_output_string(background)
|
88
|
+
end
|
89
|
+
|
90
|
+
def tests_output_string
|
91
|
+
tests.collect { |test| test_output_string(test) }.join("\n\n")
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_output_string(model)
|
95
|
+
model.to_s.split("\n").collect { |line| line.empty? ? '' : " #{line}" }.join("\n")
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
data/lib/cuke_modeler/version.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
Feature: Feature modeling
|
2
2
|
|
3
|
-
Feature models are the top level element of the
|
3
|
+
Feature models are the top level element of the Gherkin portion of the model tree. They expose several attributes of the
|
4
|
+
feature that they represent, as well as containing models for any background, scenarios, or outlines that are present in
|
5
|
+
that feature.
|
4
6
|
|
5
7
|
|
6
8
|
Background:
|
@@ -29,11 +31,18 @@ Feature models are the top level element of the gherkin portion of the model tre
|
|
29
31
|
Scenario: Scenario 2
|
30
32
|
* a step
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
Rule: a rule
|
35
|
+
|
36
|
+
Scenario: Scenario 3
|
37
|
+
* a step
|
38
|
+
|
39
|
+
Rule: another rule
|
40
|
+
|
41
|
+
Scenario Outline: Outline 2
|
42
|
+
* a step
|
43
|
+
Examples:
|
44
|
+
| param |
|
45
|
+
| value |
|
37
46
|
"""
|
38
47
|
And a feature model based on that gherkin
|
39
48
|
"""
|
@@ -75,7 +84,18 @@ Feature models are the top level element of the gherkin portion of the model tre
|
|
75
84
|
"""
|
76
85
|
Then the model returns a model for the background "The background"
|
77
86
|
|
87
|
+
Scenario: Modeling a feature's rules
|
88
|
+
When the feature's rules are requested
|
89
|
+
"""
|
90
|
+
@model.rules
|
91
|
+
"""
|
92
|
+
Then the model returns models for the following rules:
|
93
|
+
| a rule |
|
94
|
+
| another rule |
|
95
|
+
|
78
96
|
Scenario: Modeling a feature's scenarios
|
97
|
+
Note: Scenarios under a Rule keyword are included in the corresponding Rule model instead of the Feature model
|
98
|
+
|
79
99
|
When the feature's scenarios are requested
|
80
100
|
"""
|
81
101
|
@model.scenarios
|
@@ -85,13 +105,14 @@ Feature models are the top level element of the gherkin portion of the model tre
|
|
85
105
|
| Scenario 2 |
|
86
106
|
|
87
107
|
Scenario: Modeling a feature's outlines
|
108
|
+
Note: Outlines under a Rule keyword are included in the corresponding Rule model instead of the Feature model
|
109
|
+
|
88
110
|
When the feature's outlines are requested
|
89
111
|
"""
|
90
112
|
@model.outlines
|
91
113
|
"""
|
92
114
|
Then the model returns models for the following outlines:
|
93
115
|
| Outline 1 |
|
94
|
-
| Outline 2 |
|
95
116
|
|
96
117
|
Scenario: Modeling a feature's tags
|
97
118
|
|
@@ -11,23 +11,28 @@ Feature: Feature output
|
|
11
11
|
Feature: A feature with everything it could have
|
12
12
|
Including a description
|
13
13
|
and then some.
|
14
|
-
Background:
|
14
|
+
Background: non-nested background
|
15
15
|
Background
|
16
16
|
description
|
17
17
|
* a step
|
18
18
|
|value1|
|
19
|
+
|value2|
|
19
20
|
* another step
|
20
21
|
@scenario_tag
|
21
|
-
Scenario:
|
22
|
+
Scenario: non-nested scenario
|
22
23
|
Scenario
|
23
24
|
description
|
24
25
|
* a step
|
25
26
|
* another step
|
26
|
-
\"\"\"
|
27
|
+
\"\"\" with content type
|
27
28
|
some text
|
28
29
|
\"\"\"
|
30
|
+
Rule: a rule
|
31
|
+
Rule description
|
32
|
+
Background: nested background
|
33
|
+
* a step
|
29
34
|
@outline_tag
|
30
|
-
Scenario Outline:
|
35
|
+
Scenario Outline: nested outline
|
31
36
|
Outline
|
32
37
|
description
|
33
38
|
* a step
|
@@ -42,6 +47,9 @@ Feature: Feature output
|
|
42
47
|
description
|
43
48
|
|param|
|
44
49
|
|value|
|
50
|
+
Examples: additional example
|
51
|
+
Rule: another rule
|
52
|
+
Which is empty
|
45
53
|
"""
|
46
54
|
And a feature model based on that gherkin
|
47
55
|
"""
|
@@ -59,48 +67,62 @@ Feature: Feature output
|
|
59
67
|
Including a description
|
60
68
|
and then some.
|
61
69
|
|
62
|
-
Background:
|
70
|
+
Background: non-nested background
|
63
71
|
|
64
72
|
Background
|
65
73
|
description
|
66
74
|
|
67
75
|
* a step
|
68
76
|
| value1 |
|
77
|
+
| value2 |
|
69
78
|
* another step
|
70
79
|
|
71
80
|
@scenario_tag
|
72
|
-
Scenario:
|
81
|
+
Scenario: non-nested scenario
|
73
82
|
|
74
83
|
Scenario
|
75
84
|
description
|
76
85
|
|
77
86
|
* a step
|
78
87
|
* another step
|
79
|
-
\"\"\"
|
88
|
+
\"\"\" with content type
|
80
89
|
some text
|
81
90
|
\"\"\"
|
82
91
|
|
83
|
-
|
84
|
-
Scenario Outline:
|
92
|
+
Rule: a rule
|
85
93
|
|
86
|
-
|
87
|
-
description
|
94
|
+
Rule description
|
88
95
|
|
89
|
-
|
90
|
-
|
91
|
-
* another step
|
92
|
-
\"\"\"
|
93
|
-
some text
|
94
|
-
\"\"\"
|
96
|
+
Background: nested background
|
97
|
+
* a step
|
95
98
|
|
96
|
-
|
97
|
-
|
99
|
+
@outline_tag
|
100
|
+
Scenario Outline: nested outline
|
98
101
|
|
99
|
-
|
100
|
-
|
102
|
+
Outline
|
103
|
+
description
|
104
|
+
|
105
|
+
* a step
|
106
|
+
| value2 |
|
107
|
+
* another step
|
108
|
+
\"\"\"
|
109
|
+
some text
|
110
|
+
\"\"\"
|
111
|
+
|
112
|
+
@example_tag
|
113
|
+
Examples:
|
114
|
+
|
115
|
+
Example
|
116
|
+
description
|
117
|
+
|
118
|
+
| param |
|
119
|
+
| value |
|
120
|
+
|
121
|
+
Examples: additional example
|
122
|
+
|
123
|
+
Rule: another rule
|
101
124
|
|
102
|
-
|
103
|
-
| value |
|
125
|
+
Which is empty
|
104
126
|
"""
|
105
127
|
And the output can be used to make an equivalent model
|
106
128
|
"""
|
@@ -0,0 +1,108 @@
|
|
1
|
+
Feature: Rule modeling
|
2
|
+
|
3
|
+
Rule models Scenario portion of a feature. They expose several attributes of the rule that they represent, as well as
|
4
|
+
containing models for any background, scenarios, or outlines that are present in that rule.
|
5
|
+
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given the following gherkin:
|
9
|
+
"""
|
10
|
+
Rule: Rule Foo
|
11
|
+
|
12
|
+
Some rule description.
|
13
|
+
|
14
|
+
Some more.
|
15
|
+
And some more.
|
16
|
+
|
17
|
+
Background: The background
|
18
|
+
* some setup step
|
19
|
+
|
20
|
+
Scenario: Scenario 1
|
21
|
+
* a step
|
22
|
+
|
23
|
+
Scenario Outline: Outline 1
|
24
|
+
* a step
|
25
|
+
Examples:
|
26
|
+
| param |
|
27
|
+
| value |
|
28
|
+
|
29
|
+
Scenario: Scenario 2
|
30
|
+
* a step
|
31
|
+
"""
|
32
|
+
And a feature model based on that gherkin
|
33
|
+
"""
|
34
|
+
@model = CukeModeler::Rule.new(<source_text>)
|
35
|
+
"""
|
36
|
+
|
37
|
+
|
38
|
+
Scenario: Modeling a rule's keyword
|
39
|
+
When the rule's keyword is requested
|
40
|
+
"""
|
41
|
+
@model.keyword
|
42
|
+
"""
|
43
|
+
Then the model returns "Rule"
|
44
|
+
|
45
|
+
Scenario: Modeling a rule's name
|
46
|
+
When the rule's name is requested
|
47
|
+
"""
|
48
|
+
@model.name
|
49
|
+
"""
|
50
|
+
Then the model returns "Rule Foo"
|
51
|
+
|
52
|
+
Scenario: Modeling a rule's description
|
53
|
+
When the rule's description is requested
|
54
|
+
"""
|
55
|
+
@model.description
|
56
|
+
"""
|
57
|
+
Then the model returns
|
58
|
+
"""
|
59
|
+
Some rule description.
|
60
|
+
|
61
|
+
Some more.
|
62
|
+
And some more.
|
63
|
+
"""
|
64
|
+
|
65
|
+
Scenario: Modeling a rule's background
|
66
|
+
When the rule's background is requested
|
67
|
+
"""
|
68
|
+
@model.background
|
69
|
+
"""
|
70
|
+
Then the model returns a model for the background "The background"
|
71
|
+
|
72
|
+
Scenario: Modeling a rule's scenarios
|
73
|
+
When the rule's scenarios are requested
|
74
|
+
"""
|
75
|
+
@model.scenarios
|
76
|
+
"""
|
77
|
+
Then the model returns models for the following scenarios:
|
78
|
+
| Scenario 1 |
|
79
|
+
| Scenario 2 |
|
80
|
+
|
81
|
+
Scenario: Modeling a rule's outlines
|
82
|
+
When the rule's outlines are requested
|
83
|
+
"""
|
84
|
+
@model.outlines
|
85
|
+
"""
|
86
|
+
Then the model returns models for the following outlines:
|
87
|
+
| Outline 1 |
|
88
|
+
|
89
|
+
Scenario: Modeling a rule's source line
|
90
|
+
Given the following gherkin:
|
91
|
+
"""
|
92
|
+
Feature:
|
93
|
+
|
94
|
+
Rule:
|
95
|
+
"""
|
96
|
+
And a feature model based on that gherkin
|
97
|
+
"""
|
98
|
+
@model = CukeModeler::Feature.new(<source_text>)
|
99
|
+
"""
|
100
|
+
And the rule model of that feature model
|
101
|
+
"""
|
102
|
+
@model = @model.rules.first
|
103
|
+
"""
|
104
|
+
When the rule's source line is requested
|
105
|
+
"""
|
106
|
+
@model.source_line
|
107
|
+
"""
|
108
|
+
Then the model returns "3"
|
@@ -0,0 +1,111 @@
|
|
1
|
+
Feature: Rule output
|
2
|
+
|
3
|
+
A rule model's string output is a Gherkin representation of itself. As such, output from a rule model can be used as
|
4
|
+
input for the same kind of model.
|
5
|
+
|
6
|
+
|
7
|
+
Scenario: Outputting a rule model
|
8
|
+
Given the following gherkin:
|
9
|
+
"""
|
10
|
+
Rule: A rule with everything it could have
|
11
|
+
Including a description
|
12
|
+
and then some.
|
13
|
+
Background: a background
|
14
|
+
Background
|
15
|
+
description
|
16
|
+
* a step
|
17
|
+
|value1|
|
18
|
+
|value2|
|
19
|
+
* another step
|
20
|
+
@scenario_tag
|
21
|
+
Scenario: a scenario
|
22
|
+
Scenario
|
23
|
+
description
|
24
|
+
* a step
|
25
|
+
* another step
|
26
|
+
\"\"\" with content type
|
27
|
+
some text
|
28
|
+
\"\"\"
|
29
|
+
@outline_tag
|
30
|
+
Scenario Outline: an outline
|
31
|
+
Outline
|
32
|
+
description
|
33
|
+
* a step
|
34
|
+
|value2|
|
35
|
+
* another step
|
36
|
+
\"\"\"
|
37
|
+
some text
|
38
|
+
\"\"\"
|
39
|
+
@example_tag
|
40
|
+
Examples:
|
41
|
+
Example
|
42
|
+
description
|
43
|
+
|param|
|
44
|
+
|value|
|
45
|
+
Examples: additional example
|
46
|
+
"""
|
47
|
+
And a rule model based on that gherkin
|
48
|
+
"""
|
49
|
+
@model = CukeModeler::Rule.new(<source_text>)
|
50
|
+
"""
|
51
|
+
When the model is output as a string
|
52
|
+
"""
|
53
|
+
@model.to_s
|
54
|
+
"""
|
55
|
+
Then the following text is provided:
|
56
|
+
"""
|
57
|
+
Rule: A rule with everything it could have
|
58
|
+
|
59
|
+
Including a description
|
60
|
+
and then some.
|
61
|
+
|
62
|
+
Background: a background
|
63
|
+
|
64
|
+
Background
|
65
|
+
description
|
66
|
+
|
67
|
+
* a step
|
68
|
+
| value1 |
|
69
|
+
| value2 |
|
70
|
+
* another step
|
71
|
+
|
72
|
+
@scenario_tag
|
73
|
+
Scenario: a scenario
|
74
|
+
|
75
|
+
Scenario
|
76
|
+
description
|
77
|
+
|
78
|
+
* a step
|
79
|
+
* another step
|
80
|
+
\"\"\" with content type
|
81
|
+
some text
|
82
|
+
\"\"\"
|
83
|
+
|
84
|
+
@outline_tag
|
85
|
+
Scenario Outline: an outline
|
86
|
+
|
87
|
+
Outline
|
88
|
+
description
|
89
|
+
|
90
|
+
* a step
|
91
|
+
| value2 |
|
92
|
+
* another step
|
93
|
+
\"\"\"
|
94
|
+
some text
|
95
|
+
\"\"\"
|
96
|
+
|
97
|
+
@example_tag
|
98
|
+
Examples:
|
99
|
+
|
100
|
+
Example
|
101
|
+
description
|
102
|
+
|
103
|
+
| param |
|
104
|
+
| value |
|
105
|
+
|
106
|
+
Examples: additional example
|
107
|
+
"""
|
108
|
+
And the output can be used to make an equivalent model
|
109
|
+
"""
|
110
|
+
CukeModeler::Rule.new(@model.to_s)
|
111
|
+
"""
|
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: 3.
|
4
|
+
version: 3.2.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: 2020-
|
11
|
+
date: 2020-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber-gherkin
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- lib/cuke_modeler/models/model.rb
|
188
188
|
- lib/cuke_modeler/models/outline.rb
|
189
189
|
- lib/cuke_modeler/models/row.rb
|
190
|
+
- lib/cuke_modeler/models/rule.rb
|
190
191
|
- lib/cuke_modeler/models/scenario.rb
|
191
192
|
- lib/cuke_modeler/models/step.rb
|
192
193
|
- lib/cuke_modeler/models/table.rb
|
@@ -223,6 +224,8 @@ files:
|
|
223
224
|
- testing/cucumber/features/modeling/outline_output.feature
|
224
225
|
- testing/cucumber/features/modeling/row_modeling.feature
|
225
226
|
- testing/cucumber/features/modeling/row_output.feature
|
227
|
+
- testing/cucumber/features/modeling/rule_modeling.feature
|
228
|
+
- testing/cucumber/features/modeling/rule_output.feature
|
226
229
|
- testing/cucumber/features/modeling/scenario_modeling.feature
|
227
230
|
- testing/cucumber/features/modeling/scenario_output.feature
|
228
231
|
- testing/cucumber/features/modeling/step_modeling.feature
|