Permalink
Browse files

Merge pull request #1 from floere/259c172d85ffff8ea84eb05880c3b8d7fa1…

…8cb9a

Push delegate callbacks into the run method.
  • Loading branch information...
2 parents bea3965 + 259c172 commit 63aeb76ac69c8bc7b3349a521fa17f34a8711a80 @Manfred Manfred committed Aug 30, 2012
Showing with 7 additions and 8 deletions.
  1. +2 −6 lib/peck.rb
  2. +5 −2 lib/peck/specification.rb
View
@@ -75,9 +75,7 @@ def self.run_serial
Thread.current['peck-semaphore'] = Mutex.new
contexts.each do |context|
context.specs.each do |specification|
- delegates.started_specification(specification)
- specification.run
- delegates.finished_specification(specification)
+ specification.run(delegates)
end
end
rescue Exception => e
@@ -94,9 +92,7 @@ def self.run_concurrent
loop do
spec_index = Thread.exclusive { current_spec += 1 }
if specification = specs[spec_index]
- delegates.started_specification(specification)
- specification.run
- delegates.finished_specification(specification)
+ specification.run(delegates)
else
break
end
@@ -49,7 +49,8 @@ def synchronized(&block)
end
end
- def run
+ def run delegates
+ delegates.started_specification(self)
if @block
@before.each { |cb| @context.instance_eval(&cb) }
begin
@@ -63,11 +64,13 @@ def run
@after.each { |cb| @context.instance_eval(&cb) }
end
else
- Peck.delegates.received_missing(self)
+ delegates.received_missing(self)
end
rescue Object => e
Peck.delegates.received_exception(self, e)
@events << Event.new(e, self)
+ ensure
+ delegates.finished_specification(self)
end
def empty?

0 comments on commit 63aeb76

Please sign in to comment.