Sha256: 54c6d4b8129fdf187bf0c96177b20c06d2b8e5eff9ce682bd6b41a3770669598
Contents?: true
Size: 1.7 KB
Versions: 3
Compression:
Stored size: 1.7 KB
Contents
module CukeModeler # A class modeling a Cucumber Scenario Outline. class Outline < TestElement include Taggable # The Example objects contained by the Outline attr_accessor :examples # Creates a new Outline object and, if *source* is provided, populates the # object. def initialize(source = nil) parsed_outline = process_source(source) super(parsed_outline) @tags = [] @tag_elements = [] @examples = [] build_outline(parsed_outline) if parsed_outline end # Returns the immediate child elements of the outline (i.e. its Example # objects. def contains @examples + @steps end # Returns a gherkin representation of the outline. def to_s text = '' text << tag_output_string + "\n" unless tags.empty? text << "Scenario Outline:#{name_output_string}" text << "\n" + description_output_string unless description_text.empty? text << "\n" unless steps.empty? || description_text.empty? text << "\n" + steps_output_string unless steps.empty? text << "\n\n" + examples_output_string unless examples.empty? text end private def build_outline(parsed_outline) populate_element_tags(parsed_outline) populate_outline_examples(parsed_outline['examples']) if parsed_outline['examples'] end def populate_outline_examples(parsed_examples) parsed_examples.each do |example| @examples << build_child_element(Example, example) end end def examples_output_string examples.empty? ? '' : examples.collect { |example| example.to_s }.join("\n\n") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cuke_modeler-0.1.0 | lib/cuke_modeler/outline.rb |
cuke_modeler-0.0.2 | lib/cuke_modeler/outline.rb |
cuke_modeler-0.0.1 | lib/cuke_modeler/outline.rb |