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.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +579 -572
  3. data/LICENSE.txt +22 -22
  4. data/README.md +135 -135
  5. data/cuke_modeler.gemspec +59 -59
  6. data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +13 -13
  7. data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +13 -13
  8. data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +13 -13
  9. data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +13 -13
  10. data/lib/cuke_modeler/adapters/gherkin_14_adapter.rb +13 -13
  11. data/lib/cuke_modeler/adapters/gherkin_15_adapter.rb +13 -13
  12. data/lib/cuke_modeler/adapters/gherkin_16_adapter.rb +13 -13
  13. data/lib/cuke_modeler/adapters/gherkin_17_adapter.rb +13 -13
  14. data/lib/cuke_modeler/adapters/gherkin_18_adapter.rb +27 -27
  15. data/lib/cuke_modeler/adapters/gherkin_19_adapter.rb +64 -64
  16. data/lib/cuke_modeler/adapters/gherkin_20_adapter.rb +359 -359
  17. data/lib/cuke_modeler/adapters/gherkin_21_adapter.rb +13 -13
  18. data/lib/cuke_modeler/adapters/gherkin_22_adapter.rb +13 -13
  19. data/lib/cuke_modeler/adapters/gherkin_23_adapter.rb +13 -13
  20. data/lib/cuke_modeler/adapters/gherkin_24_adapter.rb +13 -13
  21. data/lib/cuke_modeler/adapters/gherkin_25_adapter.rb +13 -13
  22. data/lib/cuke_modeler/adapters/gherkin_26_adapter.rb +13 -13
  23. data/lib/cuke_modeler/adapters/gherkin_27_adapter.rb +13 -13
  24. data/lib/cuke_modeler/adapters/gherkin_28_adapter.rb +13 -13
  25. data/lib/cuke_modeler/adapters/gherkin_29_adapter.rb +13 -13
  26. data/lib/cuke_modeler/adapters/gherkin_30_adapter.rb +13 -13
  27. data/lib/cuke_modeler/adapters/gherkin_31_adapter.rb +13 -13
  28. data/lib/cuke_modeler/adapters/gherkin_32_adapter.rb +13 -13
  29. data/lib/cuke_modeler/adapters/gherkin_33_adapter.rb +13 -13
  30. data/lib/cuke_modeler/adapters/gherkin_34_adapter.rb +13 -13
  31. data/lib/cuke_modeler/adapters/gherkin_35_adapter.rb +13 -13
  32. data/lib/cuke_modeler/adapters/gherkin_36_adapter.rb +13 -13
  33. data/lib/cuke_modeler/adapters/gherkin_37_adapter.rb +13 -13
  34. data/lib/cuke_modeler/adapters/gherkin_38_adapter.rb +13 -0
  35. data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +375 -375
  36. data/lib/cuke_modeler/adapters/gherkin_base_adapter.rb +17 -17
  37. data/lib/cuke_modeler/containing.rb +105 -105
  38. data/lib/cuke_modeler/described.rb +71 -71
  39. data/lib/cuke_modeler/models/background.rb +122 -122
  40. data/lib/cuke_modeler/models/cell.rb +88 -88
  41. data/lib/cuke_modeler/models/comment.rb +82 -82
  42. data/lib/cuke_modeler/models/directory.rb +143 -143
  43. data/lib/cuke_modeler/models/doc_string.rb +104 -104
  44. data/lib/cuke_modeler/models/example.rb +274 -274
  45. data/lib/cuke_modeler/models/feature.rb +200 -200
  46. data/lib/cuke_modeler/models/feature_file.rb +116 -116
  47. data/lib/cuke_modeler/models/model.rb +87 -87
  48. data/lib/cuke_modeler/models/outline.rb +145 -145
  49. data/lib/cuke_modeler/models/row.rb +104 -104
  50. data/lib/cuke_modeler/models/rule.rb +162 -162
  51. data/lib/cuke_modeler/models/scenario.rb +128 -128
  52. data/lib/cuke_modeler/models/step.rb +178 -178
  53. data/lib/cuke_modeler/models/table.rb +117 -117
  54. data/lib/cuke_modeler/models/tag.rb +75 -75
  55. data/lib/cuke_modeler/named.rb +26 -26
  56. data/lib/cuke_modeler/nested.rb +61 -61
  57. data/lib/cuke_modeler/parsed.rb +24 -24
  58. data/lib/cuke_modeler/parsing.rb +208 -208
  59. data/lib/cuke_modeler/sourceable.rb +29 -29
  60. data/lib/cuke_modeler/stepped.rb +34 -34
  61. data/lib/cuke_modeler/taggable.rb +57 -57
  62. data/lib/cuke_modeler/version.rb +4 -4
  63. data/lib/cuke_modeler.rb +32 -32
  64. data/testing/cucumber/features/analysis/step_comparison.feature +25 -25
  65. data/testing/cucumber/features/analysis/test_comparison.feature +35 -35
  66. data/testing/cucumber/features/modeling/background_modeling.feature +105 -105
  67. data/testing/cucumber/features/modeling/background_output.feature +60 -60
  68. data/testing/cucumber/features/modeling/cell_modeling.feature +68 -68
  69. data/testing/cucumber/features/modeling/cell_output.feature +36 -36
  70. data/testing/cucumber/features/modeling/comment_modeling.feature +62 -62
  71. data/testing/cucumber/features/modeling/comment_output.feature +40 -40
  72. data/testing/cucumber/features/modeling/directory_modeling.feature +62 -62
  73. data/testing/cucumber/features/modeling/directory_output.feature +33 -33
  74. data/testing/cucumber/features/modeling/doc_string_modeling.feature +85 -85
  75. data/testing/cucumber/features/modeling/doc_string_output.feature +50 -50
  76. data/testing/cucumber/features/modeling/example_modeling.feature +155 -155
  77. data/testing/cucumber/features/modeling/example_output.feature +57 -57
  78. data/testing/cucumber/features/modeling/feature_file_modeling.feature +49 -49
  79. data/testing/cucumber/features/modeling/feature_file_output.feature +33 -33
  80. data/testing/cucumber/features/modeling/feature_modeling.feature +149 -149
  81. data/testing/cucumber/features/modeling/feature_output.feature +144 -144
  82. data/testing/cucumber/features/modeling/model_output.feature +61 -61
  83. data/testing/cucumber/features/modeling/model_structure.feature +42 -42
  84. data/testing/cucumber/features/modeling/outline_modeling.feature +175 -175
  85. data/testing/cucumber/features/modeling/outline_output.feature +87 -87
  86. data/testing/cucumber/features/modeling/row_modeling.feature +70 -70
  87. data/testing/cucumber/features/modeling/row_output.feature +40 -40
  88. data/testing/cucumber/features/modeling/rule_modeling.feature +171 -171
  89. data/testing/cucumber/features/modeling/rule_output.feature +136 -136
  90. data/testing/cucumber/features/modeling/scenario_modeling.feature +146 -146
  91. data/testing/cucumber/features/modeling/scenario_output.feature +63 -63
  92. data/testing/cucumber/features/modeling/step_modeling.feature +105 -105
  93. data/testing/cucumber/features/modeling/step_output.feature +47 -47
  94. data/testing/cucumber/features/modeling/table_modeling.feature +73 -73
  95. data/testing/cucumber/features/modeling/table_output.feature +42 -42
  96. data/testing/cucumber/features/modeling/tag_modeling.feature +62 -62
  97. data/testing/cucumber/features/modeling/tag_output.feature +40 -40
  98. metadata +6 -8
