Class: CucumberAnalytics::Outline

Inherits:
TestElement show all
Includes:
Taggable
Defined in:
lib/cucumber_analytics/outline.rb

Overview

A class modeling a Cucumber Scenario Outline.

Instance Attribute Summary collapse

Attributes included from Taggable

#tag_elements, #tags

Attributes inherited from TestElement

#steps

Attributes inherited from FeatureElement

#description, #description_text, #name

Attributes included from Nested

#parent_element

Attributes included from Raw

#raw_element

Attributes included from Sourceable

#source_line

Instance Method Summary collapse

Methods included from Taggable

#all_tag_elements, #all_tags, #applied_tag_elements, #applied_tags

Methods inherited from TestElement

#==

Methods included from Nested

#get_ancestor

Constructor Details

#initialize(source = nil) ⇒ Outline

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



16
17
18
19
20
21
22
23
24
25
26
# 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

Instance Attribute Details

#examplesObject

The Example objects contained by the Outline



11
12
13
# File 'lib/cucumber_analytics/outline.rb', line 11

def examples
  @examples
end

Instance Method Details

#containsObject

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



30
31
32
# File 'lib/cucumber_analytics/outline.rb', line 30

def contains
  @examples + @steps
end

#to_sObject

Returns a gherkin representation of the outline.



35
36
37
38
39
40
41
42
43
44
45
46
# 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