spec/punchblock/translator/freeswitch/call_spec.rb in punchblock-2.5.2 vs spec/punchblock/translator/freeswitch/call_spec.rb in punchblock-2.5.3
- old
+ new
@@ -163,59 +163,74 @@
}
end
subject { Call.new id, translator, es_env, stream }
- its(:id) { should be == id }
- its(:translator) { should be translator }
- its(:es_env) { should be == es_env }
- its(:stream) { should be stream }
+ describe '#id' do
+ subject { super().id }
+ it { should be == id }
+ end
+ describe '#translator' do
+ subject { super().translator }
+ it { should be translator }
+ end
+
+ describe '#es_env' do
+ subject { super().es_env }
+ it { should be == es_env }
+ end
+
+ describe '#stream' do
+ subject { super().stream }
+ it { should be stream }
+ end
+
describe '#register_component' do
it 'should make the component accessible by ID' do
component_id = 'abc123'
component = double 'Translator::Freeswitch::Component', :id => component_id
subject.register_component component
- subject.component_with_id(component_id).should be component
+ expect(subject.component_with_id(component_id)).to be component
end
end
describe '#send_offer' do
it 'sends an offer to the translator' do
expected_offer = Punchblock::Event::Offer.new :target_call_id => subject.id,
:to => "10@127.0.0.1",
:from => "Extension 1000 <1000@127.0.0.1>",
:headers => headers
- translator.should_receive(:handle_pb_event).with expected_offer
+ expect(translator).to receive(:handle_pb_event).with expected_offer
subject.send_offer
end
it 'should make the call identify as inbound' do
subject.send_offer
- subject.direction.should be == :inbound
- subject.inbound?.should be true
- subject.outbound?.should be false
+ expect(subject.direction).to eq(:inbound)
+ expect(subject.inbound?).to be true
+ expect(subject.outbound?).to be false
end
end
describe "#application" do
it "should execute a FS application on the current call" do
- stream.should_receive(:application).once.with(id, 'appname', 'options')
+ expect(stream).to receive(:application).once.with(id, 'appname', 'options')
subject.application 'appname', 'options'
end
end
describe "#sendmsg" do
it "should execute a FS sendmsg on the current call" do
- stream.should_receive(:sendmsg).once.with(id, 'msg', :foo => 'bar')
+ expect(stream).to receive(:sendmsg).once.with(id, 'msg', :foo => 'bar')
subject.sendmsg 'msg', :foo => 'bar'
end
end
describe "#uuid_foo" do
it "should execute a FS uuid_* on the current call using bgapi" do
- stream.should_receive(:bgapi).once.with("uuid_record #{id} blah.mp3")
+ expect(stream).to receive(:bgapi).once.with("uuid_record #{id} blah.mp3")
subject.uuid_foo 'record', 'blah.mp3'
end
end
describe '#dial' do
@@ -229,97 +244,97 @@
end
before { dial_command.request! }
it 'sends an originate bgapi command' do
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}'}#{to} &park()"
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}'}#{to} &park()"
subject.dial dial_command
end
context 'with a name and channel in the from field' do
let(:from_name) { 'Jane Smith' }
let(:from_number) { '1001' }
let(:from) { "#{from_name} <#{from_number}>" }
it 'sends an originate bgapi command with the cid fields set correctly' do
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from_number}',origination_caller_id_name='#{from_name}'}#{to} &park()"
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from_number}',origination_caller_id_name='#{from_name}'}#{to} &park()"
subject.dial dial_command
end
end
context 'with a name and empty channel in the from field' do
let(:from_name) { 'Jane Smith' }
let(:from_number) { '' }
let(:from) { "#{from_name} <#{from_number}>" }
it 'sends an originate bgapi command with the cid fields set correctly' do
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_name='#{from_name}'}#{to} &park()"
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_name='#{from_name}'}#{to} &park()"
subject.dial dial_command
end
end
context 'with a number in the from field with angled brackets' do
let(:from_number) { '1001' }
let(:from) { "<#{from_number}>" }
it 'sends an originate bgapi command with the cid fields set correctly' do
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from_number}'}#{to} &park()"
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from_number}'}#{to} &park()"
subject.dial dial_command
end
end
context 'with an empty from attribute' do
let(:from) { '' }
it 'sends an originate bgapi command with the cid fields set correctly' do
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id}}#{to} &park()"
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id}}#{to} &park()"
subject.dial dial_command
end
end
context 'with no from attribute' do
let(:from) { nil }
it 'sends an originate bgapi command with the cid fields set correctly' do
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id}}#{to} &park()"
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id}}#{to} &park()"
subject.dial dial_command
end
end
context 'with a timeout specified' do
let :dial_command_options do
{ :timeout => 10000 }
end
it 'includes the timeout in the originate command' do
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}',originate_timeout=10}#{to} &park()"
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}',originate_timeout=10}#{to} &park()"
subject.dial dial_command
end
end
context 'with headers specified' do
let :dial_command_options do
{ :headers => {'X-foo' => 'bar', 'X-doo' => 'dah'} }
end
it 'includes the headers in the originate command' do
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}',sip_h_X-foo='bar',sip_h_X-doo='dah'}#{to} &park()"
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}',sip_h_X-foo='bar',sip_h_X-doo='dah'}#{to} &park()"
subject.dial dial_command
end
end
it 'sends the call ID as a response to the Dial' do
subject.dial dial_command
dial_command.response
- dial_command.target_call_id.should be == subject.id
+ expect(dial_command.target_call_id).to eq(subject.id)
end
it 'should make the call identify as outbound' do
subject.dial dial_command
- subject.direction.should be == :outbound
- subject.outbound?.should be true
- subject.inbound?.should be false
+ expect(subject.direction).to eq(:outbound)
+ expect(subject.outbound?).to be true
+ expect(subject.inbound?).to be false
end
end
describe '#handle_es_event' do
context 'with a CHANNEL_HANGUP event' do
@@ -337,35 +352,35 @@
end
let(:cause) { 'ORIGINATOR_CANCEL' }
it "should cause the actor to be terminated" do
- translator.should_receive(:handle_pb_event).once
+ expect(translator).to receive(:handle_pb_event).once
subject.handle_es_event es_event
sleep 0.25
- subject.should_not be_alive
+ expect(subject.alive?).to be false
end
it "de-registers the call from the translator" do
- translator.stub :handle_pb_event
- translator.should_receive(:deregister_call).once.with(id)
+ allow(translator).to receive :handle_pb_event
+ expect(translator).to receive(:deregister_call).once.with(id)
subject.handle_es_event es_event
end
it "should cause all components to send complete events before sending end event" do
ssml_doc = RubySpeech::SSML.draw { audio { 'foo.wav' } }
comp_command = Punchblock::Component::Output.new :render_document => {:value => ssml_doc}
comp_command.request!
component = subject.execute_command comp_command
- comp_command.response(0.1).should be_a Ref
+ expect(comp_command.response(0.1)).to be_a Ref
expected_complete_event = Punchblock::Event::Complete.new :target_call_id => subject.id, :component_id => component.id, source_uri: component.id
expected_complete_event.reason = Punchblock::Event::Complete::Hangup.new
expected_end_event = Punchblock::Event::End.new :reason => :hangup, :target_call_id => subject.id
- translator.should_receive(:handle_pb_event).with(expected_complete_event).once.ordered
- translator.should_receive(:handle_pb_event).with(expected_end_event).once.ordered
+ expect(translator).to receive(:handle_pb_event).with(expected_complete_event).once.ordered
+ expect(translator).to receive(:handle_pb_event).with(expected_end_event).once.ordered
subject.handle_es_event es_event
end
[
'NORMAL_CLEARING',
@@ -380,11 +395,11 @@
let(:cause) { cause }
it 'should send an end (hangup) event to the translator' do
expected_end_event = Punchblock::Event::End.new :reason => :hangup,
:target_call_id => subject.id
- translator.should_receive(:handle_pb_event).with expected_end_event
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
subject.handle_es_event es_event
end
end
end
@@ -392,22 +407,22 @@
let(:cause) { 'MANAGER_REQUEST' }
it 'should send an end (hangup-command) event to the translator' do
expected_end_event = Punchblock::Event::End.new :reason => :hangup_command,
:target_call_id => subject.id
- translator.should_receive(:handle_pb_event).with expected_end_event
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
subject.handle_es_event es_event
end
end
context "with a user busy cause" do
let(:cause) { 'USER_BUSY' }
it 'should send an end (busy) event to the translator' do
expected_end_event = Punchblock::Event::End.new :reason => :busy,
:target_call_id => subject.id
- translator.should_receive(:handle_pb_event).with expected_end_event
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
subject.handle_es_event es_event
end
end
[
@@ -422,11 +437,11 @@
let(:cause) { cause }
it 'should send an end (timeout) event to the translator' do
expected_end_event = Punchblock::Event::End.new :reason => :timeout,
:target_call_id => subject.id
- translator.should_receive(:handle_pb_event).with expected_end_event
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
subject.handle_es_event es_event
end
end
end
@@ -453,11 +468,11 @@
let(:cause) { cause }
it 'should send an end (reject) event to the translator' do
expected_end_event = Punchblock::Event::End.new :reason => :reject,
:target_call_id => subject.id
- translator.should_receive(:handle_pb_event).with expected_end_event
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
subject.handle_es_event es_event
end
end
end
@@ -497,11 +512,11 @@
let(:cause) { cause }
it 'should send an end (error) event to the translator' do
expected_end_event = Punchblock::Event::End.new :reason => :error,
:target_call_id => subject.id
- translator.should_receive(:handle_pb_event).with expected_end_event
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
subject.handle_es_event es_event
end
end
end
end
@@ -519,11 +534,11 @@
before do
subject.register_component component
end
it 'should send the event to the component' do
- component.should_receive(:handle_es_event).once.with es_event
+ expect(component).to receive(:handle_es_event).once.with es_event
subject.handle_es_event es_event
end
end
context 'with a CHANNEL_STATE event' do
@@ -538,31 +553,31 @@
let(:channel_call_state) { 'RINGING' }
it 'should send a ringing event' do
expected_ringing = Punchblock::Event::Ringing.new
expected_ringing.target_call_id = subject.id
- translator.should_receive(:handle_pb_event).with expected_ringing
+ expect(translator).to receive(:handle_pb_event).with expected_ringing
subject.handle_es_event es_event
end
it '#answered? should return false' do
subject.handle_es_event es_event
- subject.should_not be_answered
+ expect(subject).not_to be_answered
end
end
context 'something else' do
let(:channel_call_state) { 'FOO' }
it 'should not send a ringing event' do
- translator.should_receive(:handle_pb_event).never
+ expect(translator).to receive(:handle_pb_event).never
subject.handle_es_event es_event
end
it '#answered? should return false' do
subject.handle_es_event es_event
- subject.should_not be_answered
+ expect(subject).not_to be_answered
end
end
end
context 'with a CHANNEL_ANSWER event' do
@@ -571,17 +586,17 @@
end
it 'should send an answered event' do
expected_answered = Punchblock::Event::Answered.new
expected_answered.target_call_id = subject.id
- translator.should_receive(:handle_pb_event).with expected_answered
+ expect(translator).to receive(:handle_pb_event).with expected_answered
subject.handle_es_event es_event
end
it '#answered? should be true' do
subject.handle_es_event es_event
- subject.should be_answered
+ expect(subject).to be_answered
end
end
context 'with a handler registered for a matching event' do
let :es_event do
@@ -589,11 +604,11 @@
end
let(:response) { double 'Response' }
it 'should execute the handler' do
- response.should_receive(:call).once.with es_event
+ expect(response).to receive(:call).once.with es_event
subject.register_handler :es, :event_name => 'DTMF' do |event|
response.call event
end
subject.handle_es_event es_event
end
@@ -615,11 +630,11 @@
:other_leg_unique_id => other_call_id
}
end
it "should send a joined event with the correct call ID" do
- translator.should_receive(:handle_pb_event).with expected_joined
+ expect(translator).to receive(:handle_pb_event).with expected_joined
subject.handle_es_event bridge_event
end
end
context "where this is the joined call" do
@@ -630,11 +645,11 @@
:other_leg_unique_id => id
}
end
it "should send a joined event with the correct call ID" do
- translator.should_receive(:handle_pb_event).with expected_joined
+ expect(translator).to receive(:handle_pb_event).with expected_joined
subject.handle_es_event bridge_event
end
end
end
@@ -654,11 +669,11 @@
:other_leg_unique_id => other_call_id
}
end
it "should send a unjoined event with the correct call ID" do
- translator.should_receive(:handle_pb_event).with expected_unjoined
+ expect(translator).to receive(:handle_pb_event).with expected_unjoined
subject.handle_es_event unbridge_event
end
end
context "where this is the joined call" do
@@ -669,11 +684,11 @@
:other_leg_unique_id => id
}
end
it "should send a unjoined event with the correct call ID" do
- translator.should_receive(:handle_pb_event).with expected_unjoined
+ expect(translator).to receive(:handle_pb_event).with expected_unjoined
subject.handle_es_event unbridge_event
end
end
end
end
@@ -685,92 +700,92 @@
context 'with an accept command' do
let(:command) { Command::Accept.new }
it "should send a respond 180 command and set the command's response" do
- subject.wrapped_object.should_receive(:application).once.with('respond', '180 Ringing')
+ expect(subject.wrapped_object).to receive(:application).once.with('respond', '180 Ringing')
subject.execute_command command
- command.response(0.5).should be true
+ expect(command.response(0.5)).to be true
end
end
context 'with an answer command' do
let(:command) { Command::Answer.new }
it "should execute the answer application and set the command's response" do
subject
- Punchblock.should_receive(:new_uuid).once.and_return 'abc123'
- subject.wrapped_object.should_receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
- subject.should_not be_answered
+ expect(Punchblock).to receive(:new_uuid).once.and_return 'abc123'
+ expect(subject.wrapped_object).to receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
+ expect(subject).not_to be_answered
subject.execute_command command
subject.handle_es_event RubyFS::Event.new(nil, :event_name => 'CHANNEL_ANSWER', :scope_variable_punchblock_command_id => 'abc123')
- command.response(0.5).should be true
- subject.should be_answered
+ expect(command.response(0.5)).to be true
+ expect(subject).to be_answered
end
it "should not execute the answer application twice if already answered" do
subject
- Punchblock.should_receive(:new_uuid).once.and_return 'abc123'
- subject.wrapped_object.should_receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
- subject.should_not be_answered
+ expect(Punchblock).to receive(:new_uuid).once.and_return 'abc123'
+ expect(subject.wrapped_object).to receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
+ expect(subject).not_to be_answered
subject.execute_command command
subject.handle_es_event RubyFS::Event.new(nil, :event_name => 'CHANNEL_ANSWER', :scope_variable_punchblock_command_id => 'abc123')
- command.response(0.5).should be true
- subject.should be_answered
+ expect(command.response(0.5)).to be true
+ expect(subject).to be_answered
subject.execute_command command
end
context "when a component has previously been executed" do
it "should set the answer command's response correctly" do
subject
- Punchblock.should_receive(:new_uuid).once.and_return 'abc123'
- subject.wrapped_object.should_receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
- subject.should_not be_answered
+ expect(Punchblock).to receive(:new_uuid).once.and_return 'abc123'
+ expect(subject.wrapped_object).to receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
+ expect(subject).not_to be_answered
subject.execute_command command
subject.handle_es_event RubyFS::Event.new(nil, :event_name => 'CHANNEL_ANSWER', :scope_variable_punchblock_command_id => 'abc123', :scope_variable_punchblock_component_id => 'dj182989j')
- command.response(0.5).should be true
- subject.should be_answered
+ expect(command.response(0.5)).to be true
+ expect(subject).to be_answered
end
end
end
def expect_hangup_with_reason(reason)
- subject.wrapped_object.should_receive(:sendmsg).once.with(:call_command => 'hangup', :hangup_cause => reason)
+ expect(subject.wrapped_object).to receive(:sendmsg).once.with(:call_command => 'hangup', :hangup_cause => reason)
end
context 'with a hangup command' do
let(:command) { Command::Hangup.new }
it "should send a hangup message and set the command's response" do
expect_hangup_with_reason 'MANAGER_REQUEST'
subject.execute_command command
- command.response(0.5).should be true
+ expect(command.response(0.5)).to be true
end
end
context 'with a reject command' do
let(:command) { Command::Reject.new }
it "with a :busy reason should send a USER_BUSY hangup command and set the command's response" do
command.reason = :busy
expect_hangup_with_reason 'USER_BUSY'
subject.execute_command command
- command.response(0.5).should be true
+ expect(command.response(0.5)).to be true
end
it "with a :decline reason should send a CALL_REJECTED hangup command and set the command's response" do
command.reason = :decline
expect_hangup_with_reason 'CALL_REJECTED'
subject.execute_command command
- command.response(0.5).should be true
+ expect(command.response(0.5)).to be true
end
it "with an :error reason should send a NORMAL_TEMPORARY_FAILURE hangup command and set the command's response" do
command.reason = :error
expect_hangup_with_reason 'NORMAL_TEMPORARY_FAILURE'
subject.execute_command command
- command.response(0.5).should be true
+ expect(command.response(0.5)).to be true
end
end
context 'with an Output component' do
let :command do
@@ -782,48 +797,48 @@
['freeswitch', 'native', nil].each do |renderer|
let(:renderer) { renderer }
context "with a renderer of #{renderer}" do
it 'should create an Output component and execute it asynchronously' do
- Component::Output.should_receive(:new_link).once.with(command, subject).and_return mock_component
- mock_component.should_receive(:execute).once
+ expect(Component::Output).to receive(:new_link).once.with(command, subject).and_return mock_component
+ expect(mock_component).to receive(:execute).once
subject.execute_command command
- subject.component_with_id(mock_component.id).should be mock_component
+ expect(subject.component_with_id(mock_component.id)).to be mock_component
end
end
end
context 'with the renderer of :flite' do
let(:renderer) { :flite }
it 'should create a FliteOutput component and execute it asynchronously using flite and the calls default voice' do
- Component::FliteOutput.should_receive(:new_link).once.with(command, subject).and_return mock_component
- mock_component.should_receive(:execute).once
+ expect(Component::FliteOutput).to receive(:new_link).once.with(command, subject).and_return mock_component
+ expect(mock_component).to receive(:execute).once
subject.execute_command command
- subject.component_with_id(mock_component.id).should be mock_component
+ expect(subject.component_with_id(mock_component.id)).to be mock_component
end
end
context 'with the renderer of :cepstral' do
let(:renderer) { :cepstral }
it 'should create a TTSOutput component and execute it asynchronously using cepstral and the calls default voice' do
- Component::TTSOutput.should_receive(:new_link).once.with(command, subject).and_return mock_component
- mock_component.should_receive(:execute).once
+ expect(Component::TTSOutput).to receive(:new_link).once.with(command, subject).and_return mock_component
+ expect(mock_component).to receive(:execute).once
subject.execute_command command
- subject.component_with_id(mock_component.id).should be mock_component
+ expect(subject.component_with_id(mock_component.id)).to be mock_component
end
end
context 'with the renderer of :unimrcp' do
let(:renderer) { :unimrcp }
it 'should create a TTSOutput component and execute it asynchronously using unimrcp and the calls default voice' do
- Component::TTSOutput.should_receive(:new_link).once.with(command, subject).and_return mock_component
- mock_component.should_receive(:execute).once
+ expect(Component::TTSOutput).to receive(:new_link).once.with(command, subject).and_return mock_component
+ expect(mock_component).to receive(:execute).once
subject.execute_command command
- subject.component_with_id(mock_component.id).should be mock_component
+ expect(subject.component_with_id(mock_component.id)).to be mock_component
end
end
end
context 'with an Input component' do
@@ -832,12 +847,12 @@
end
let(:mock_component) { Translator::Freeswitch::Component::Input.new(command, subject) }
it 'should create an Input component and execute it asynchronously' do
- Component::Input.should_receive(:new_link).once.with(command, subject).and_return mock_component
- mock_component.should_receive(:execute).once
+ expect(Component::Input).to receive(:new_link).once.with(command, subject).and_return mock_component
+ expect(mock_component).to receive(:execute).once
subject.execute_command command
end
end
context 'with a Record component' do
@@ -846,12 +861,12 @@
end
let(:mock_component) { Translator::Freeswitch::Component::Record.new(command, subject) }
it 'should create a Record component and execute it asynchronously' do
- Component::Record.should_receive(:new_link).once.with(command, subject).and_return mock_component
- mock_component.should_receive(:execute).once
+ expect(Component::Record).to receive(:new_link).once.with(command, subject).and_return mock_component
+ expect(mock_component).to receive(:execute).once
subject.execute_command command
end
end
context 'with a component command' do
@@ -867,11 +882,11 @@
context "for a known component ID" do
before { subject.register_component mock_component }
it 'should send the command to the component for execution' do
- mock_component.should_receive(:execute_command).once
+ expect(mock_component).to receive(:execute_command).once
subject.execute_command command
end
end
context "for a component which began executing but crashed" do
@@ -900,27 +915,27 @@
component.wrapped_object.define_singleton_method(:oops) do
raise 'Woops, I died'
end
- translator.should_receive(:handle_pb_event).once.with expected_event
+ expect(translator).to receive(:handle_pb_event).once.with expected_event
- lambda { component.oops }.should raise_error(/Woops, I died/)
+ expect { component.oops }.to raise_error(/Woops, I died/)
sleep 0.1
- component.should_not be_alive
- subject.component_with_id(comp_id).should be_nil
+ expect(component.alive?).to be false
+ expect(subject.component_with_id(comp_id)).to be_nil
subsequent_command.request!
subject.execute_command subsequent_command
- subsequent_command.response.should be == ProtocolError.new.setup(:item_not_found, "Could not find a component with ID #{comp_id} for call #{subject.id}", subject.id, comp_id)
+ expect(subsequent_command.response).to eq(ProtocolError.new.setup(:item_not_found, "Could not find a component with ID #{comp_id} for call #{subject.id}", subject.id, comp_id))
end
end
context "for an unknown component ID" do
it 'sends an error in response to the command' do
subject.execute_command command
- command.response.should be == ProtocolError.new.setup(:item_not_found, "Could not find a component with ID #{component_id} for call #{subject.id}", subject.id, component_id)
+ expect(command.response).to eq(ProtocolError.new.setup(:item_not_found, "Could not find a component with ID #{component_id} for call #{subject.id}", subject.id, component_id))
end
end
end
context 'with a command we do not understand' do
@@ -928,11 +943,11 @@
Punchblock::Command::Mute.new
end
it 'sends an error in response to the command' do
subject.execute_command command
- command.response.should be == ProtocolError.new.setup('command-not-acceptable', "Did not understand command for call #{subject.id}", subject.id)
+ expect(command.response).to eq(ProtocolError.new.setup('command-not-acceptable', "Did not understand command for call #{subject.id}", subject.id))
end
end
context "with a join command" do
let(:other_call_id) { Punchblock.new_uuid }
@@ -940,11 +955,11 @@
let :command do
Punchblock::Command::Join.new :call_uri => other_call_id
end
it "executes the proper uuid_bridge command" do
- subject.wrapped_object.should_receive(:uuid_foo).once.with :bridge, other_call_id
+ expect(subject.wrapped_object).to receive(:uuid_foo).once.with :bridge, other_call_id
subject.execute_command command
expect { command.response 1 }.to raise_exception(Timeout::Error)
end
context "subsequently receiving a CHANNEL_BRIDGE event" do
@@ -959,11 +974,11 @@
subject.execute_command command
end
it "should set the command response to true" do
subject.handle_es_event bridge_event
- command.response.should be_true
+ expect(command.response).to be_true
end
end
end
context "with an unjoin command" do
@@ -972,11 +987,11 @@
let :command do
Punchblock::Command::Unjoin.new :call_uri => other_call_id
end
it "executes the unjoin via transfer to park" do
- subject.wrapped_object.should_receive(:uuid_foo).once.with :transfer, '-both park inline'
+ expect(subject.wrapped_object).to receive(:uuid_foo).once.with :transfer, '-both park inline'
subject.execute_command command
expect { command.response 1 }.to raise_exception(Timeout::Error)
end
context "subsequently receiving a CHANNEL_UNBRIDGE event" do
@@ -991,10 +1006,10 @@
subject.execute_command command
end
it "should set the command response to true" do
subject.handle_es_event unbridge_event
- command.response.should be_true
+ expect(command.response).to be_true
end
end
end
end
end