Class: CucumberAnalytics::Background

Inherits:
TestElement show all
Defined in:
lib/cucumber_analytics/background.rb

Overview

A class modeling a Cucumber feature’s Background.

Instance Attribute Summary

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 inherited from TestElement

#==, #contains

Methods included from Nested

#get_ancestor

Constructor Details

#initialize(source = nil) ⇒ Background

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



9
10
11
12
13
14
15
# File 'lib/cucumber_analytics/background.rb', line 9

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

  super(parsed_background)

  build_background(parsed_background) if parsed_background
end

Instance Method Details

#to_sObject

Returns gherkin representation of the background.



18
19
20
21
22
23
24
25
26
27
# File 'lib/cucumber_analytics/background.rb', line 18

def to_s
  text = ''

  text << "Background:#{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