Commit 38cdce1e authored by James Mead's avatar James Mead
Browse files

Since 14d6cda4 we always get a result from the call to `wait`.

There's no need to check the value of `result` since `wait` now always returns an event - either one of the expected events or a timeout event.

Before the commit mentioned above, I think we were only cancelling the timer when it had not yet fired. But since that commit, we always remove it. I'm not sure the latter was intentional, but I think it's probably sensible anyway as long as it doesn't upset event machine.
parent bd1246e1
......@@ -195,7 +195,7 @@ module Connfu
end
end
result = wait
EM.cancel_timer(timer) if result && timer
EM.cancel_timer(timer) if timer
result
end
end
......
......@@ -332,10 +332,10 @@ describe Connfu::Dsl do
subject.send(:wait_for, Connfu::Event::Answered, :timeout => 10)
end
it 'should not cancel the timer when no event is received' do
it 'should cancel the timer when timeout event is received' do
EM.stub!(:add_timer).and_return(:timer_signature)
subject.stub!(:wait).and_return(nil)
EM.should_not_receive(:cancel_timer).with(:timer_signature)
subject.stub!(:wait).and_return(Connfu::Dsl::Timeout.new(subject.call_id))
EM.should_receive(:cancel_timer).with(:timer_signature)
subject.send(:wait_for, Connfu::Event::Answered, :timeout => 10)
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment