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) ⇒ Boolean
Compares this model with another object.
-
#children ⇒ Array<Step, Tag>
Returns the model objects that are children of this model.
-
#initialize(source_text = nil) ⇒ Scenario
constructor
Creates a new Scenario object and, if source_text is provided, populates the object.
-
#inspect(verbose: false) ⇒ String
See ‘Object#inspect`.
-
#to_s ⇒ String
Returns a string representation of this model.
Methods included from Taggable
Methods included from Parsing
Methods included from Containing
#each, #each_descendant, #each_model
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.
29 30 31 32 33 34 |
# File 'lib/cuke_modeler/models/scenario.rb', line 29 def initialize(source_text = nil) @steps = [] @tags = [] super end |
Instance Attribute Details
#keyword ⇒ Object
The scenario’s keyword
16 17 18 |
# File 'lib/cuke_modeler/models/scenario.rb', line 16 def keyword @keyword end |
Instance Method Details
#==(other) ⇒ Boolean
Compares this model with another object. Returns true if the two objects have equivalent steps and false otherwise.
44 45 46 47 48 |
# File 'lib/cuke_modeler/models/scenario.rb', line 44 def ==(other) return false unless other.respond_to?(:steps) steps == other.steps end |
#children ⇒ Array<Step, Tag>
Returns the model objects that are children of this model. For a Scenario model, these would be any associated Step or Tag models.
57 58 59 |
# File 'lib/cuke_modeler/models/scenario.rb', line 57 def children steps + end |
#inspect(verbose: false) ⇒ String
See ‘Object#inspect`. Returns some basic information about the object, including its class, object ID, and its most meaningful attribute. For a Scenario model, this will be the name of the scenario. If verbose is true, provides default Ruby inspection behavior instead.
98 99 100 101 102 |
# File 'lib/cuke_modeler/models/scenario.rb', line 98 def inspect(verbose: false) return super if verbose "#{super.chop} @name: #{name.inspect}>" end |
#to_s ⇒ String
Returns a string representation of this model. For a Scenario model, this will be Gherkin text that is equivalent to the scenario being modeled.
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/cuke_modeler/models/scenario.rb', line 71 def to_s text = '' text << "#{tag_output_string}\n" unless .empty? text << "#{@keyword}:#{name_output_string}" text << "\n#{description_output_string}" unless no_description_to_output? text << "\n" unless steps.empty? || no_description_to_output? text << "\n#{steps_output_string}" unless steps.empty? text end |