Module: Async::RSpec::Reactor

Defined in:
lib/async/rspec/reactor.rb

Instance Method Summary collapse

Instance Method Details

#run_reactor(example, duration = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/async/rspec/reactor.rb', line 27

def run_reactor(example, duration = nil)
	result = nil
	
	duration ||= example.[:timeout] || 60
	
	Async::Reactor.run do |task|
		task.timeout(duration) do
			result = example.run
			
			task.children.each(&:wait)
		end
		
		task.reactor.stop if result.is_a? Exception
	end
	
	return result
end