spec/adhearsion/call_controller/dial_spec.rb in adhearsion-2.1.0 vs spec/adhearsion/call_controller/dial_spec.rb in adhearsion-2.1.1
- old
+ new
@@ -386,9 +386,41 @@
time.to_i.should be == timeout
t.join
status = t.value
status.result.should be == :timeout
end
+
+ describe "if someone answers before the timeout elapses" do
+ it "should not abort until the far end hangs up" do
+ flexmock(other_mock_call).should_receive(:dial).once.with(to, hsh(:timeout => timeout))
+ flexmock(other_mock_call).should_receive(:join).once.with(call)
+ flexmock(other_mock_call).should_receive(:hangup).once
+ flexmock(OutboundCall).should_receive(:new).and_return other_mock_call
+
+ time = Time.now
+
+ t = Thread.new do
+ status = subject.dial to, :timeout => timeout
+ latch.countdown!
+ status
+ end
+
+ latch.wait(2).should be_false
+
+ other_mock_call << mock_answered
+
+ latch.wait(2).should be_false
+
+ other_mock_call << mock_end
+
+ latch.wait(0.1).should be_true
+ time = Time.now - time
+ time.to_i.should be > timeout
+ t.join
+ status = t.value
+ status.result.should be == :answer
+ end
+ end
end
describe "with a confirmation controller" do
let(:confirmation_controller) do
latch = confirmation_latch