Class: CucumberAnalytics::Scenario

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

Overview

A class modeling a Cucumber Scenario.

Instance Attribute Summary

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

#==, #contains

Methods included from Nested

#get_ancestor

Constructor Details

#initialize(source = nil) ⇒ Scenario

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



12
13
14
15
16
17
18
19
20
21
# File 'lib/cucumber_analytics/scenario.rb', line 12

def initialize(source = nil)
  parsed_scenario = process_source(source)

  super(parsed_scenario)

  @tags = []
  @tag_elements = []

  build_scenario(parsed_scenario) if parsed_scenario
end

Instance Method Details

#to_sObject

Returns gherkin representation of the scenario.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cucumber_analytics/scenario.rb', line 24

def to_s
  text = ''

  text << tag_output_string + "\n" unless tags.empty?
  text << "Scenario:#{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
end