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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Testing::TestRunnerAdapter

#Report, #execute

Constructor Details

#initialize(text, &block) ⇒ Scenario

Returns a new instance of Scenario.



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

def initialize(text, &block)
  @value = text
  @text = text.to_s
  @block = block
  @givens = []
  @backgrounds = []
  @result = Testing::ScenarioResult.new(text)
  @file_name = ""
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

#file_nameObject

Returns the value of attribute file_name.



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

def file_name
  @file_name
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



39
40
41
42
43
44
45
46
47
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 39

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

#add_given(given) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 25

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

#last_backgroundObject



49
50
51
# File 'lib/sapphire/DSL/Scenarios/scenario.rb', line 49

def last_background
  @backgrounds.last
end

#last_givenObject



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

def last_given
  @givens.last
end