Class: CukeModeler::Scenario
- Defined in:
- lib/cuke_modeler/models/scenario.rb
Overview
A class modeling an individual scenario of a Cucumber suite.
Instance Attribute Summary collapse
-
#keyword ⇒ Object
The scenario’s keyword.
Attributes included from Taggable
Attributes included from Sourceable
Attributes included from Stepped
Attributes included from Described
Attributes included from Named
Attributes included from Parsed
Attributes included from Nested
Instance Method Summary collapse
-
#==(other_model) ⇒ Object
Returns true if the two models have equivalent steps and false otherwise.
-
#children ⇒ Object
Returns the model objects that belong to this model.
-
#initialize(source_text = nil) ⇒ Scenario
constructor
Creates a new Scenario object and, if source_text is provided, populates the object.
-
#to_s ⇒ Object
Returns a string representation of this model.
Methods included from Taggable
Methods included from Parsing
Methods included from Containing
Methods included from Nested
Constructor Details
#initialize(source_text = nil) ⇒ Scenario
Creates a new Scenario object and, if source_text is provided, populates the object.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cuke_modeler/models/scenario.rb', line 22 def initialize(source_text = nil) @steps = [] @tags = [] super(source_text) if source_text parsed_scenario_data = parse_source(source_text) populate_scenario(self, parsed_scenario_data) end end |
Instance Attribute Details
#keyword ⇒ Object
The scenario’s keyword
17 18 19 |
# File 'lib/cuke_modeler/models/scenario.rb', line 17 def keyword @keyword end |
Instance Method Details
#==(other_model) ⇒ Object
Returns true if the two models have equivalent steps and false otherwise.
35 36 37 38 39 |
# File 'lib/cuke_modeler/models/scenario.rb', line 35 def ==(other_model) return false unless other_model.respond_to?(:steps) steps == other_model.steps end |
#children ⇒ Object
Returns the model objects that belong to this model.
42 43 44 |
# File 'lib/cuke_modeler/models/scenario.rb', line 42 def children steps + end |
#to_s ⇒ Object
Returns a string representation of this model. For a scenario model, this will be Gherkin text that is equivalent to the scenario being modeled.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cuke_modeler/models/scenario.rb', line 48 def to_s text = '' text << tag_output_string + "\n" unless .empty? text << "#{@keyword}:#{name_output_string}" text << "\n" + description_output_string unless (description.nil? || description.empty?) text << "\n" unless (steps.empty? || description.nil? || description.empty?) text << "\n" + steps_output_string unless steps.empty? text end |