cuke_modeler 3.27.0 → 3.28.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 +579 -572
- data/LICENSE.txt +22 -22
- data/README.md +135 -135
- data/cuke_modeler.gemspec +59 -59
- data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_14_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_15_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_16_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_17_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_18_adapter.rb +27 -27
- data/lib/cuke_modeler/adapters/gherkin_19_adapter.rb +64 -64
- data/lib/cuke_modeler/adapters/gherkin_20_adapter.rb +359 -359
- data/lib/cuke_modeler/adapters/gherkin_21_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_22_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_23_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_24_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_25_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_26_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_27_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_28_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_29_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_30_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_31_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_32_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_33_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_34_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_35_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_36_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_37_adapter.rb +13 -13
- data/lib/cuke_modeler/adapters/gherkin_38_adapter.rb +13 -0
- data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +375 -375
- data/lib/cuke_modeler/adapters/gherkin_base_adapter.rb +17 -17
- data/lib/cuke_modeler/containing.rb +105 -105
- data/lib/cuke_modeler/described.rb +71 -71
- data/lib/cuke_modeler/models/background.rb +122 -122
- data/lib/cuke_modeler/models/cell.rb +88 -88
- data/lib/cuke_modeler/models/comment.rb +82 -82
- data/lib/cuke_modeler/models/directory.rb +143 -143
- data/lib/cuke_modeler/models/doc_string.rb +104 -104
- data/lib/cuke_modeler/models/example.rb +274 -274
- data/lib/cuke_modeler/models/feature.rb +200 -200
- data/lib/cuke_modeler/models/feature_file.rb +116 -116
- data/lib/cuke_modeler/models/model.rb +87 -87
- data/lib/cuke_modeler/models/outline.rb +145 -145
- data/lib/cuke_modeler/models/row.rb +104 -104
- data/lib/cuke_modeler/models/rule.rb +162 -162
- data/lib/cuke_modeler/models/scenario.rb +128 -128
- data/lib/cuke_modeler/models/step.rb +178 -178
- data/lib/cuke_modeler/models/table.rb +117 -117
- data/lib/cuke_modeler/models/tag.rb +75 -75
- data/lib/cuke_modeler/named.rb +26 -26
- data/lib/cuke_modeler/nested.rb +61 -61
- data/lib/cuke_modeler/parsed.rb +24 -24
- data/lib/cuke_modeler/parsing.rb +208 -208
- data/lib/cuke_modeler/sourceable.rb +29 -29
- data/lib/cuke_modeler/stepped.rb +34 -34
- data/lib/cuke_modeler/taggable.rb +57 -57
- data/lib/cuke_modeler/version.rb +4 -4
- data/lib/cuke_modeler.rb +32 -32
- data/testing/cucumber/features/analysis/step_comparison.feature +25 -25
- data/testing/cucumber/features/analysis/test_comparison.feature +35 -35
- data/testing/cucumber/features/modeling/background_modeling.feature +105 -105
- data/testing/cucumber/features/modeling/background_output.feature +60 -60
- data/testing/cucumber/features/modeling/cell_modeling.feature +68 -68
- data/testing/cucumber/features/modeling/cell_output.feature +36 -36
- data/testing/cucumber/features/modeling/comment_modeling.feature +62 -62
- data/testing/cucumber/features/modeling/comment_output.feature +40 -40
- data/testing/cucumber/features/modeling/directory_modeling.feature +62 -62
- data/testing/cucumber/features/modeling/directory_output.feature +33 -33
- data/testing/cucumber/features/modeling/doc_string_modeling.feature +85 -85
- data/testing/cucumber/features/modeling/doc_string_output.feature +50 -50
- data/testing/cucumber/features/modeling/example_modeling.feature +155 -155
- data/testing/cucumber/features/modeling/example_output.feature +57 -57
- data/testing/cucumber/features/modeling/feature_file_modeling.feature +49 -49
- data/testing/cucumber/features/modeling/feature_file_output.feature +33 -33
- data/testing/cucumber/features/modeling/feature_modeling.feature +149 -149
- data/testing/cucumber/features/modeling/feature_output.feature +144 -144
- data/testing/cucumber/features/modeling/model_output.feature +61 -61
- data/testing/cucumber/features/modeling/model_structure.feature +42 -42
- data/testing/cucumber/features/modeling/outline_modeling.feature +175 -175
- data/testing/cucumber/features/modeling/outline_output.feature +87 -87
- data/testing/cucumber/features/modeling/row_modeling.feature +70 -70
- data/testing/cucumber/features/modeling/row_output.feature +40 -40
- data/testing/cucumber/features/modeling/rule_modeling.feature +171 -171
- data/testing/cucumber/features/modeling/rule_output.feature +136 -136
- data/testing/cucumber/features/modeling/scenario_modeling.feature +146 -146
- data/testing/cucumber/features/modeling/scenario_output.feature +63 -63
- data/testing/cucumber/features/modeling/step_modeling.feature +105 -105
- data/testing/cucumber/features/modeling/step_output.feature +47 -47
- data/testing/cucumber/features/modeling/table_modeling.feature +73 -73
- data/testing/cucumber/features/modeling/table_output.feature +42 -42
- data/testing/cucumber/features/modeling/tag_modeling.feature +62 -62
- data/testing/cucumber/features/modeling/tag_output.feature +40 -40
- metadata +6 -8
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling a rule in a Cucumber suite.
|
|
4
|
-
class Rule < Model
|
|
5
|
-
|
|
6
|
-
include Parsing
|
|
7
|
-
include Parsed
|
|
8
|
-
include Named
|
|
9
|
-
include Described
|
|
10
|
-
include Taggable
|
|
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
|
-
#
|
|
27
|
-
# @example
|
|
28
|
-
# Rule.new
|
|
29
|
-
# Rule.new("Rule:\nThis is a rule")
|
|
30
|
-
#
|
|
31
|
-
# @param source_text [String] The Gherkin text that will be used to populate the model
|
|
32
|
-
# @raise [ArgumentError] If *source_text* is not a String
|
|
33
|
-
# @return [Rule] A new Rule instance
|
|
34
|
-
def initialize(source_text = nil)
|
|
35
|
-
@tags = []
|
|
36
|
-
@tests = []
|
|
37
|
-
|
|
38
|
-
super
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Returns *true* if the rule contains a background, *false* otherwise.
|
|
42
|
-
#
|
|
43
|
-
# @example
|
|
44
|
-
# rule.background?
|
|
45
|
-
#
|
|
46
|
-
# @return [Boolean] Whether the rule contains a background
|
|
47
|
-
def background?
|
|
48
|
-
!@background.nil?
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
alias has_background? background?
|
|
52
|
-
|
|
53
|
-
# Returns the scenario models contained in the rule.
|
|
54
|
-
#
|
|
55
|
-
# @example
|
|
56
|
-
# rule.scenarios
|
|
57
|
-
#
|
|
58
|
-
# @return [Array<Scenario>] Child Scenario models
|
|
59
|
-
def scenarios
|
|
60
|
-
@tests.select { |test| test.is_a? Scenario }
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Returns the outline models contained in the rule.
|
|
64
|
-
#
|
|
65
|
-
# @example
|
|
66
|
-
# rule.outlines
|
|
67
|
-
#
|
|
68
|
-
# @return [Array<Outline>] Child Outline models
|
|
69
|
-
def outlines
|
|
70
|
-
@tests.select { |test| test.is_a? Outline }
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# Returns the model objects that are children of this model. For a
|
|
74
|
-
# Rule model, these would be any associated Background, Scenario,
|
|
75
|
-
# Outline, or Tag models.
|
|
76
|
-
#
|
|
77
|
-
# @example
|
|
78
|
-
# rule.children
|
|
79
|
-
#
|
|
80
|
-
# @return [Array<Background, Scenario, Outline, Tag>] A collection of child models
|
|
81
|
-
def children
|
|
82
|
-
models = tests + tags
|
|
83
|
-
models << background if background
|
|
84
|
-
|
|
85
|
-
models
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
# Returns a string representation of this model. For a Rule model,
|
|
89
|
-
# this will be Gherkin text that is equivalent to the rule being modeled.
|
|
90
|
-
#
|
|
91
|
-
# @example
|
|
92
|
-
# rule.to_s
|
|
93
|
-
#
|
|
94
|
-
# @return [String] A string representation of this model
|
|
95
|
-
def to_s
|
|
96
|
-
text = ''
|
|
97
|
-
|
|
98
|
-
text << "#{tag_output_string}\n" unless tags.empty?
|
|
99
|
-
text << "#{@keyword}:#{name_output_string}"
|
|
100
|
-
text << "\n#{description_output_string}" unless no_description_to_output?
|
|
101
|
-
text << "\n\n#{background_output_string}" if background
|
|
102
|
-
text << "\n\n#{tests_output_string}" unless tests.empty?
|
|
103
|
-
|
|
104
|
-
text
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
# See `Object#inspect`. Returns some basic information about the
|
|
108
|
-
# object, including its class, object ID, and its most meaningful
|
|
109
|
-
# attribute. For a Rule model, this will be the name of the rule.
|
|
110
|
-
# If *verbose* is true, provides default Ruby inspection behavior
|
|
111
|
-
# instead.
|
|
112
|
-
#
|
|
113
|
-
# @example
|
|
114
|
-
# rule.inspect
|
|
115
|
-
# rule.inspect(verbose: true)
|
|
116
|
-
#
|
|
117
|
-
# @param verbose [Boolean] Whether or not to return the full details of
|
|
118
|
-
# the object. Defaults to false.
|
|
119
|
-
# @return [String] A string representation of this model
|
|
120
|
-
def inspect(verbose: false)
|
|
121
|
-
return super if verbose
|
|
122
|
-
|
|
123
|
-
"#{super.chop} @name: #{@name.inspect}>"
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
private
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def process_source(source_text)
|
|
131
|
-
base_file_string = "# language: #{Parsing.dialect}\n#{dialect_feature_keyword}: Fake feature to parse\n"
|
|
132
|
-
source_text = base_file_string + source_text
|
|
133
|
-
|
|
134
|
-
parsed_file = Parsing.parse_text(source_text, 'cuke_modeler_stand_alone_rule.feature')
|
|
135
|
-
|
|
136
|
-
parsed_file['feature']['elements'].first
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def populate_model(parsed_rule_data)
|
|
140
|
-
populate_parsing_data(parsed_rule_data)
|
|
141
|
-
populate_source_location(parsed_rule_data)
|
|
142
|
-
populate_keyword(parsed_rule_data)
|
|
143
|
-
populate_name(parsed_rule_data)
|
|
144
|
-
populate_description(parsed_rule_data)
|
|
145
|
-
populate_tags(parsed_rule_data)
|
|
146
|
-
populate_children(parsed_rule_data)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def background_output_string
|
|
150
|
-
test_output_string(background)
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def tests_output_string
|
|
154
|
-
tests.collect { |test| test_output_string(test) }.join("\n\n")
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def test_output_string(model)
|
|
158
|
-
model.to_s.split("\n").collect { |line| line.empty? ? '' : " #{line}" }.join("\n")
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
end
|
|
162
|
-
end
|
|
1
|
+
module CukeModeler
|
|
2
|
+
|
|
3
|
+
# A class modeling a rule in a Cucumber suite.
|
|
4
|
+
class Rule < Model
|
|
5
|
+
|
|
6
|
+
include Parsing
|
|
7
|
+
include Parsed
|
|
8
|
+
include Named
|
|
9
|
+
include Described
|
|
10
|
+
include Taggable
|
|
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
|
+
#
|
|
27
|
+
# @example
|
|
28
|
+
# Rule.new
|
|
29
|
+
# Rule.new("Rule:\nThis is a rule")
|
|
30
|
+
#
|
|
31
|
+
# @param source_text [String] The Gherkin text that will be used to populate the model
|
|
32
|
+
# @raise [ArgumentError] If *source_text* is not a String
|
|
33
|
+
# @return [Rule] A new Rule instance
|
|
34
|
+
def initialize(source_text = nil)
|
|
35
|
+
@tags = []
|
|
36
|
+
@tests = []
|
|
37
|
+
|
|
38
|
+
super
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Returns *true* if the rule contains a background, *false* otherwise.
|
|
42
|
+
#
|
|
43
|
+
# @example
|
|
44
|
+
# rule.background?
|
|
45
|
+
#
|
|
46
|
+
# @return [Boolean] Whether the rule contains a background
|
|
47
|
+
def background?
|
|
48
|
+
!@background.nil?
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
alias has_background? background?
|
|
52
|
+
|
|
53
|
+
# Returns the scenario models contained in the rule.
|
|
54
|
+
#
|
|
55
|
+
# @example
|
|
56
|
+
# rule.scenarios
|
|
57
|
+
#
|
|
58
|
+
# @return [Array<Scenario>] Child Scenario models
|
|
59
|
+
def scenarios
|
|
60
|
+
@tests.select { |test| test.is_a? Scenario }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Returns the outline models contained in the rule.
|
|
64
|
+
#
|
|
65
|
+
# @example
|
|
66
|
+
# rule.outlines
|
|
67
|
+
#
|
|
68
|
+
# @return [Array<Outline>] Child Outline models
|
|
69
|
+
def outlines
|
|
70
|
+
@tests.select { |test| test.is_a? Outline }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Returns the model objects that are children of this model. For a
|
|
74
|
+
# Rule model, these would be any associated Background, Scenario,
|
|
75
|
+
# Outline, or Tag models.
|
|
76
|
+
#
|
|
77
|
+
# @example
|
|
78
|
+
# rule.children
|
|
79
|
+
#
|
|
80
|
+
# @return [Array<Background, Scenario, Outline, Tag>] A collection of child models
|
|
81
|
+
def children
|
|
82
|
+
models = tests + tags
|
|
83
|
+
models << background if background
|
|
84
|
+
|
|
85
|
+
models
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Returns a string representation of this model. For a Rule model,
|
|
89
|
+
# this will be Gherkin text that is equivalent to the rule being modeled.
|
|
90
|
+
#
|
|
91
|
+
# @example
|
|
92
|
+
# rule.to_s
|
|
93
|
+
#
|
|
94
|
+
# @return [String] A string representation of this model
|
|
95
|
+
def to_s
|
|
96
|
+
text = ''
|
|
97
|
+
|
|
98
|
+
text << "#{tag_output_string}\n" unless tags.empty?
|
|
99
|
+
text << "#{@keyword}:#{name_output_string}"
|
|
100
|
+
text << "\n#{description_output_string}" unless no_description_to_output?
|
|
101
|
+
text << "\n\n#{background_output_string}" if background
|
|
102
|
+
text << "\n\n#{tests_output_string}" unless tests.empty?
|
|
103
|
+
|
|
104
|
+
text
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# See `Object#inspect`. Returns some basic information about the
|
|
108
|
+
# object, including its class, object ID, and its most meaningful
|
|
109
|
+
# attribute. For a Rule model, this will be the name of the rule.
|
|
110
|
+
# If *verbose* is true, provides default Ruby inspection behavior
|
|
111
|
+
# instead.
|
|
112
|
+
#
|
|
113
|
+
# @example
|
|
114
|
+
# rule.inspect
|
|
115
|
+
# rule.inspect(verbose: true)
|
|
116
|
+
#
|
|
117
|
+
# @param verbose [Boolean] Whether or not to return the full details of
|
|
118
|
+
# the object. Defaults to false.
|
|
119
|
+
# @return [String] A string representation of this model
|
|
120
|
+
def inspect(verbose: false)
|
|
121
|
+
return super if verbose
|
|
122
|
+
|
|
123
|
+
"#{super.chop} @name: #{@name.inspect}>"
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
private
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def process_source(source_text)
|
|
131
|
+
base_file_string = "# language: #{Parsing.dialect}\n#{dialect_feature_keyword}: Fake feature to parse\n"
|
|
132
|
+
source_text = base_file_string + source_text
|
|
133
|
+
|
|
134
|
+
parsed_file = Parsing.parse_text(source_text, 'cuke_modeler_stand_alone_rule.feature')
|
|
135
|
+
|
|
136
|
+
parsed_file['feature']['elements'].first
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def populate_model(parsed_rule_data)
|
|
140
|
+
populate_parsing_data(parsed_rule_data)
|
|
141
|
+
populate_source_location(parsed_rule_data)
|
|
142
|
+
populate_keyword(parsed_rule_data)
|
|
143
|
+
populate_name(parsed_rule_data)
|
|
144
|
+
populate_description(parsed_rule_data)
|
|
145
|
+
populate_tags(parsed_rule_data)
|
|
146
|
+
populate_children(parsed_rule_data)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def background_output_string
|
|
150
|
+
test_output_string(background)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def tests_output_string
|
|
154
|
+
tests.collect { |test| test_output_string(test) }.join("\n\n")
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def test_output_string(model)
|
|
158
|
+
model.to_s.split("\n").collect { |line| line.empty? ? '' : " #{line}" }.join("\n")
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
end
|
|
162
|
+
end
|
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling an individual scenario of a Cucumber suite.
|
|
4
|
-
class Scenario < Model
|
|
5
|
-
|
|
6
|
-
include Parsing
|
|
7
|
-
include Parsed
|
|
8
|
-
include Named
|
|
9
|
-
include Described
|
|
10
|
-
include Stepped
|
|
11
|
-
include Sourceable
|
|
12
|
-
include Taggable
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# The scenario's keyword
|
|
16
|
-
attr_accessor :keyword
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
# Creates a new Scenario object and, if *source_text* is provided, populates the
|
|
20
|
-
# object.
|
|
21
|
-
#
|
|
22
|
-
# @example
|
|
23
|
-
# Scenario.new
|
|
24
|
-
# Scenario.new("Scenario:\n * a step")
|
|
25
|
-
#
|
|
26
|
-
# @param source_text [String] The Gherkin text that will be used to populate the model
|
|
27
|
-
# @raise [ArgumentError] If *source_text* is not a String
|
|
28
|
-
# @return [Scenario] A new Scenario instance
|
|
29
|
-
def initialize(source_text = nil)
|
|
30
|
-
@steps = []
|
|
31
|
-
@tags = []
|
|
32
|
-
|
|
33
|
-
super
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Compares this model with another object. Returns *true* if the two objects
|
|
37
|
-
# have equivalent steps and *false* otherwise.
|
|
38
|
-
#
|
|
39
|
-
# @example
|
|
40
|
-
# scenario_1 == scenario_2
|
|
41
|
-
#
|
|
42
|
-
# @param other [Object] The object to compare this model with
|
|
43
|
-
# @return [Boolean] Whether the two objects are equivalent
|
|
44
|
-
def ==(other)
|
|
45
|
-
return false unless other.respond_to?(:steps)
|
|
46
|
-
|
|
47
|
-
steps == other.steps
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Returns the model objects that are children of this model. For a
|
|
51
|
-
# Scenario model, these would be any associated Step or Tag models.
|
|
52
|
-
#
|
|
53
|
-
# @example
|
|
54
|
-
# scenario.children
|
|
55
|
-
#
|
|
56
|
-
# @return [Array<Step, Tag>] A collection of child models
|
|
57
|
-
def children
|
|
58
|
-
steps + tags
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Building strings just isn't pretty
|
|
62
|
-
# rubocop:disable Metrics/AbcSize
|
|
63
|
-
|
|
64
|
-
# Returns a string representation of this model. For a Scenario model,
|
|
65
|
-
# this will be Gherkin text that is equivalent to the scenario being modeled.
|
|
66
|
-
#
|
|
67
|
-
# @example
|
|
68
|
-
# scenario.to_s
|
|
69
|
-
#
|
|
70
|
-
# @return [String] A string representation of this model
|
|
71
|
-
def to_s
|
|
72
|
-
text = ''
|
|
73
|
-
|
|
74
|
-
text << "#{tag_output_string}\n" unless tags.empty?
|
|
75
|
-
text << "#{@keyword}:#{name_output_string}"
|
|
76
|
-
text << "\n#{description_output_string}" unless no_description_to_output?
|
|
77
|
-
text << "\n" unless steps.empty? || no_description_to_output?
|
|
78
|
-
text << "\n#{steps_output_string}" unless steps.empty?
|
|
79
|
-
|
|
80
|
-
text
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# rubocop:enable Metrics/AbcSize
|
|
84
|
-
|
|
85
|
-
# See `Object#inspect`. Returns some basic information about the
|
|
86
|
-
# object, including its class, object ID, and its most meaningful
|
|
87
|
-
# attribute. For a Scenario model, this will be the name of the
|
|
88
|
-
# scenario. If *verbose* is true, provides default Ruby inspection
|
|
89
|
-
# behavior instead.
|
|
90
|
-
#
|
|
91
|
-
# @example
|
|
92
|
-
# scenario.inspect
|
|
93
|
-
# scenario.inspect(verbose: true)
|
|
94
|
-
#
|
|
95
|
-
# @param verbose [Boolean] Whether or not to return the full details of
|
|
96
|
-
# the object. Defaults to false.
|
|
97
|
-
# @return [String] A string representation of this model
|
|
98
|
-
def inspect(verbose: false)
|
|
99
|
-
return super if verbose
|
|
100
|
-
|
|
101
|
-
"#{super.chop} @name: #{name.inspect}>"
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
private
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def process_source(source_text)
|
|
109
|
-
base_file_string = "# language: #{Parsing.dialect}\n#{dialect_feature_keyword}: Fake feature to parse\n"
|
|
110
|
-
source_text = base_file_string + source_text
|
|
111
|
-
|
|
112
|
-
parsed_file = Parsing.parse_text(source_text, 'cuke_modeler_stand_alone_scenario.feature')
|
|
113
|
-
|
|
114
|
-
parsed_file['feature']['elements'].first
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def populate_model(parsed_scenario_data)
|
|
118
|
-
populate_parsing_data(parsed_scenario_data)
|
|
119
|
-
populate_source_location(parsed_scenario_data)
|
|
120
|
-
populate_keyword(parsed_scenario_data)
|
|
121
|
-
populate_name(parsed_scenario_data)
|
|
122
|
-
populate_description(parsed_scenario_data)
|
|
123
|
-
populate_steps(parsed_scenario_data)
|
|
124
|
-
populate_tags(parsed_scenario_data)
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
end
|
|
128
|
-
end
|
|
1
|
+
module CukeModeler
|
|
2
|
+
|
|
3
|
+
# A class modeling an individual scenario of a Cucumber suite.
|
|
4
|
+
class Scenario < Model
|
|
5
|
+
|
|
6
|
+
include Parsing
|
|
7
|
+
include Parsed
|
|
8
|
+
include Named
|
|
9
|
+
include Described
|
|
10
|
+
include Stepped
|
|
11
|
+
include Sourceable
|
|
12
|
+
include Taggable
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# The scenario's keyword
|
|
16
|
+
attr_accessor :keyword
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Creates a new Scenario object and, if *source_text* is provided, populates the
|
|
20
|
+
# object.
|
|
21
|
+
#
|
|
22
|
+
# @example
|
|
23
|
+
# Scenario.new
|
|
24
|
+
# Scenario.new("Scenario:\n * a step")
|
|
25
|
+
#
|
|
26
|
+
# @param source_text [String] The Gherkin text that will be used to populate the model
|
|
27
|
+
# @raise [ArgumentError] If *source_text* is not a String
|
|
28
|
+
# @return [Scenario] A new Scenario instance
|
|
29
|
+
def initialize(source_text = nil)
|
|
30
|
+
@steps = []
|
|
31
|
+
@tags = []
|
|
32
|
+
|
|
33
|
+
super
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Compares this model with another object. Returns *true* if the two objects
|
|
37
|
+
# have equivalent steps and *false* otherwise.
|
|
38
|
+
#
|
|
39
|
+
# @example
|
|
40
|
+
# scenario_1 == scenario_2
|
|
41
|
+
#
|
|
42
|
+
# @param other [Object] The object to compare this model with
|
|
43
|
+
# @return [Boolean] Whether the two objects are equivalent
|
|
44
|
+
def ==(other)
|
|
45
|
+
return false unless other.respond_to?(:steps)
|
|
46
|
+
|
|
47
|
+
steps == other.steps
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Returns the model objects that are children of this model. For a
|
|
51
|
+
# Scenario model, these would be any associated Step or Tag models.
|
|
52
|
+
#
|
|
53
|
+
# @example
|
|
54
|
+
# scenario.children
|
|
55
|
+
#
|
|
56
|
+
# @return [Array<Step, Tag>] A collection of child models
|
|
57
|
+
def children
|
|
58
|
+
steps + tags
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Building strings just isn't pretty
|
|
62
|
+
# rubocop:disable Metrics/AbcSize
|
|
63
|
+
|
|
64
|
+
# Returns a string representation of this model. For a Scenario model,
|
|
65
|
+
# this will be Gherkin text that is equivalent to the scenario being modeled.
|
|
66
|
+
#
|
|
67
|
+
# @example
|
|
68
|
+
# scenario.to_s
|
|
69
|
+
#
|
|
70
|
+
# @return [String] A string representation of this model
|
|
71
|
+
def to_s
|
|
72
|
+
text = ''
|
|
73
|
+
|
|
74
|
+
text << "#{tag_output_string}\n" unless tags.empty?
|
|
75
|
+
text << "#{@keyword}:#{name_output_string}"
|
|
76
|
+
text << "\n#{description_output_string}" unless no_description_to_output?
|
|
77
|
+
text << "\n" unless steps.empty? || no_description_to_output?
|
|
78
|
+
text << "\n#{steps_output_string}" unless steps.empty?
|
|
79
|
+
|
|
80
|
+
text
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# rubocop:enable Metrics/AbcSize
|
|
84
|
+
|
|
85
|
+
# See `Object#inspect`. Returns some basic information about the
|
|
86
|
+
# object, including its class, object ID, and its most meaningful
|
|
87
|
+
# attribute. For a Scenario model, this will be the name of the
|
|
88
|
+
# scenario. If *verbose* is true, provides default Ruby inspection
|
|
89
|
+
# behavior instead.
|
|
90
|
+
#
|
|
91
|
+
# @example
|
|
92
|
+
# scenario.inspect
|
|
93
|
+
# scenario.inspect(verbose: true)
|
|
94
|
+
#
|
|
95
|
+
# @param verbose [Boolean] Whether or not to return the full details of
|
|
96
|
+
# the object. Defaults to false.
|
|
97
|
+
# @return [String] A string representation of this model
|
|
98
|
+
def inspect(verbose: false)
|
|
99
|
+
return super if verbose
|
|
100
|
+
|
|
101
|
+
"#{super.chop} @name: #{name.inspect}>"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
private
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def process_source(source_text)
|
|
109
|
+
base_file_string = "# language: #{Parsing.dialect}\n#{dialect_feature_keyword}: Fake feature to parse\n"
|
|
110
|
+
source_text = base_file_string + source_text
|
|
111
|
+
|
|
112
|
+
parsed_file = Parsing.parse_text(source_text, 'cuke_modeler_stand_alone_scenario.feature')
|
|
113
|
+
|
|
114
|
+
parsed_file['feature']['elements'].first
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def populate_model(parsed_scenario_data)
|
|
118
|
+
populate_parsing_data(parsed_scenario_data)
|
|
119
|
+
populate_source_location(parsed_scenario_data)
|
|
120
|
+
populate_keyword(parsed_scenario_data)
|
|
121
|
+
populate_name(parsed_scenario_data)
|
|
122
|
+
populate_description(parsed_scenario_data)
|
|
123
|
+
populate_steps(parsed_scenario_data)
|
|
124
|
+
populate_tags(parsed_scenario_data)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
end
|
|
128
|
+
end
|