@@ -1,17 +1,17 @@
1
- module CukeModeler
2
-
3
- # @api private
4
- #
5
- # A class providing some basic and common adapter functionality. Internal helper class.
6
- class GherkinBaseAdapter
7
-
8
- private
9
-
10
- def save_original_data(adapted_ast, raw_ast)
11
- adapted_ast['cuke_modeler_parsing_data'] = Marshal.load(Marshal.dump(raw_ast))
12
- end
13
-
14
- end
15
-
16
- private_constant :GherkinBaseAdapter
17
- end
1
+ module CukeModeler
2
+
3
+ # @api private
4
+ #
5
+ # A class providing some basic and common adapter functionality. Internal helper class.
6
+ class GherkinBaseAdapter
7
+
8
+ private
9
+
10
+ def save_original_data(adapted_ast, raw_ast)
11
+ adapted_ast['cuke_modeler_parsing_data'] = Marshal.load(Marshal.dump(raw_ast))
12
+ end
13
+
14
+ end
15
+
16
+ private_constant :GherkinBaseAdapter
17
+ end
@@ -1,105 +1,105 @@
1
- module CukeModeler
2
-
3
- # @api private
4
- #
5
- # A mix-in module containing methods used by models that contain other models. Internal helper class.
6
- module Containing
7
-
8
- include Enumerable
9
-
10
- # TODO: Have this method return `self` so that method chaining can be done?
11
-
12
- # @api
13
- #
14
- # Executes the given code block with this model and every model that is a child of this model. Exact
15
- # order of model tree traversal is not guaranteed beyond the first model traversed, which will be the
16
- # model that called this method. If no block is provided, an `Enumerator` is returned instead.
17
- #
18
- # @example
19
- # model.each
20
- # model.each { |model| puts model.inspect }
21
- #
22
- # @yieldparam [Model] The current model being visited
23
- # @return [Enumerable] if no block is given
24
- def each(&block)
25
- if block
26
- block.call(self)
27
- children.each { |child| child.each(&block) }
28
- else
29
- to_enum(:each)
30
- end
31
- end
32
-
33
- # @api
34
- # @deprecated Use `Enumerable` module methods instead
35
- #
36
- # Executes the given code block with every model that is a child of this model.
37
- #
38
- # @example
39
- # model.each_descendant { |model| puts model.inspect }
40
- #
41
- # @yieldparam [Model] The current model being visited
42
- def each_descendant(&block)
43
- children.each do |child_model|
44
- block.call(child_model)
45
- child_model.each_descendant(&block) if child_model.respond_to?(:each_descendant)
46
- end
47
- end
48
-
49
- # @api
50
- # @deprecated Use `Enumerable` module methods instead
51
- #
52
- # Executes the given code block with this model and every model that is a child of this model.
53
- #
54
- # @example
55
- # model.each_model { |model| puts model.inspect }
56
- #
57
- # @yieldparam [Model] The current model being visited
58
- def each_model(&block)
59
- block.call(self)
60
-
61
- each_descendant(&block)
62
- end
63
-
64
-
65
- private
66
-
67
-
68
- def build_child_model(clazz, model_data)
69
- model = clazz.new
70
- # Send-ing to get around private scoping. Don't want the make the method public
71
- # and there is no way to get the already processed data to the child model that
72
- # wouldn't require something public.
73
- model.send('populate_model', model_data)
74
- model.parent_model = self
75
-
76
- model
77
- end
78
-
79
- # TODO: move to mix-in module
80
- def populate_keyword(parsed_model_data)
81
- @keyword = parsed_model_data['keyword'].strip
82
- end
83
-
84
- # TODO: move elsewhere?
85
- def populate_children(parsed_feature_data)
86
- return unless parsed_feature_data['elements']
87
-
88
- parsed_feature_data['elements'].each do |element|
89
- case element['type']
90
- when 'Scenario', 'scenario'
91
- @tests << build_child_model(Scenario, element)
92
- when 'ScenarioOutline', 'scenario_outline'
93
- @tests << build_child_model(Outline, element)
94
- when 'Background', 'background'
95
- @background = build_child_model(Background, element)
96
- when 'Rule'
97
- @rules << build_child_model(Rule, element)
98
- else
99
- raise(ArgumentError, "Unknown element type: #{element['type']}")
100
- end
101
- end
102
- end
103
-
104
- end
105
- end
1
+ module CukeModeler
2
+
3
+ # @api private
4
+ #
5
+ # A mix-in module containing methods used by models that contain other models. Internal helper class.
6
+ module Containing
7
+
8
+ include Enumerable
9
+
10
+ # TODO: Have this method return `self` so that method chaining can be done?
11
+
12
+ # @api
13
+ #
14
+ # Executes the given code block with this model and every model that is a child of this model. Exact
15
+ # order of model tree traversal is not guaranteed beyond the first model traversed, which will be the
16
+ # model that called this method. If no block is provided, an `Enumerator` is returned instead.
17
+ #
18
+ # @example
19
+ # model.each
20
+ # model.each { |model| puts model.inspect }
21
+ #
22
+ # @yieldparam [Model] The current model being visited
23
+ # @return [Enumerable] if no block is given
24
+ def each(&block)
25
+ if block
26
+ block.call(self)
27
+ children.each { |child| child.each(&block) }
28
+ else
29
+ to_enum(:each)
30
+ end
31
+ end
32
+
33
+ # @api
34
+ # @deprecated Use `Enumerable` module methods instead
35
+ #
36
+ # Executes the given code block with every model that is a child of this model.
37
+ #
38
+ # @example
39
+ # model.each_descendant { |model| puts model.inspect }
40
+ #
41
+ # @yieldparam [Model] The current model being visited
42
+ def each_descendant(&block)
43
+ children.each do |child_model|
44
+ block.call(child_model)
45
+ child_model.each_descendant(&block) if child_model.respond_to?(:each_descendant)
46
+ end
47
+ end
48
+
49
+ # @api
50
+ # @deprecated Use `Enumerable` module methods instead
51
+ #
52
+ # Executes the given code block with this model and every model that is a child of this model.
53
+ #
54
+ # @example
55
+ # model.each_model { |model| puts model.inspect }
56
+ #
57
+ # @yieldparam [Model] The current model being visited
58
+ def each_model(&block)
59
+ block.call(self)
60
+
61
+ each_descendant(&block)
62
+ end
63
+
64
+
65
+ private
66
+
67
+
68
+ def build_child_model(clazz, model_data)
69
+ model = clazz.new
70
+ # Send-ing to get around private scoping. Don't want the make the method public
71
+ # and there is no way to get the already processed data to the child model that
72
+ # wouldn't require something public.
73
+ model.send('populate_model', model_data)
74
+ model.parent_model = self
75
+
76
+ model
77
+ end
78
+
79
+ # TODO: move to mix-in module
80
+ def populate_keyword(parsed_model_data)
81
+ @keyword = parsed_model_data['keyword'].strip
82
+ end
83
+
84
+ # TODO: move elsewhere?
85
+ def populate_children(parsed_feature_data)
86
+ return unless parsed_feature_data['elements']
87
+
88
+ parsed_feature_data['elements'].each do |element|
89
+ case element['type']
90
+ when 'Scenario', 'scenario'
91
+ @tests << build_child_model(Scenario, element)
92
+ when 'ScenarioOutline', 'scenario_outline'
93
+ @tests << build_child_model(Outline, element)
94
+ when 'Background', 'background'
95
+ @background = build_child_model(Background, element)
96
+ when 'Rule'
97
+ @rules << build_child_model(Rule, element)
98
+ else
99
+ raise(ArgumentError, "Unknown element type: #{element['type']}")
100
+ end
101
+ end
102
+ end
103
+
104
+ end
105
+ end
@@ -1,71 +1,71 @@
1
- module CukeModeler
2
-
3
- # @api private
4
- #
5
- # A mix-in module containing methods used by models that represent an element that has a
6
- # description. Internal helper class.
7
- module Described
8
-
9
- # @api
10
- #
11
- # The description of the element
12
- attr_accessor :description
13
-
14
-
15
- private
16
-
17
-
18
- def description_output_string
19
- text = ''
20
-
21
- unless description.empty?
22
- description_lines = description.split("\n")
23
-
24
- text << "\n" if description_lines.first =~ /\S/
25
- text << description_lines.join("\n")
26
- end
27
-
28
- text
29
- end
30
-
31
- def no_description_to_output?
32
- description.nil? || description.empty?
33
- end
34
-
35
- def populate_description(parsed_model_data)
36
- @description = trimmed_description(parsed_model_data['description'])
37
- end
38
-
39
- def trimmed_description(description)
40
- description = description.split("\n")
41
-
42
- trim_leading_blank_lines(description)
43
- trim_trailing_blank_lines(description)
44
- trim_leading_spaces(description)
45
- trim_trailing_spaces(description)
46
-
47
- description.join("\n")
48
- end
49
-
50
- def trim_leading_blank_lines(description)
51
- description.replace(description.drop_while { |line| line !~ /\S/ })
52
- end
53
-
54
- def trim_trailing_blank_lines(_description)
55
- # Nothing to do. Already done by the parser but leaving this here in case that changes in future versions.
56
- end
57
-
58
- def trim_leading_spaces(description)
59
- non_blank_lines = description.grep(/\S/)
60
-
61
- fewest_spaces = non_blank_lines.collect { |line| line[/^\s*/].length }.min || 0
62
-
63
- description.each { |line| line.slice!(0..(fewest_spaces - 1)) } if fewest_spaces.positive?
64
- end
65
-
66
- def trim_trailing_spaces(description)
67
- description.map!(&:rstrip)
68
- end
69
-
70
- end
71
- end
1
+ module CukeModeler
2
+
3
+ # @api private
4
+ #
5
+ # A mix-in module containing methods used by models that represent an element that has a
6
+ # description. Internal helper class.
7
+ module Described
8
+
9
+ # @api
10
+ #
11
+ # The description of the element
12
+ attr_accessor :description
13
+
14
+
15
+ private
16
+
17
+
18
+ def description_output_string
19
+ text = ''
20
+
21
+ unless description.empty?
22
+ description_lines = description.split("\n")
23
+
24
+ text << "\n" if description_lines.first =~ /\S/
25
+ text << description_lines.join("\n")
26
+ end
27
+
28
+ text
29
+ end
30
+
31
+ def no_description_to_output?
32
+ description.nil? || description.empty?
33
+ end
34
+
35
+ def populate_description(parsed_model_data)
36
+ @description = trimmed_description(parsed_model_data['description'])
37
+ end
38
+
39
+ def trimmed_description(description)
40
+ description = description.split("\n")
41
+
42
+ trim_leading_blank_lines(description)
43
+ trim_trailing_blank_lines(description)
44
+ trim_leading_spaces(description)
45
+ trim_trailing_spaces(description)
46
+
47
+ description.join("\n")
48
+ end
49
+
50
+ def trim_leading_blank_lines(description)
51
+ description.replace(description.drop_while { |line| line !~ /\S/ })
52
+ end
53
+
54
+ def trim_trailing_blank_lines(_description)
55
+ # Nothing to do. Already done by the parser but leaving this here in case that changes in future versions.
56
+ end
57
+
58
+ def trim_leading_spaces(description)
59
+ non_blank_lines = description.grep(/\S/)
60
+
61
+ fewest_spaces = non_blank_lines.collect { |line| line[/^\s*/].length }.min || 0
62
+
63
+ description.each { |line| line.slice!(0..(fewest_spaces - 1)) } if fewest_spaces.positive?
64
+ end
65
+
66
+ def trim_trailing_spaces(description)
67
+ description.map!(&:rstrip)
68
+ end
69
+
70
+ end
71
+ end
@@ -1,122 +1,122 @@
1
- module CukeModeler
2
-
3
- # A class modeling a feature's background.
4
- class Background < Model
5
-
6
- include Parsing
7
- include Parsed
8
- include Named
9
- include Described
10
- include Stepped
11
- include Sourceable
12
-
13
-
14
- # The background's keyword
15
- attr_accessor :keyword
16
-
17
-
18
- # Creates a new Background object and, if *source_text* is provided, populates
19
- # the object.
20
- #
21
- # @example
22
- # Background.new
23
- # Background.new("Background:\n * a step")
24
- #
25
- # @param source_text [String] The Gherkin text that will be used to populate the model
26
- # @raise [ArgumentError] If *source_text* is not a String
27
- # @return [Background] A new Background instance
28
- def initialize(source_text = nil)
29
- @steps = []
30
-
31
- super
32
- end
33
-
34
- # TODO: Have (all) models be equivalent if they have the same #to_s output. Would
35
- # likely require major version change.
36
-
37
- # Compares this model with another object. Returns *true* if the two objects
38
- # have equivalent steps and *false* otherwise.
39
- #
40
- # @example
41
- # background_1 == background_2
42
- #
43
- # @param other [Object] The object to compare this model with
44
- # @return [Boolean] Whether the two objects are equivalent
45
- def ==(other)
46
- return false unless other.respond_to?(:steps)
47
-
48
- steps == other.steps
49
- end
50
-
51
- # Returns the model objects that are children of this model. For a
52
- # Background model, these would be any associated Step models.
53
- #
54
- # @example
55
- # background.children
56
- #
57
- # @return [Array<Step>] A collection of child models
58
- def children
59
- steps
60
- end
61
-
62
- # Returns a string representation of this model. For a Background model,
63
- # this will be Gherkin text that is equivalent to the background being modeled.
64
- #
65
- # @example
66
- # background.to_s
67
- #
68
- # @return [String] A string representation of this model
69
- def to_s
70
- text = ''
71
-
72
- text << "#{@keyword}:#{name_output_string}"
73
- text << "\n#{description_output_string}" unless no_description_to_output?
74
- text << "\n" unless steps.empty? || no_description_to_output?
75
- text << "\n#{steps_output_string}" unless steps.empty?
76
-
77
- text
78
- end
79
-
80
- # See `Object#inspect`. Returns some basic information about the
81
- # object, including its class, object ID, and its most meaningful
82
- # attribute. For a Background model, this will be the name of the
83
- # background. If *verbose* is true, provides default Ruby inspection
84
- # behavior instead.
85
- #
86
- # @example
87
- # background.inspect
88
- # background.inspect(verbose: true)
89
- #
90
- # @param verbose [Boolean] Whether or not to return the full details of
91
- # the object. Defaults to false.
92
- # @return [String] A string representation of this model
93
- def inspect(verbose: false)
94
- return super if verbose
95
-
96
- "#{super.chop} @name: #{name.inspect}>"
97
- end
98
-
99
-
100
- private
101
-
102
-
103
- def process_source(source_text)
104
- base_file_string = "# language: #{Parsing.dialect}\n#{dialect_feature_keyword}: Fake feature to parse\n"
105
- source_text = base_file_string + source_text
106
-
107
- parsed_file = Parsing.parse_text(source_text, 'cuke_modeler_stand_alone_background.feature')
108
-
109
- parsed_file['feature']['elements'].first
110
- end
111
-
112
- def populate_model(parsed_background_data)
113
- populate_parsing_data(parsed_background_data)
114
- populate_keyword(parsed_background_data)
115
- populate_name(parsed_background_data)
116
- populate_description(parsed_background_data)
117
- populate_source_location(parsed_background_data)
118
- populate_steps(parsed_background_data)
119
- end
120
-
121
- end
122
- end
1
+ module CukeModeler
2
+
3
+ # A class modeling a feature's background.
4
+ class Background < Model
5
+
6
+ include Parsing
7
+ include Parsed
8
+ include Named
9
+ include Described
10
+ include Stepped
11
+ include Sourceable
12
+
13
+
14
+ # The background's keyword
15
+ attr_accessor :keyword
16
+
17
+
18
+ # Creates a new Background object and, if *source_text* is provided, populates
19
+ # the object.
20
+ #
21
+ # @example
22
+ # Background.new
23
+ # Background.new("Background:\n * a step")
24
+ #
25
+ # @param source_text [String] The Gherkin text that will be used to populate the model
26
+ # @raise [ArgumentError] If *source_text* is not a String
27
+ # @return [Background] A new Background instance
28
+ def initialize(source_text = nil)
29
+ @steps = []
30
+
31
+ super
32
+ end
33
+
34
+ # TODO: Have (all) models be equivalent if they have the same #to_s output. Would
35
+ # likely require major version change.
36
+
37
+ # Compares this model with another object. Returns *true* if the two objects
38
+ # have equivalent steps and *false* otherwise.
39
+ #
40
+ # @example
41
+ # background_1 == background_2
42
+ #
43
+ # @param other [Object] The object to compare this model with
44
+ # @return [Boolean] Whether the two objects are equivalent
45
+ def ==(other)
46
+ return false unless other.respond_to?(:steps)
47
+
48
+ steps == other.steps
49
+ end
50
+
51
+ # Returns the model objects that are children of this model. For a
52
+ # Background model, these would be any associated Step models.
53
+ #
54
+ # @example
55
+ # background.children
56
+ #
57
+ # @return [Array<Step>] A collection of child models
58
+ def children
59
+ steps
60
+ end
61
+
62
+ # Returns a string representation of this model. For a Background model,
63
+ # this will be Gherkin text that is equivalent to the background being modeled.
64
+ #
65
+ # @example
66
+ # background.to_s
67
+ #
68
+ # @return [String] A string representation of this model
69
+ def to_s
70
+ text = ''
71
+
72
+ text << "#{@keyword}:#{name_output_string}"
73
+ text << "\n#{description_output_string}" unless no_description_to_output?
74
+ text << "\n" unless steps.empty? || no_description_to_output?
75
+ text << "\n#{steps_output_string}" unless steps.empty?
76
+
77
+ text
78
+ end
79
+
80
+ # See `Object#inspect`. Returns some basic information about the
81
+ # object, including its class, object ID, and its most meaningful
82
+ # attribute. For a Background model, this will be the name of the
83
+ # background. If *verbose* is true, provides default Ruby inspection
84
+ # behavior instead.
85
+ #
86
+ # @example
87
+ # background.inspect
88
+ # background.inspect(verbose: true)
89
+ #
90
+ # @param verbose [Boolean] Whether or not to return the full details of
91
+ # the object. Defaults to false.
92
+ # @return [String] A string representation of this model
93
+ def inspect(verbose: false)
94
+ return super if verbose
95
+
96
+ "#{super.chop} @name: #{name.inspect}>"
97
+ end
98
+
99
+
100
+ private
101
+
102
+
103
+ def process_source(source_text)
104
+ base_file_string = "# language: #{Parsing.dialect}\n#{dialect_feature_keyword}: Fake feature to parse\n"
105
+ source_text = base_file_string + source_text
106
+
107
+ parsed_file = Parsing.parse_text(source_text, 'cuke_modeler_stand_alone_background.feature')
108
+
109
+ parsed_file['feature']['elements'].first
110
+ end
111
+
112
+ def populate_model(parsed_background_data)
113
+ populate_parsing_data(parsed_background_data)
114
+ populate_keyword(parsed_background_data)
115
+ populate_name(parsed_background_data)
116
+ populate_description(parsed_background_data)
117
+ populate_source_location(parsed_background_data)
118
+ populate_steps(parsed_background_data)
119
+ end
120
+
121
+ end
122
+ end