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,200 +1,200 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling a feature in a Cucumber suite.
|
|
4
|
-
class Feature < Model
|
|
5
|
-
|
|
6
|
-
include Parsed
|
|
7
|
-
include Named
|
|
8
|
-
include Described
|
|
9
|
-
include Taggable
|
|
10
|
-
include Sourceable
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# The language for the feature
|
|
14
|
-
attr_accessor :language
|
|
15
|
-
|
|
16
|
-
# The keyword for the feature
|
|
17
|
-
attr_accessor :keyword
|
|
18
|
-
|
|
19
|
-
# The Background object contained by the Feature
|
|
20
|
-
attr_accessor :background
|
|
21
|
-
|
|
22
|
-
# The Rule objects contained by the Feature
|
|
23
|
-
attr_accessor :rules
|
|
24
|
-
|
|
25
|
-
# The Scenario and Outline objects contained by the Feature
|
|
26
|
-
attr_accessor :tests
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# Creates a new Feature object and, if *source_text* is provided, populates the
|
|
30
|
-
# object.
|
|
31
|
-
#
|
|
32
|
-
# @example
|
|
33
|
-
# Feature.new
|
|
34
|
-
# Feature.new("Feature:\nThis is a feature")
|
|
35
|
-
#
|
|
36
|
-
# @param source_text [String] The Gherkin text that will be used to populate the model
|
|
37
|
-
# @raise [ArgumentError] If *source_text* is not a String
|
|
38
|
-
# @return [Feature] A new Feature instance
|
|
39
|
-
def initialize(source_text = nil)
|
|
40
|
-
@tags = []
|
|
41
|
-
@rules = []
|
|
42
|
-
@tests = []
|
|
43
|
-
|
|
44
|
-
super
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Returns *true* if the feature contains a background, *false* otherwise.
|
|
48
|
-
#
|
|
49
|
-
# @example
|
|
50
|
-
# feature.background?
|
|
51
|
-
#
|
|
52
|
-
# @return [Boolean] Whether the feature contains a background
|
|
53
|
-
def background?
|
|
54
|
-
!@background.nil?
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
alias has_background? background?
|
|
58
|
-
|
|
59
|
-
# Returns the scenario models contained in the feature.
|
|
60
|
-
#
|
|
61
|
-
# @example
|
|
62
|
-
# feature.scenarios
|
|
63
|
-
#
|
|
64
|
-
# @return [Array<Scenario>] Child Scenario models
|
|
65
|
-
def scenarios
|
|
66
|
-
@tests.select { |test| test.is_a? Scenario }
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Returns the outline models contained in the feature.
|
|
70
|
-
#
|
|
71
|
-
# @example
|
|
72
|
-
# feature.outlines
|
|
73
|
-
#
|
|
74
|
-
# @return [Array<Outline>] Child Outline models
|
|
75
|
-
def outlines
|
|
76
|
-
@tests.select { |test| test.is_a? Outline }
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# TODO: Remove this and other deprecated methods on next major version release
|
|
80
|
-
|
|
81
|
-
# @deprecated See CHANGELOG
|
|
82
|
-
#
|
|
83
|
-
# Returns the number of test cases contained in the feature. A test case is a
|
|
84
|
-
# single set of test values, such as an individual scenario or one example row
|
|
85
|
-
# of an outline.
|
|
86
|
-
#
|
|
87
|
-
# @example
|
|
88
|
-
# feature.test_case_count
|
|
89
|
-
#
|
|
90
|
-
# @return [Integer] The count of test cases
|
|
91
|
-
def test_case_count
|
|
92
|
-
scenarios.count + outlines.reduce(0) do |outline_sum, outline|
|
|
93
|
-
outline_sum + outline.examples.reduce(0) do |example_sum, example|
|
|
94
|
-
example_sum + example.argument_rows.count
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
# Returns the model objects that are children of this model. For a
|
|
100
|
-
# Feature model, these would be any associated Rule, Background,
|
|
101
|
-
# Scenario, Outline, or Tag models.
|
|
102
|
-
#
|
|
103
|
-
# @example
|
|
104
|
-
# feature.children
|
|
105
|
-
#
|
|
106
|
-
# @return [Array<Rule, Background, Scenario, Outline, Tag>] A collection of child models
|
|
107
|
-
def children
|
|
108
|
-
models = rules + tests + tags
|
|
109
|
-
models << background if background
|
|
110
|
-
|
|
111
|
-
models
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
# Building strings just isn't pretty
|
|
115
|
-
# rubocop:disable Metrics/AbcSize
|
|
116
|
-
|
|
117
|
-
# Returns a string representation of this model. For a Feature model,
|
|
118
|
-
# this will be Gherkin text that is equivalent to the feature being modeled.
|
|
119
|
-
#
|
|
120
|
-
# @example
|
|
121
|
-
# feature.to_s
|
|
122
|
-
#
|
|
123
|
-
# @return [String] A string representation of this model
|
|
124
|
-
def to_s
|
|
125
|
-
text = ''
|
|
126
|
-
|
|
127
|
-
text << "#{tag_output_string}\n" unless tags.empty?
|
|
128
|
-
text << "#{@keyword}:#{name_output_string}"
|
|
129
|
-
text << "\n#{description_output_string}" unless no_description_to_output?
|
|
130
|
-
text << "\n\n#{background_output_string}" if background
|
|
131
|
-
text << "\n\n#{tests_output_string}" unless tests.empty?
|
|
132
|
-
text << "\n\n#{rules_output_string}" unless rules.empty?
|
|
133
|
-
|
|
134
|
-
text
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# rubocop:enable Metrics/AbcSize
|
|
138
|
-
|
|
139
|
-
# See `Object#inspect`. Returns some basic information about the
|
|
140
|
-
# object, including its class, object ID, and its most meaningful
|
|
141
|
-
# attribute. For a Feature model, this will be the name of the
|
|
142
|
-
# feature. If *verbose* is true, provides default Ruby inspection
|
|
143
|
-
# behavior instead.
|
|
144
|
-
#
|
|
145
|
-
# @example
|
|
146
|
-
# feature.inspect
|
|
147
|
-
# feature.inspect(verbose: true)
|
|
148
|
-
#
|
|
149
|
-
# @param verbose [Boolean] Whether or not to return the full details of
|
|
150
|
-
# the object. Defaults to false.
|
|
151
|
-
# @return [String] A string representation of this model
|
|
152
|
-
def inspect(verbose: false)
|
|
153
|
-
return super if verbose
|
|
154
|
-
|
|
155
|
-
"#{super.chop} @name: #{name.inspect}>"
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
private
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
def process_source(source_text)
|
|
163
|
-
parsed_file = Parsing.parse_text(source_text, 'cuke_modeler_stand_alone_feature.feature')
|
|
164
|
-
|
|
165
|
-
parsed_file['feature']
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
def populate_model(parsed_feature_data)
|
|
169
|
-
populate_parsing_data(parsed_feature_data)
|
|
170
|
-
populate_source_location(parsed_feature_data)
|
|
171
|
-
populate_language(parsed_feature_data)
|
|
172
|
-
populate_keyword(parsed_feature_data)
|
|
173
|
-
populate_name(parsed_feature_data)
|
|
174
|
-
populate_description(parsed_feature_data)
|
|
175
|
-
populate_tags(parsed_feature_data)
|
|
176
|
-
populate_children(parsed_feature_data)
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
def populate_language(parsed_feature_data)
|
|
180
|
-
@language = parsed_feature_data['language']
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
def background_output_string
|
|
184
|
-
child_element_output_string(background)
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
def tests_output_string
|
|
188
|
-
tests.collect { |test| child_element_output_string(test) }.join("\n\n")
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
def rules_output_string
|
|
192
|
-
rules.collect { |rule| child_element_output_string(rule) }.join("\n\n")
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
def child_element_output_string(model)
|
|
196
|
-
model.to_s.split("\n").collect { |line| line.empty? ? '' : " #{line}" }.join("\n")
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
end
|
|
200
|
-
end
|
|
1
|
+
module CukeModeler
|
|
2
|
+
|
|
3
|
+
# A class modeling a feature in a Cucumber suite.
|
|
4
|
+
class Feature < Model
|
|
5
|
+
|
|
6
|
+
include Parsed
|
|
7
|
+
include Named
|
|
8
|
+
include Described
|
|
9
|
+
include Taggable
|
|
10
|
+
include Sourceable
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# The language for the feature
|
|
14
|
+
attr_accessor :language
|
|
15
|
+
|
|
16
|
+
# The keyword for the feature
|
|
17
|
+
attr_accessor :keyword
|
|
18
|
+
|
|
19
|
+
# The Background object contained by the Feature
|
|
20
|
+
attr_accessor :background
|
|
21
|
+
|
|
22
|
+
# The Rule objects contained by the Feature
|
|
23
|
+
attr_accessor :rules
|
|
24
|
+
|
|
25
|
+
# The Scenario and Outline objects contained by the Feature
|
|
26
|
+
attr_accessor :tests
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Creates a new Feature object and, if *source_text* is provided, populates the
|
|
30
|
+
# object.
|
|
31
|
+
#
|
|
32
|
+
# @example
|
|
33
|
+
# Feature.new
|
|
34
|
+
# Feature.new("Feature:\nThis is a feature")
|
|
35
|
+
#
|
|
36
|
+
# @param source_text [String] The Gherkin text that will be used to populate the model
|
|
37
|
+
# @raise [ArgumentError] If *source_text* is not a String
|
|
38
|
+
# @return [Feature] A new Feature instance
|
|
39
|
+
def initialize(source_text = nil)
|
|
40
|
+
@tags = []
|
|
41
|
+
@rules = []
|
|
42
|
+
@tests = []
|
|
43
|
+
|
|
44
|
+
super
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Returns *true* if the feature contains a background, *false* otherwise.
|
|
48
|
+
#
|
|
49
|
+
# @example
|
|
50
|
+
# feature.background?
|
|
51
|
+
#
|
|
52
|
+
# @return [Boolean] Whether the feature contains a background
|
|
53
|
+
def background?
|
|
54
|
+
!@background.nil?
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
alias has_background? background?
|
|
58
|
+
|
|
59
|
+
# Returns the scenario models contained in the feature.
|
|
60
|
+
#
|
|
61
|
+
# @example
|
|
62
|
+
# feature.scenarios
|
|
63
|
+
#
|
|
64
|
+
# @return [Array<Scenario>] Child Scenario models
|
|
65
|
+
def scenarios
|
|
66
|
+
@tests.select { |test| test.is_a? Scenario }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Returns the outline models contained in the feature.
|
|
70
|
+
#
|
|
71
|
+
# @example
|
|
72
|
+
# feature.outlines
|
|
73
|
+
#
|
|
74
|
+
# @return [Array<Outline>] Child Outline models
|
|
75
|
+
def outlines
|
|
76
|
+
@tests.select { |test| test.is_a? Outline }
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# TODO: Remove this and other deprecated methods on next major version release
|
|
80
|
+
|
|
81
|
+
# @deprecated See CHANGELOG
|
|
82
|
+
#
|
|
83
|
+
# Returns the number of test cases contained in the feature. A test case is a
|
|
84
|
+
# single set of test values, such as an individual scenario or one example row
|
|
85
|
+
# of an outline.
|
|
86
|
+
#
|
|
87
|
+
# @example
|
|
88
|
+
# feature.test_case_count
|
|
89
|
+
#
|
|
90
|
+
# @return [Integer] The count of test cases
|
|
91
|
+
def test_case_count
|
|
92
|
+
scenarios.count + outlines.reduce(0) do |outline_sum, outline|
|
|
93
|
+
outline_sum + outline.examples.reduce(0) do |example_sum, example|
|
|
94
|
+
example_sum + example.argument_rows.count
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Returns the model objects that are children of this model. For a
|
|
100
|
+
# Feature model, these would be any associated Rule, Background,
|
|
101
|
+
# Scenario, Outline, or Tag models.
|
|
102
|
+
#
|
|
103
|
+
# @example
|
|
104
|
+
# feature.children
|
|
105
|
+
#
|
|
106
|
+
# @return [Array<Rule, Background, Scenario, Outline, Tag>] A collection of child models
|
|
107
|
+
def children
|
|
108
|
+
models = rules + tests + tags
|
|
109
|
+
models << background if background
|
|
110
|
+
|
|
111
|
+
models
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Building strings just isn't pretty
|
|
115
|
+
# rubocop:disable Metrics/AbcSize
|
|
116
|
+
|
|
117
|
+
# Returns a string representation of this model. For a Feature model,
|
|
118
|
+
# this will be Gherkin text that is equivalent to the feature being modeled.
|
|
119
|
+
#
|
|
120
|
+
# @example
|
|
121
|
+
# feature.to_s
|
|
122
|
+
#
|
|
123
|
+
# @return [String] A string representation of this model
|
|
124
|
+
def to_s
|
|
125
|
+
text = ''
|
|
126
|
+
|
|
127
|
+
text << "#{tag_output_string}\n" unless tags.empty?
|
|
128
|
+
text << "#{@keyword}:#{name_output_string}"
|
|
129
|
+
text << "\n#{description_output_string}" unless no_description_to_output?
|
|
130
|
+
text << "\n\n#{background_output_string}" if background
|
|
131
|
+
text << "\n\n#{tests_output_string}" unless tests.empty?
|
|
132
|
+
text << "\n\n#{rules_output_string}" unless rules.empty?
|
|
133
|
+
|
|
134
|
+
text
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# rubocop:enable Metrics/AbcSize
|
|
138
|
+
|
|
139
|
+
# See `Object#inspect`. Returns some basic information about the
|
|
140
|
+
# object, including its class, object ID, and its most meaningful
|
|
141
|
+
# attribute. For a Feature model, this will be the name of the
|
|
142
|
+
# feature. If *verbose* is true, provides default Ruby inspection
|
|
143
|
+
# behavior instead.
|
|
144
|
+
#
|
|
145
|
+
# @example
|
|
146
|
+
# feature.inspect
|
|
147
|
+
# feature.inspect(verbose: true)
|
|
148
|
+
#
|
|
149
|
+
# @param verbose [Boolean] Whether or not to return the full details of
|
|
150
|
+
# the object. Defaults to false.
|
|
151
|
+
# @return [String] A string representation of this model
|
|
152
|
+
def inspect(verbose: false)
|
|
153
|
+
return super if verbose
|
|
154
|
+
|
|
155
|
+
"#{super.chop} @name: #{name.inspect}>"
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
private
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def process_source(source_text)
|
|
163
|
+
parsed_file = Parsing.parse_text(source_text, 'cuke_modeler_stand_alone_feature.feature')
|
|
164
|
+
|
|
165
|
+
parsed_file['feature']
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def populate_model(parsed_feature_data)
|
|
169
|
+
populate_parsing_data(parsed_feature_data)
|
|
170
|
+
populate_source_location(parsed_feature_data)
|
|
171
|
+
populate_language(parsed_feature_data)
|
|
172
|
+
populate_keyword(parsed_feature_data)
|
|
173
|
+
populate_name(parsed_feature_data)
|
|
174
|
+
populate_description(parsed_feature_data)
|
|
175
|
+
populate_tags(parsed_feature_data)
|
|
176
|
+
populate_children(parsed_feature_data)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def populate_language(parsed_feature_data)
|
|
180
|
+
@language = parsed_feature_data['language']
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def background_output_string
|
|
184
|
+
child_element_output_string(background)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def tests_output_string
|
|
188
|
+
tests.collect { |test| child_element_output_string(test) }.join("\n\n")
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def rules_output_string
|
|
192
|
+
rules.collect { |rule| child_element_output_string(rule) }.join("\n\n")
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def child_element_output_string(model)
|
|
196
|
+
model.to_s.split("\n").collect { |line| line.empty? ? '' : " #{line}" }.join("\n")
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
end
|
|
200
|
+
end
|
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
module CukeModeler
|
|
2
|
-
|
|
3
|
-
# A class modeling a feature file in a Cucumber suite.
|
|
4
|
-
class FeatureFile < Model
|
|
5
|
-
|
|
6
|
-
include Parsed
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# The comment models contained by the modeled feature file
|
|
10
|
-
attr_accessor :comments
|
|
11
|
-
|
|
12
|
-
# The feature model contained by the modeled feature file
|
|
13
|
-
attr_accessor :feature
|
|
14
|
-
|
|
15
|
-
# The file path of the modeled feature file
|
|
16
|
-
attr_accessor :path
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
# Creates a new FeatureFile object and, if *file_path* is provided,
|
|
20
|
-
# populates the object.
|
|
21
|
-
#
|
|
22
|
-
# @example
|
|
23
|
-
# FeatureFile.new
|
|
24
|
-
# FeatureFile.new('path/to/some.feature')
|
|
25
|
-
#
|
|
26
|
-
# @param file_path [String] The file path that will be used to populate the model
|
|
27
|
-
# @raise [ArgumentError] If *file_path* is not a String
|
|
28
|
-
# @raise [ArgumentError] If the file path does not exist
|
|
29
|
-
# @return [FeatureFile] A new FeatureFile instance
|
|
30
|
-
def initialize(file_path = nil)
|
|
31
|
-
@path = file_path
|
|
32
|
-
@comments = []
|
|
33
|
-
|
|
34
|
-
super
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Returns the name of the modeled feature file.
|
|
38
|
-
#
|
|
39
|
-
# @example
|
|
40
|
-
# f = FeatureFile.new('path/to/some.feature')
|
|
41
|
-
# f.name #=> 'some.feature'
|
|
42
|
-
#
|
|
43
|
-
# @return [String] The name of the file
|
|
44
|
-
def name
|
|
45
|
-
File.basename(@path.gsub('\\', '/')) if @path
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# Returns the model objects that are children of this model. For a
|
|
49
|
-
# FeatureFile model, this would be any associated Feature model.
|
|
50
|
-
#
|
|
51
|
-
# @example
|
|
52
|
-
# feature_file.children
|
|
53
|
-
#
|
|
54
|
-
# @return [Array<Feature>] A collection of child models
|
|
55
|
-
def children
|
|
56
|
-
@feature ? [@feature] : []
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# Returns a string representation of this model. For a FeatureFile
|
|
60
|
-
# model, this will be the path of the modeled feature file.
|
|
61
|
-
#
|
|
62
|
-
# @example
|
|
63
|
-
# feature_file.to_s #=> 'path/to/some.feature'
|
|
64
|
-
#
|
|
65
|
-
# @return [String] A string representation of this model
|
|
66
|
-
def to_s
|
|
67
|
-
path.to_s
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# See `Object#inspect`. Returns some basic information about the
|
|
71
|
-
# object, including its class, object ID, and its most meaningful
|
|
72
|
-
# attribute. For a FeatureFile model, this will be the path of
|
|
73
|
-
# the feature file. If *verbose* is true, provides default Ruby
|
|
74
|
-
# inspection behavior instead.
|
|
75
|
-
#
|
|
76
|
-
# @example
|
|
77
|
-
# feature_file.inspect
|
|
78
|
-
# feature_file.inspect(verbose: true)
|
|
79
|
-
#
|
|
80
|
-
# @param verbose [Boolean] Whether or not to return the full details of
|
|
81
|
-
# the object. Defaults to false.
|
|
82
|
-
# @return [String] A string representation of this model
|
|
83
|
-
def inspect(verbose: false)
|
|
84
|
-
return super if verbose
|
|
85
|
-
|
|
86
|
-
"#{super.chop} @path: #{@path.inspect}>"
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
private
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def process_source(file_path)
|
|
94
|
-
raise(ArgumentError, "Unknown file: #{file_path.inspect}") unless File.exist?(file_path)
|
|
95
|
-
|
|
96
|
-
source_text = File.read(file_path)
|
|
97
|
-
feature_file_data = Parsing.parse_text(source_text, file_path)
|
|
98
|
-
|
|
99
|
-
feature_file_data.merge({ 'path' => file_path })
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def populate_model(processed_feature_file_data)
|
|
103
|
-
populate_parsing_data(processed_feature_file_data)
|
|
104
|
-
@path = processed_feature_file_data['path']
|
|
105
|
-
|
|
106
|
-
if processed_feature_file_data['feature']
|
|
107
|
-
@feature = build_child_model(Feature, processed_feature_file_data['feature'])
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
processed_feature_file_data['comments'].each do |comment_data|
|
|
111
|
-
@comments << build_child_model(Comment, comment_data)
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
end
|
|
116
|
-
end
|
|
1
|
+
module CukeModeler
|
|
2
|
+
|
|
3
|
+
# A class modeling a feature file in a Cucumber suite.
|
|
4
|
+
class FeatureFile < Model
|
|
5
|
+
|
|
6
|
+
include Parsed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# The comment models contained by the modeled feature file
|
|
10
|
+
attr_accessor :comments
|
|
11
|
+
|
|
12
|
+
# The feature model contained by the modeled feature file
|
|
13
|
+
attr_accessor :feature
|
|
14
|
+
|
|
15
|
+
# The file path of the modeled feature file
|
|
16
|
+
attr_accessor :path
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Creates a new FeatureFile object and, if *file_path* is provided,
|
|
20
|
+
# populates the object.
|
|
21
|
+
#
|
|
22
|
+
# @example
|
|
23
|
+
# FeatureFile.new
|
|
24
|
+
# FeatureFile.new('path/to/some.feature')
|
|
25
|
+
#
|
|
26
|
+
# @param file_path [String] The file path that will be used to populate the model
|
|
27
|
+
# @raise [ArgumentError] If *file_path* is not a String
|
|
28
|
+
# @raise [ArgumentError] If the file path does not exist
|
|
29
|
+
# @return [FeatureFile] A new FeatureFile instance
|
|
30
|
+
def initialize(file_path = nil)
|
|
31
|
+
@path = file_path
|
|
32
|
+
@comments = []
|
|
33
|
+
|
|
34
|
+
super
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Returns the name of the modeled feature file.
|
|
38
|
+
#
|
|
39
|
+
# @example
|
|
40
|
+
# f = FeatureFile.new('path/to/some.feature')
|
|
41
|
+
# f.name #=> 'some.feature'
|
|
42
|
+
#
|
|
43
|
+
# @return [String] The name of the file
|
|
44
|
+
def name
|
|
45
|
+
File.basename(@path.gsub('\\', '/')) if @path
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Returns the model objects that are children of this model. For a
|
|
49
|
+
# FeatureFile model, this would be any associated Feature model.
|
|
50
|
+
#
|
|
51
|
+
# @example
|
|
52
|
+
# feature_file.children
|
|
53
|
+
#
|
|
54
|
+
# @return [Array<Feature>] A collection of child models
|
|
55
|
+
def children
|
|
56
|
+
@feature ? [@feature] : []
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Returns a string representation of this model. For a FeatureFile
|
|
60
|
+
# model, this will be the path of the modeled feature file.
|
|
61
|
+
#
|
|
62
|
+
# @example
|
|
63
|
+
# feature_file.to_s #=> 'path/to/some.feature'
|
|
64
|
+
#
|
|
65
|
+
# @return [String] A string representation of this model
|
|
66
|
+
def to_s
|
|
67
|
+
path.to_s
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# See `Object#inspect`. Returns some basic information about the
|
|
71
|
+
# object, including its class, object ID, and its most meaningful
|
|
72
|
+
# attribute. For a FeatureFile model, this will be the path of
|
|
73
|
+
# the feature file. If *verbose* is true, provides default Ruby
|
|
74
|
+
# inspection behavior instead.
|
|
75
|
+
#
|
|
76
|
+
# @example
|
|
77
|
+
# feature_file.inspect
|
|
78
|
+
# feature_file.inspect(verbose: true)
|
|
79
|
+
#
|
|
80
|
+
# @param verbose [Boolean] Whether or not to return the full details of
|
|
81
|
+
# the object. Defaults to false.
|
|
82
|
+
# @return [String] A string representation of this model
|
|
83
|
+
def inspect(verbose: false)
|
|
84
|
+
return super if verbose
|
|
85
|
+
|
|
86
|
+
"#{super.chop} @path: #{@path.inspect}>"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
private
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def process_source(file_path)
|
|
94
|
+
raise(ArgumentError, "Unknown file: #{file_path.inspect}") unless File.exist?(file_path)
|
|
95
|
+
|
|
96
|
+
source_text = File.read(file_path)
|
|
97
|
+
feature_file_data = Parsing.parse_text(source_text, file_path)
|
|
98
|
+
|
|
99
|
+
feature_file_data.merge({ 'path' => file_path })
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def populate_model(processed_feature_file_data)
|
|
103
|
+
populate_parsing_data(processed_feature_file_data)
|
|
104
|
+
@path = processed_feature_file_data['path']
|
|
105
|
+
|
|
106
|
+
if processed_feature_file_data['feature']
|
|
107
|
+
@feature = build_child_model(Feature, processed_feature_file_data['feature'])
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
processed_feature_file_data['comments'].each do |comment_data|
|
|
111
|
+
@comments << build_child_model(Comment, comment_data)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
end
|
|
116
|
+
end
|