class CukeModeler::Background
A class modeling a feature's background.
Attributes
keyword[RW]
The background's keyword
Public Class Methods
new(source_text = nil)
click to toggle source
Creates a new Background
object and, if source_text is provided, populates the object.
Calls superclass method
# File lib/cuke_modeler/models/background.rb, line 20 def initialize(source_text = nil) @steps = [] super(source_text) return unless source_text parsed_background_data = parse_source(source_text) populate_background(self, parsed_background_data) end
Public Instance Methods
==(other)
click to toggle source
Returns true if the two models have equivalent steps and false otherwise.
# File lib/cuke_modeler/models/background.rb, line 32 def ==(other) return false unless other.respond_to?(:steps) steps == other.steps end
children()
click to toggle source
Returns the model objects that belong to this model.
# File lib/cuke_modeler/models/background.rb, line 39 def children steps end
to_s()
click to toggle source
Returns a string representation of this model. For a background model, this will be Gherkin text that is equivalent to the background being modeled.
# File lib/cuke_modeler/models/background.rb, line 45 def to_s text = '' 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
Private Instance Methods
parse_source(source_text)
click to toggle source
# File lib/cuke_modeler/models/background.rb, line 60 def parse_source(source_text) base_file_string = "# language: #{Parsing.dialect}\n#{dialect_feature_keyword}: Fake feature to parse\n" source_text = base_file_string + source_text parsed_file = Parsing.parse_text(source_text, 'cuke_modeler_stand_alone_background.feature') parsed_file['feature']['elements'].first end