spec/adhearsion/call_spec.rb in adhearsion-2.6.4 vs spec/adhearsion/call_spec.rb in adhearsion-3.0.0.beta1
- old
+ new
@@ -18,11 +18,11 @@
let(:to) { 'sip:you@there.com' }
let(:from) { 'sip:me@here.com' }
let(:transport) { 'footransport' }
let(:base_time) { Time.local(2008, 9, 1, 12, 0, 0) }
let :offer do
- Punchblock::Event::Offer.new target_call_id: call_id,
+ Adhearsion::Event::Offer.new target_call_id: call_id,
domain: domain,
transport: transport,
to: to,
from: from,
headers: headers,
@@ -156,29 +156,29 @@
subject[:x_foo] = 'baz'
expect(subject[:x_foo]).to eq('baz')
end
context "when receiving an event with headers" do
- let(:event) { Punchblock::Event::End.new :headers => {'X-bar' => 'foo'} }
+ let(:event) { Adhearsion::Event::End.new :headers => {'X-bar' => 'foo'} }
it "should merge later headers" do
subject << event
expect(subject.variables).to eq({'x_foo' => 'bar', 'x_bar' => 'foo'})
end
context "with have symbol names" do
- let(:event) { Punchblock::Event::End.new :headers => {:x_bar => 'foo'} }
+ let(:event) { Adhearsion::Event::End.new :headers => {:x_bar => 'foo'} }
it "should merge later headers" do
subject << event
expect(subject.variables).to eq({'x_foo' => 'bar', 'x_bar' => 'foo'})
end
end
end
context "when sending a command with headers" do
- let(:command) { Punchblock::Command::Accept.new :headers => {'X-bar' => 'foo'} }
+ let(:command) { Adhearsion::Rayo::Command::Accept.new :headers => {'X-bar' => 'foo'} }
it "should merge later headers" do
subject.write_command command
expect(subject.variables).to eq({'x_foo' => 'bar', 'x_bar' => 'foo'})
end
@@ -249,11 +249,11 @@
let(:response) { double 'Response' }
describe "for joined events" do
context "joined to another call" do
let :event do
- Punchblock::Event::Joined.new call_uri: 'footransport:foobar@rayo.net'
+ Adhearsion::Event::Joined.new call_uri: 'footransport:foobar@rayo.net'
end
it "should trigger any on_joined callbacks set for the matching call ID" do
expect(response).to receive(:call).once.with(event)
subject.on_joined(:call_uri => 'footransport:foobar@rayo.net') { |event| response.call event }
@@ -287,11 +287,11 @@
end
end
context "joined to a mixer" do
let :event do
- Punchblock::Event::Joined.new :mixer_name => 'foobar'
+ Adhearsion::Event::Joined.new :mixer_name => 'foobar'
end
it "should trigger on_joined callbacks for the matching mixer name" do
expect(response).to receive(:call).once.with(event)
subject.on_joined(:mixer_name => 'foobar') { |event| response.call event }
@@ -327,11 +327,11 @@
end
describe "for unjoined events" do
context "unjoined from another call" do
let :event do
- Punchblock::Event::Unjoined.new call_uri: 'footransport:foobar@rayo.net'
+ Adhearsion::Event::Unjoined.new call_uri: 'footransport:foobar@rayo.net'
end
it "should trigger any on_unjoined callbacks set for the matching call ID" do
expect(response).to receive(:call).once.with(event)
subject.on_unjoined(:call_uri => 'footransport:foobar@rayo.net') { |event| response.call event }
@@ -365,11 +365,11 @@
end
end
context "unjoined from a mixer" do
let :event do
- Punchblock::Event::Unjoined.new :mixer_name => 'foobar'
+ Adhearsion::Event::Unjoined.new :mixer_name => 'foobar'
end
it "should trigger on_unjoined callbacks for the matching mixer name" do
expect(response).to receive(:call).once.with(event)
subject.on_unjoined(:mixer_name => 'foobar') { |event| response.call event }
@@ -404,11 +404,11 @@
end
end
describe "for end events" do
let :event do
- Punchblock::Event::End.new :reason => :hangup
+ Adhearsion::Event::End.new :reason => :hangup
end
it "should trigger any on_end callbacks set" do
expect(response).to receive(:call).once.with(event)
subject.on_end { |event| response.call event }
@@ -432,11 +432,10 @@
latch.countdown!
end
subject.register_event_handler { |e| raise 'foo' }
expect { subject << :foo }.not_to raise_error
expect(latch.wait(3)).to be true
- Adhearsion::Events.clear_handlers :exception
end
end
end
context "peer registry" do
@@ -444,15 +443,15 @@
let(:other_call) { Call.new }
before { allow(other_call).to receive_messages uri: other_call_uri }
let :joined_event do
- Punchblock::Event::Joined.new call_uri: other_call_uri
+ Adhearsion::Event::Joined.new call_uri: other_call_uri
end
let :unjoined_event do
- Punchblock::Event::Unjoined.new call_uri: other_call_uri
+ Adhearsion::Event::Unjoined.new call_uri: other_call_uri
end
context "when we know about the joined call" do
before { Adhearsion.active_calls << other_call }
after { Adhearsion.active_calls.remove_inactive_call other_call }
@@ -550,31 +549,15 @@
expect(subject.peers).not_to be subject.peers
end
end
describe "#<<" do
- describe "with a Punchblock Complete Event and Reason Hangup" do
- let :complete_event do
- Punchblock::Event::Complete.new :reason => Punchblock::Event::Complete::Hangup.new
- end
-
- it "should mark the call as terminating" do
- subject << complete_event
- expect(subject.terminating?).to be true
- end
- end
-
- describe "with a Punchblock End" do
+ describe "with an End event" do
let :end_event do
- Punchblock::Event::End.new :reason => :hangup, :platform_code => 'arbitrary_code'
+ Adhearsion::Event::End.new :reason => :hangup, :platform_code => 'arbitrary_code'
end
- it "should mark the call as terminating" do
- subject << end_event
- expect(subject.terminating?).to be true
- end
-
it "should mark the call as ended" do
subject << end_event
expect(subject).not_to be_active
end
@@ -616,11 +599,11 @@
expect(subject.duration).to eq(63.0)
end
it "should instruct the command registry to terminate" do
- command = Punchblock::Command::Answer.new
+ command = Adhearsion::Rayo::Command::Answer.new
command.request!
subject.future.write_and_await_response command
subject << end_event
expect(command.response(1)).to be_a Call::Hangup
end
@@ -635,39 +618,39 @@
expect(Adhearsion.active_calls.size).to eq(size_before)
end
context "with no custom lifetime" do
around do |example|
- old_val = Adhearsion.config.platform.after_hangup_lifetime
+ old_val = Adhearsion.config.core.after_hangup_lifetime
begin
example.run
rescue
- Adhearsion.config.platform.after_hangup_lifetime = old_val
+ Adhearsion.config.core.after_hangup_lifetime = old_val
end
end
it "shuts down the actor using platform config" do
- Adhearsion.config.platform.after_hangup_lifetime = 2
+ Adhearsion.config.core.after_hangup_lifetime = 2
subject << end_event
sleep 2.1
expect(subject.alive?).to be false
expect { subject.id }.to raise_error Call::ExpiredError, /expired and is no longer accessible/
end
end
context "with a custom lifetime" do
around do |example|
- old_val = Adhearsion.config.platform.after_hangup_lifetime
+ old_val = Adhearsion.config.core.after_hangup_lifetime
begin
example.run
rescue
- Adhearsion.config.platform.after_hangup_lifetime = old_val
+ Adhearsion.config.core.after_hangup_lifetime = old_val
end
end
it "shuts down the actor using the Call#after_hangup_lifetime" do
- Adhearsion.config.platform.after_hangup_lifetime = 1
+ Adhearsion.config.core.after_hangup_lifetime = 1
subject.after_hangup_lifetime = 2
subject << end_event
sleep 1.1
expect(subject.alive?).to be true
sleep 1
@@ -678,11 +661,11 @@
end
end
describe "#wait_for_end" do
let :end_event do
- Punchblock::Event::End.new reason: :hangup
+ Adhearsion::Event::End.new reason: :hangup
end
context "when the call has already ended" do
before { subject << end_event }
@@ -700,10 +683,22 @@
subject << end_event
expect(fut.value).to eq(:hangup)
end
+
+ it "should unblock after a timeout" do
+ fut = subject.future.wait_for_end 1
+
+ sleep 0.5
+ expect(fut).not_to be_ready
+
+ sleep 0.5
+
+ expect { fut.value }.to raise_error(Celluloid::ConditionError)
+ expect(subject.alive?).to be(true)
+ end
end
end
describe "tagging a call" do
it 'with a single Symbol' do
@@ -751,15 +746,15 @@
expect(subject.tagged_with?(:authorized)).to be true
end
end
describe "#write_command" do
- let(:command) { Punchblock::Command::Answer.new }
+ let(:command) { Adhearsion::Rayo::Command::Answer.new }
- it "should write the command to the Punchblock connection" do
+ it "should write the command to the Rayo connection" do
expect(subject.wrapped_object).to receive(:client).once.and_return mock_client
- expect(mock_client).to receive(:execute_command).once.with(Punchblock::Command::Answer.new(target_call_id: call_id, domain: domain)).and_return true
+ expect(mock_client).to receive(:execute_command).once.with(Adhearsion::Rayo::Command::Answer.new(target_call_id: call_id, domain: domain)).and_return true
subject.write_command command
end
describe "with a hungup call" do
before do
@@ -769,21 +764,21 @@
it "should raise a Hangup exception" do
expect { subject.write_command command }.to raise_error(Call::Hangup)
end
describe "if the command is a Hangup" do
- let(:command) { Punchblock::Command::Hangup.new }
+ let(:command) { Adhearsion::Rayo::Command::Hangup.new }
it "should not raise a Hangup exception" do
expect { subject.write_command command }.not_to raise_error
end
end
end
end
describe '#write_and_await_response' do
- let(:message) { Punchblock::Command::Accept.new }
+ let(:message) { Adhearsion::Rayo::Command::Accept.new }
let(:response) { :foo }
before do
expect(message).to receive(:execute!).and_return true
message.response = response
@@ -798,11 +793,11 @@
subject.write_and_await_response message
expect(subject.commands).to be_empty
end
it "blocks until a response is received" do
- slow_command = Punchblock::Command::Dial.new
+ slow_command = Adhearsion::Rayo::Command::Dial.new
slow_command.request!
Thread.new do
sleep 0.5
slow_command.response = response
end
@@ -810,11 +805,11 @@
subject.write_and_await_response slow_command
expect(Time.now - starting_time).to be >= 0.5
end
context "while waiting for a response" do
- let(:slow_command) { Punchblock::Command::Dial.new }
+ let(:slow_command) { Adhearsion::Rayo::Command::Dial.new }
before { slow_command.request! }
it "does not block the whole actor while waiting for a response" do
fut = subject.future.write_and_await_response slow_command
@@ -836,11 +831,11 @@
expect(subject.write_and_await_response(message)).to be message
end
end
describe "with an error response" do
- let(:new_exception) { Punchblock::ProtocolError }
+ let(:new_exception) { Adhearsion::ProtocolError }
let(:response) { new_exception.new }
it "raises the error" do
expect(Events).to receive(:trigger).never
expect { subject.write_and_await_response message }.to raise_error new_exception
@@ -870,11 +865,11 @@
end
end
end
describe "#send_message" do
- it "should send a message through the Punchblock connection using the call ID and domain" do
+ it "should send a message through the Rayo connection using the call ID and domain" do
expect(subject.wrapped_object).to receive(:client).once.and_return mock_client
expect(mock_client).to receive(:send_message).once.with(subject.id, subject.domain, "Hello World!", {})
subject.send_message "Hello World!"
end
@@ -897,124 +892,124 @@
end
describe '#accept' do
describe "with no headers" do
it 'should send an Accept message' do
- expect_message_waiting_for_response Punchblock::Command::Accept.new
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Accept.new
subject.accept
end
end
describe "with headers set" do
it 'should send an Accept message with the correct headers' do
headers = {:foo => 'bar'}
- expect_message_waiting_for_response Punchblock::Command::Accept.new(:headers => headers)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Accept.new(:headers => headers)
subject.accept headers
end
end
describe "a second time" do
it "should only send one Accept message" do
- expect_message_waiting_for_response Punchblock::Command::Accept.new
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Accept.new
subject.accept
subject.accept
end
end
context "with a failure response" do
it 'should raise the error but not crash the actor' do
- error = Punchblock::ProtocolError.new.setup(:service_unavailable)
- expect_message_waiting_for_response Punchblock::Command::Accept.new, error
+ error = Adhearsion::ProtocolError.new.setup(:service_unavailable)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Accept.new, error
expect { subject.accept }.to raise_error error
sleep 0.2
expect(subject.alive?).to be true
end
end
end
describe '#answer' do
describe "with no headers" do
it 'should send an Answer message' do
- expect_message_waiting_for_response Punchblock::Command::Answer.new
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Answer.new
subject.answer
end
end
describe "with headers set" do
it 'should send an Answer message with the correct headers' do
headers = {:foo => 'bar'}
- expect_message_waiting_for_response Punchblock::Command::Answer.new(:headers => headers)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Answer.new(:headers => headers)
subject.answer headers
end
end
context "with a failure response" do
it 'should raise the error but not crash the actor' do
- error = Punchblock::ProtocolError.new.setup(:service_unavailable)
- expect_message_waiting_for_response Punchblock::Command::Answer.new, error
+ error = Adhearsion::ProtocolError.new.setup(:service_unavailable)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Answer.new, error
expect { subject.answer }.to raise_error error
sleep 0.2
expect(subject.alive?).to be true
end
end
end
describe '#reject' do
describe "with a reason given" do
it 'should send a Reject message with the correct reason' do
- expect_message_waiting_for_response Punchblock::Command::Reject.new(:reason => :decline)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Reject.new(:reason => :decline)
subject.reject :decline
end
end
describe "with no reason given" do
it 'should send a Reject message with the reason busy' do
- expect_message_waiting_for_response Punchblock::Command::Reject.new(:reason => :busy)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Reject.new(:reason => :busy)
subject.reject
end
end
describe "with no headers" do
it 'should send a Reject message' do
expect_message_waiting_for_response do |c|
- c.is_a?(Punchblock::Command::Reject) && c.headers == {}
+ c.is_a?(Adhearsion::Rayo::Command::Reject) && c.headers == {}
end
subject.reject
end
end
describe "with headers set" do
it 'should send a Hangup message with the correct headers' do
headers = {:foo => 'bar'}
expect_message_waiting_for_response do |c|
- c.is_a?(Punchblock::Command::Reject) && c.headers == headers
+ c.is_a?(Adhearsion::Rayo::Command::Reject) && c.headers == headers
end
subject.reject nil, headers
end
end
it "should immediately fire the :call_rejected event giving the call and the reason" do
- expect_message_waiting_for_response kind_of(Punchblock::Command::Reject)
+ expect_message_waiting_for_response kind_of(Adhearsion::Rayo::Command::Reject)
expect(Adhearsion::Events).to receive(:trigger_immediately).once.with(:call_rejected, :call => subject, :reason => :decline)
subject.reject :decline
end
context "with a failure response" do
it 'should raise the error but not crash the actor' do
- error = Punchblock::ProtocolError.new.setup(:service_unavailable)
- expect_message_waiting_for_response Punchblock::Command::Reject.new(reason: :busy), error
+ error = Adhearsion::ProtocolError.new.setup(:service_unavailable)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Reject.new(reason: :busy), error
expect { subject.reject }.to raise_error error
sleep 0.2
expect(subject.alive?).to be true
end
end
end
describe '#redirect' do
describe "with a target given" do
it 'should send a Redirect message with the correct target' do
- expect_message_waiting_for_response Punchblock::Command::Redirect.new(to: 'sip:foo@bar.com')
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Redirect.new(to: 'sip:foo@bar.com')
subject.redirect 'sip:foo@bar.com'
end
end
describe "with no target given" do
@@ -1024,30 +1019,30 @@
end
describe "with no headers" do
it 'should send a Redirect message' do
expect_message_waiting_for_response do |c|
- c.is_a?(Punchblock::Command::Redirect) && c.headers == {}
+ c.is_a?(Adhearsion::Rayo::Command::Redirect) && c.headers == {}
end
subject.redirect 'sip:foo@bar.com'
end
end
describe "with headers set" do
it 'should send a Redirect message with the correct headers' do
headers = {:foo => 'bar'}
expect_message_waiting_for_response do |c|
- c.is_a?(Punchblock::Command::Redirect) && c.headers == headers
+ c.is_a?(Adhearsion::Rayo::Command::Redirect) && c.headers == headers
end
subject.redirect 'sip:foo@bar.com', headers
end
end
context "with a failure response" do
it 'should raise the error but not crash the actor' do
- error = Punchblock::ProtocolError.new.setup(:service_unavailable)
- expect_message_waiting_for_response Punchblock::Command::Redirect.new(to: 'sip:foo@bar.com'), error
+ error = Adhearsion::ProtocolError.new.setup(:service_unavailable)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Redirect.new(to: 'sip:foo@bar.com'), error
expect { subject.redirect 'sip:foo@bar.com' }.to raise_error error
sleep 0.2
expect(subject.alive?).to be true
end
end
@@ -1065,45 +1060,45 @@
end
end
describe "if the call is active" do
it "should mark the call inactive" do
- expect_message_waiting_for_response Punchblock::Command::Hangup.new
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Hangup.new
subject.hangup
expect(subject).not_to be_active
end
describe "with no headers" do
it 'should send a Hangup message' do
- expect_message_waiting_for_response Punchblock::Command::Hangup.new
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Hangup.new
subject.hangup
end
end
describe "with headers set" do
it 'should send a Hangup message with the correct headers' do
headers = {:foo => 'bar'}
- expect_message_waiting_for_response Punchblock::Command::Hangup.new(:headers => headers)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Hangup.new(:headers => headers)
subject.hangup headers
end
end
end
context "with a failure response" do
it 'should raise the error but not crash the actor' do
- error = Punchblock::ProtocolError.new.setup(:service_unavailable)
- expect_message_waiting_for_response Punchblock::Command::Hangup.new, error
+ error = Adhearsion::ProtocolError.new.setup(:service_unavailable)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Hangup.new, error
expect { subject.hangup }.to raise_error error
sleep 0.2
expect(subject.alive?).to be true
end
end
end
describe "#join" do
def expect_join_with_options(options = {})
- Punchblock::Command::Join.new(options).tap do |join|
+ Adhearsion::Rayo::Command::Join.new(options).tap do |join|
expect_message_waiting_for_response join
end
end
context "with a call" do
@@ -1127,11 +1122,11 @@
end
it "should return the command" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
- expect(result[:command]).to be_a Punchblock::Command::Join
+ expect(result[:command]).to be_a Adhearsion::Rayo::Command::Join
expect(result[:command].call_uri).to eql(uri)
expect(result[:command].media).to eql(:bridge)
expect(result[:command].direction).to eql(:recv)
end
@@ -1139,55 +1134,55 @@
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
expect(result[:joined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
expect(result[:joined_condition].wait(0.5)).to be_truthy
end
it "should return something that can be blocked on until the entities are unjoined" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Unjoined.new(call_uri: uri)
+ subject << Adhearsion::Event::Unjoined.new(call_uri: uri)
expect(result[:unjoined_condition].wait(0.5)).to be_truthy
end
it "should unblock all conditions on call end if no joined/unjoined events are received" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
expect(result[:joined_condition].wait(0.5)).to be_falsey
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::End.new
+ subject << Adhearsion::Event::End.new
expect(result[:joined_condition].wait(0.5)).to be_truthy
expect(result[:unjoined_condition].wait(0.5)).to be_truthy
end
it "should not error on call end when joined/unjoined events are received correctly" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
- subject << Punchblock::Event::Joined.new(call_uri: uri)
- subject << Punchblock::Event::Unjoined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Unjoined.new(call_uri: uri)
- subject << Punchblock::Event::End.new
+ subject << Adhearsion::Event::End.new
end
it "should not error if multiple joined events are received for the same join" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
- subject << Punchblock::Event::Joined.new(call_uri: uri)
- subject << Punchblock::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
expect(subject).to be_alive
end
end
@@ -1208,11 +1203,11 @@
end
it "should return the command" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
- expect(result[:command]).to be_a Punchblock::Command::Join
+ expect(result[:command]).to be_a Adhearsion::Rayo::Command::Join
expect(result[:command].call_uri).to eql(uri)
expect(result[:command].media).to eql(:bridge)
expect(result[:command].direction).to eql(:recv)
end
@@ -1220,55 +1215,55 @@
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
expect(result[:joined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
expect(result[:joined_condition].wait(0.5)).to be_truthy
end
it "should return something that can be blocked on until the entities are unjoined" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Unjoined.new(call_uri: uri)
+ subject << Adhearsion::Event::Unjoined.new(call_uri: uri)
expect(result[:unjoined_condition].wait(0.5)).to be_truthy
end
it "should unblock all conditions on call end if no joined/unjoined events are received" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
expect(result[:joined_condition].wait(0.5)).to be_falsey
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::End.new
+ subject << Adhearsion::Event::End.new
expect(result[:joined_condition].wait(0.5)).to be_truthy
expect(result[:unjoined_condition].wait(0.5)).to be_truthy
end
it "should not error on call end when joined/unjoined events are received correctly" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
- subject << Punchblock::Event::Joined.new(call_uri: uri)
- subject << Punchblock::Event::Unjoined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Unjoined.new(call_uri: uri)
- subject << Punchblock::Event::End.new
+ subject << Adhearsion::Event::End.new
end
it "should not error if multiple joined events are received for the same join" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target, :media => :bridge, :direction => :recv
- subject << Punchblock::Event::Joined.new(call_uri: uri)
- subject << Punchblock::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
expect(subject).to be_alive
end
end
@@ -1290,11 +1285,11 @@
end
it "should return the command" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
- expect(result[:command]).to be_a Punchblock::Command::Join
+ expect(result[:command]).to be_a Adhearsion::Rayo::Command::Join
expect(result[:command].call_uri).to eql(uri)
expect(result[:command].media).to eql(:bridge)
expect(result[:command].direction).to eql(:recv)
end
@@ -1302,55 +1297,55 @@
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
expect(result[:joined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
expect(result[:joined_condition].wait(0.5)).to be_truthy
end
it "should return something that can be blocked on until the entities are unjoined" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Unjoined.new(call_uri: uri)
+ subject << Adhearsion::Event::Unjoined.new(call_uri: uri)
expect(result[:unjoined_condition].wait(0.5)).to be_truthy
end
it "should unblock all conditions on call end if no joined/unjoined events are received" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
expect(result[:joined_condition].wait(0.5)).to be_falsey
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::End.new
+ subject << Adhearsion::Event::End.new
expect(result[:joined_condition].wait(0.5)).to be_truthy
expect(result[:unjoined_condition].wait(0.5)).to be_truthy
end
it "should not error on call end when joined/unjoined events are received correctly" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
- subject << Punchblock::Event::Joined.new(call_uri: uri)
- subject << Punchblock::Event::Unjoined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Unjoined.new(call_uri: uri)
- subject << Punchblock::Event::End.new
+ subject << Adhearsion::Event::End.new
end
it "should not error if multiple joined events are received for the same join" do
expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
- subject << Punchblock::Event::Joined.new(call_uri: uri)
- subject << Punchblock::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
+ subject << Adhearsion::Event::Joined.new(call_uri: uri)
expect(subject).to be_alive
end
end
@@ -1371,11 +1366,11 @@
end
it "should return the command" do
expect_join_with_options :mixer_name => mixer_name, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
- expect(result[:command]).to be_a Punchblock::Command::Join
+ expect(result[:command]).to be_a Adhearsion::Rayo::Command::Join
expect(result[:command].mixer_name).to eql(mixer_name)
expect(result[:command].media).to eql(:bridge)
expect(result[:command].direction).to eql(:recv)
end
@@ -1383,55 +1378,55 @@
expect_join_with_options :mixer_name => mixer_name, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
expect(result[:joined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Joined.new(mixer_name: mixer_name)
+ subject << Adhearsion::Event::Joined.new(mixer_name: mixer_name)
expect(result[:joined_condition].wait(0.5)).to be_truthy
end
it "should return something that can be blocked on until the entities are unjoined" do
expect_join_with_options :mixer_name => mixer_name, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Joined.new(mixer_name: mixer_name)
+ subject << Adhearsion::Event::Joined.new(mixer_name: mixer_name)
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::Unjoined.new(mixer_name: mixer_name)
+ subject << Adhearsion::Event::Unjoined.new(mixer_name: mixer_name)
expect(result[:unjoined_condition].wait(0.5)).to be_truthy
end
it "should unblock all conditions on call end if no joined/unjoined events are received" do
expect_join_with_options :mixer_name => mixer_name, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
expect(result[:joined_condition].wait(0.5)).to be_falsey
expect(result[:unjoined_condition].wait(0.5)).to be_falsey
- subject << Punchblock::Event::End.new
+ subject << Adhearsion::Event::End.new
expect(result[:joined_condition].wait(0.5)).to be_truthy
expect(result[:unjoined_condition].wait(0.5)).to be_truthy
end
it "should not error on call end when joined/unjoined events are received correctly" do
expect_join_with_options :mixer_name => mixer_name, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
- subject << Punchblock::Event::Joined.new(mixer_name: mixer_name)
- subject << Punchblock::Event::Unjoined.new(mixer_name: mixer_name)
+ subject << Adhearsion::Event::Joined.new(mixer_name: mixer_name)
+ subject << Adhearsion::Event::Unjoined.new(mixer_name: mixer_name)
- subject << Punchblock::Event::End.new
+ subject << Adhearsion::Event::End.new
end
it "should not error if multiple joined events are received for the same join" do
expect_join_with_options :mixer_name => mixer_name, :media => :bridge, :direction => :recv
result = subject.join target.merge({:media => :bridge, :direction => :recv})
- subject << Punchblock::Event::Joined.new(mixer_name: mixer_name)
- subject << Punchblock::Event::Joined.new(mixer_name: mixer_name)
+ subject << Adhearsion::Event::Joined.new(mixer_name: mixer_name)
+ subject << Adhearsion::Event::Joined.new(mixer_name: mixer_name)
expect(subject).to be_alive
end
end
@@ -1445,22 +1440,22 @@
end
end
context "with a failure response" do
it 'should raise the error but not crash the actor' do
- error = Punchblock::ProtocolError.new.setup(:service_unavailable)
- expect_message_waiting_for_response Punchblock::Command::Join.new(call_id: 'footransport:foo@rayo.net'), error
+ error = Adhearsion::ProtocolError.new.setup(:service_unavailable)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Join.new(call_id: 'footransport:foo@rayo.net'), error
expect { subject.join 'foo' }.to raise_error error
sleep 0.2
expect(subject.alive?).to be true
end
end
end
describe "#unjoin" do
def expect_unjoin_with_options(options = {})
- Punchblock::Command::Unjoin.new(options).tap do |unjoin|
+ Adhearsion::Rayo::Command::Unjoin.new(options).tap do |unjoin|
expect_message_waiting_for_response unjoin
end
end
context "without a target" do
@@ -1523,46 +1518,46 @@
end
end
context "with a failure response" do
it 'should raise the error but not crash the actor' do
- error = Punchblock::ProtocolError.new.setup(:service_unavailable)
- expect_message_waiting_for_response Punchblock::Command::Unjoin.new(call_id: 'footransport:foo@rayo.net'), error
+ error = Adhearsion::ProtocolError.new.setup(:service_unavailable)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Unjoin.new(call_id: 'footransport:foo@rayo.net'), error
expect { subject.unjoin 'foo' }.to raise_error error
sleep 0.2
expect(subject.alive?).to be true
end
end
end
describe "#mute" do
it 'should send a Mute message' do
- expect_message_waiting_for_response Punchblock::Command::Mute.new
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Mute.new
subject.mute
end
context "with a failure response" do
it 'should raise the error but not crash the actor' do
- error = Punchblock::ProtocolError.new.setup(:service_unavailable)
- expect_message_waiting_for_response Punchblock::Command::Mute.new, error
+ error = Adhearsion::ProtocolError.new.setup(:service_unavailable)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Mute.new, error
expect { subject.mute }.to raise_error error
sleep 0.2
expect(subject.alive?).to be true
end
end
end
describe "#unmute" do
it 'should send a Mute message' do
- expect_message_waiting_for_response Punchblock::Command::Unmute.new
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Unmute.new
subject.unmute
end
context "with a failure response" do
it 'should raise the error but not crash the actor' do
- error = Punchblock::ProtocolError.new.setup(:service_unavailable)
- expect_message_waiting_for_response Punchblock::Command::Unmute.new, error
+ error = Adhearsion::ProtocolError.new.setup(:service_unavailable)
+ expect_message_waiting_for_response Adhearsion::Rayo::Command::Unmute.new, error
expect { subject.unmute }.to raise_error error
sleep 0.2
expect(subject.alive?).to be true
end
end
@@ -1602,11 +1597,10 @@
expect(l).to be subject.logger
latch.countdown!
end
subject.execute_controller BrokenController.new(subject), lambda { |call| latch.countdown! }
expect(latch.wait(3)).to be true
- Adhearsion::Events.clear_handlers :exception
end
it "should execute a callback after the controller executes" do
foo = nil
subject.execute_controller mock_controller, lambda { |call| foo = call; latch.countdown! }
@@ -1685,16 +1679,16 @@
end
describe "#terminate" do
let :commands do
[
- Punchblock::Command::Answer.new,
- Punchblock::Command::Answer.new
+ Adhearsion::Rayo::Command::Answer.new,
+ Adhearsion::Rayo::Command::Answer.new
]
end
it "should set each command's response to an instance of Adhearsion::Hangup if it doesn't already have a response" do
- finished_command = Punchblock::Command::Answer.new
+ finished_command = Adhearsion::Rayo::Command::Answer.new
finished_command.request!
finished_command.response = :foo
subject << finished_command
commands.each do |command|
command.request!