Class: When
- Includes:
- Sapphire::Testing::Executable
- Defined in:
- lib/sapphire/DSL/Scenarios/when.rb
Instance Attribute Summary collapse
-
#and ⇒ Object
readonly
Returns the value of attribute and.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#text ⇒ Object
Returns the value of attribute text.
-
#then ⇒ Object
readonly
Returns the value of attribute then.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #add_and(pre, text, &block) ⇒ Object
- #add_then(pre, text, &block) ⇒ Object
- #AddResult(result) ⇒ Object
-
#initialize(parent, pre, text, &block) ⇒ When
constructor
A new instance of When.
- #last_then ⇒ Object
Methods included from Sapphire::Testing::Executable
Constructor Details
#initialize(parent, pre, text, &block) ⇒ When
Returns a new instance of When.
12 13 14 15 16 17 18 19 20 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 12 def initialize(parent, pre, text, &block) @block = block @value = text @text = pre + text.to_s @then = [] @and = [] @parent = parent @results = [] end |
Instance Attribute Details
#and ⇒ Object (readonly)
Returns the value of attribute and.
8 9 10 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 8 def and @and end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
6 7 8 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 6 def block @block end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
9 10 11 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 9 def parent @parent end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
10 11 12 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 10 def results @results end |
#text ⇒ Object
Returns the value of attribute text.
5 6 7 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 5 def text @text end |
#then ⇒ Object (readonly)
Returns the value of attribute then.
7 8 9 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 7 def then @then end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 4 def value @value end |
Instance Method Details
#add_and(pre, text, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 32 def add_and(pre, text, &block) if(self.value.is_a? Pending or text.is_a? Pending) self.and << And.new(self, Pending.new(pre + text.to_s), &block) elsif(self.value.is_a? Broken) self.and << And.new(self, Broken.new(pre + text), &block) else self.and << And.new(self, pre + text.to_s, &block) end end |
#add_then(pre, text, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 22 def add_then(pre, text, &block) if(self.value.is_a? Pending or text.is_a? Pending) @then << Then.new(self, pre, Pending.new(text.to_s), &block) elsif(self.value.is_a? Broken) @then << Then.new(self, pre, Broken.new(text), &block) else @then << Then.new(self, pre, text, &block) end end |
#AddResult(result) ⇒ Object
46 47 48 49 50 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 46 def AddResult(result) result.item = self @results << result self.parent.results.last.AddChild(result) end |
#last_then ⇒ Object
42 43 44 |
# File 'lib/sapphire/DSL/Scenarios/when.rb', line 42 def last_then @then.last end |