Class: Sapphire::DSL::Scenarios::Scenario

Inherits:
Object
  • Object
show all
Includes:
Testing::RSpecRunner
Defined in:
lib/sapphire/DSL/Scenarios/scenario.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Testing::RSpecRunner

#execute

Constructor Details

#initialize(text, &block) ⇒ Scenario

Returns a new instance of Scenario.



14
15
16
17
18
19
20
21
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 14

def initialize(text, &block)
  @value = text
  @text = text.to_s
  @block = block
  @givens = []
  @backgrounds = []
  @result = Testing::ScenarioResult.new(text)
end

Instance Attribute Details

#backgroundsObject (readonly)

Returns the value of attribute backgrounds.



11
12
13
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 11

def backgrounds
  @backgrounds
end

#blockObject (readonly)

Returns the value of attribute block.



7
8
9
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 7

def block
  @block
end

#givensObject (readonly)

Returns the value of attribute givens.



10
11
12
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 10

def givens
  @givens
end

#resultObject (readonly)

Returns the value of attribute result.



12
13
14
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 12

def result
  @result
end

#textObject (readonly)

Returns the value of attribute text.



9
10
11
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 9

def text
  @text
end

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 8

def value
  @value
end

Instance Method Details

#add_background(background) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 35

def add_background(background)
  if(self.value.is_a? Pending)
    @backgrounds << Background.new(self, "", Pending.new(background.text), &block)
  else
    @backgrounds << background
  end
end

#add_given(given) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 23

def add_given(given)
  if(self.value.is_a? Pending)
    @givens << Given.new(self, "", Pending.new(given.text), &block)
  else
    @givens << given
  end
end

#last_backgroundObject



43
44
45
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 43

def last_background
  @backgrounds.last
end

#last_givenObject



31
32
33
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 31

def last_given
  @givens.last
end