spec/adhearsion/call_controller/dial_spec.rb in adhearsion-2.5.2 vs spec/adhearsion/call_controller/dial_spec.rb in adhearsion-2.5.3

- old
+ new

@@ -263,11 +263,14 @@ end context "when the call is answered and joined" do it "has an overall dial status of :answer" do call.should_receive(:answer).once - other_mock_call.should_receive(:join).once.with(call, {}) + other_mock_call.should_receive(:join).once.with(call, {}).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end t = dial_in_thread sleep 0.5 @@ -284,11 +287,14 @@ joined_status.result.should == :joined end it "records the duration of the join" do call.should_receive(:answer).once - other_mock_call.should_receive(:join).once.with(call, {}) + other_mock_call.should_receive(:join).once.with(call, {}).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end other_mock_call.stub hangup: true t = dial_in_thread sleep 0.5 @@ -339,11 +345,14 @@ context "when a dial is split" do let(:join_target) { call } before do call.should_receive(:answer).once - other_mock_call.should_receive(:join).once.with(join_target, join_options) + other_mock_call.should_receive(:join).once.with(join_target, join_options).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end other_mock_call.stub(:unjoin).and_return do call << Punchblock::Event::Unjoined.new(call_uri: other_mock_call.id) other_mock_call << Punchblock::Event::Unjoined.new(call_uri: call.id) end end @@ -1321,14 +1330,16 @@ confirmation_latch.wait(2).should be_true latch.wait(2).should be_true end it "should join the calls if the call is still active after execution of the call controller" do - other_mock_call.should_receive(:hangup).once other_mock_call['confirm'] = true call.should_receive(:answer).once - other_mock_call.should_receive(:join).once.with(call, {}) + other_mock_call.should_receive(:join).once.with(call, {}).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end t = dial_in_thread latch.wait(2).should be_false @@ -1396,11 +1407,14 @@ it "should only execute the confirmation controller on the first call to answer, immediately hanging up all others" do other_mock_call['confirm'] = true call.should_receive(:answer).once other_mock_call.should_receive(:dial).once.with(to, from: nil) - other_mock_call.should_receive(:join).once.with(call, {}) + other_mock_call.should_receive(:join).once.with(call, {}).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end other_mock_call.should_receive(:hangup).once.and_return do other_mock_call << mock_end end second_other_mock_call.should_receive(:dial).once.with(second_to, from: nil) @@ -1666,11 +1680,14 @@ end context "when the call is answered and joined" do it "has an overall dial status of :answer" do call.should_receive(:answer).once - other_mock_call.should_receive(:join).once.with(call, {}) + other_mock_call.should_receive(:join).once.with(call, {}).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end t = dial_in_thread sleep 0.5 @@ -1687,11 +1704,14 @@ joined_status.result.should == :joined end it "records the duration of the join" do call.should_receive(:answer).once - other_mock_call.should_receive(:join).once.with(call, {}) + other_mock_call.should_receive(:join).once.with(call, {}).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end other_mock_call.stub hangup: true t = dial_in_thread sleep 0.5 @@ -1718,11 +1738,14 @@ context "when join options are specified" do let(:options) { { join_options: {media: :direct} } } it "joins the calls with those options" do call.should_receive(:answer).once - other_mock_call.should_receive(:join).once.with(call, media: :direct) + other_mock_call.should_receive(:join).once.with(call, media: :direct).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end other_mock_call.stub hangup: true t = dial_in_thread sleep 0.5 @@ -1742,11 +1765,14 @@ context "when a dial is split" do let(:join_target) { call } before do call.should_receive(:answer).once - other_mock_call.should_receive(:join).once.with(join_target, join_options) + other_mock_call.should_receive(:join).once.with(join_target, join_options).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end other_mock_call.stub(:unjoin).and_return do call << Punchblock::Event::Unjoined.new(call_uri: other_mock_call.id) other_mock_call << Punchblock::Event::Unjoined.new(call_uri: call.id) end end @@ -1910,11 +1936,14 @@ other_mock_call << mock_answered dial.split - other_mock_call.should_receive(:join).once.ordered.with(call, {}) + other_mock_call.should_receive(:join).once.ordered.with(call, {}).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end dial.rejoin other_mock_call << mock_end latch.wait(2).should be_true @@ -1934,11 +1963,14 @@ other_mock_call << mock_answered dial.split - other_mock_call.should_receive(:join).once.ordered.with(call, media: :direct) + other_mock_call.should_receive(:join).once.ordered.with(call, media: :direct).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end dial.rejoin end end context "when join options are passed to rejoin" do @@ -1950,11 +1982,14 @@ other_mock_call << mock_answered dial.split - other_mock_call.should_receive(:join).once.ordered.with(call, media: :direct) + other_mock_call.should_receive(:join).once.ordered.with(call, media: :direct).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end dial.rejoin nil, media: :direct end end context "when a join target was originally specified" do @@ -2654,11 +2689,14 @@ other_mock_call.should_receive(:hangup).once.and_return do other_mock_call << mock_end end other_mock_call['confirm'] = true call.should_receive(:answer).once - other_mock_call.should_receive(:join).once.with(call, {}) + other_mock_call.should_receive(:join).once.with(call, {}).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end t = dial_in_thread latch.wait(2).should be_false @@ -2741,10 +2779,13 @@ second_other_mock_call['confirmation_delay'] = 1.3 call.should_receive(:answer).once other_mock_call.should_receive(:dial).once.with(to, from: nil) - other_mock_call.should_receive(:join).once.with(call, {}) + other_mock_call.should_receive(:join).once.with(call, {}).and_return do + call << Punchblock::Event::Joined.new(call_uri: other_mock_call.id) + other_mock_call << Punchblock::Event::Joined.new(call_uri: call.id) + end other_mock_call.should_receive(:hangup).once.and_return do other_mock_call.async.deliver_message mock_end end second_other_mock_call.should_receive(:dial).once.with(second_to, from: nil)