Class: GUnit::Context
- Inherits:
-
Object
- Object
- GUnit::Context
- Defined in:
- lib/gunit/context.rb
Overview
Context instance has message, setups, exercises, teardowns, and parent (another Context)
Instance Attribute Summary collapse
-
#exercise ⇒ Object
Returns the value of attribute exercise.
-
#message ⇒ Object
Returns the value of attribute message.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#setups ⇒ Object
Returns the value of attribute setups.
-
#task ⇒ Object
Returns the value of attribute task.
-
#teardowns ⇒ Object
Returns the value of attribute teardowns.
Instance Method Summary collapse
- #all_message ⇒ Object
- #all_setups ⇒ Object
- #all_teardowns ⇒ Object
-
#initialize(*args, &blk) ⇒ Context
constructor
Context.new(“my message”) Context.new(“my message”) do setup { @foo = “bar” } verify { true } end Context.new do setup { @foo = “bar” } verify { true } end.
- #run(binding = self) ⇒ Object
Constructor Details
#initialize(*args, &blk) ⇒ Context
Context.new(“my message”) Context.new(“my message”) do
setup { @foo = "bar" }
verify { true }
end Context.new do
setup { @foo = "bar" }
verify { true }
end
15 16 17 18 19 20 |
# File 'lib/gunit/context.rb', line 15 def initialize(*args, &blk) self. = args[0] || '' self.setups = [] self.teardowns = [] self.task = blk if blk end |
Instance Attribute Details
#exercise ⇒ Object
Returns the value of attribute exercise.
4 5 6 |
# File 'lib/gunit/context.rb', line 4 def exercise @exercise end |
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/gunit/context.rb', line 4 def @message end |
#parent ⇒ Object
Returns the value of attribute parent.
4 5 6 |
# File 'lib/gunit/context.rb', line 4 def parent @parent end |
#setups ⇒ Object
Returns the value of attribute setups.
4 5 6 |
# File 'lib/gunit/context.rb', line 4 def setups @setups end |
#task ⇒ Object
Returns the value of attribute task.
4 5 6 |
# File 'lib/gunit/context.rb', line 4 def task @task end |
#teardowns ⇒ Object
Returns the value of attribute teardowns.
4 5 6 |
# File 'lib/gunit/context.rb', line 4 def teardowns @teardowns end |
Instance Method Details
#all_message ⇒ Object
30 31 32 33 34 |
# File 'lib/gunit/context.rb', line 30 def = self.parent. if self.parent = nil if == '' [, @message].compact.join(' ') end |
#all_setups ⇒ Object
36 37 38 |
# File 'lib/gunit/context.rb', line 36 def all_setups (self.parent ? self.parent.all_setups : []) + @setups end |
#all_teardowns ⇒ Object
40 41 42 |
# File 'lib/gunit/context.rb', line 40 def all_teardowns (self.parent ? self.parent.all_teardowns : []) + @teardowns end |
#run(binding = self) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/gunit/context.rb', line 22 def run(binding=self) if @task.is_a?(Proc) bound_task = @task.bind(binding) bound_task.call end return true end |