class CucumberAnalytics::Outline

A class modeling a Cucumber Scenario Outline.

Attributes

examples[RW]

The Example objects contained by the Outline

Public Class Methods

new(source = nil) click to toggle source

Creates a new Outline object and, if source is provided, populates the object.

Calls superclass method
# File lib/cucumber_analytics/outline.rb, line 16
def initialize(source = nil)
  parsed_outline = process_source(source)

  super(parsed_outline)

  @tags = []
  @tag_elements = []
  @examples = []

  build_outline(parsed_outline) if parsed_outline
end

Public Instance Methods

contains() click to toggle source

Returns the immediate child elements of the outline (i.e. its Example objects.

# File lib/cucumber_analytics/outline.rb, line 30
def contains
  @examples + @steps
end
to_s() click to toggle source

Returns a gherkin representation of the outline.

# File lib/cucumber_analytics/outline.rb, line 35
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 Instance Methods

build_outline(parsed_outline) click to toggle source
# File lib/cucumber_analytics/outline.rb, line 52
def build_outline(parsed_outline)
  populate_element_tags(parsed_outline)
  populate_outline_examples(parsed_outline['examples']) if parsed_outline['examples']
end
examples_output_string() click to toggle source
# File lib/cucumber_analytics/outline.rb, line 63
def examples_output_string
  examples.empty? ? '' : examples.collect { |example| example.to_s }.join("\n\n")
end
populate_outline_examples(parsed_examples) click to toggle source
# File lib/cucumber_analytics/outline.rb, line 57
def populate_outline_examples(parsed_examples)
  parsed_examples.each do |example|
    @examples << build_child_element(Example, example)
  end
end