spec/punchblock/translator/freeswitch/call_spec.rb in punchblock-1.8.0 vs spec/punchblock/translator/freeswitch/call_spec.rb in punchblock-1.8.1
- old
+ new
@@ -277,10 +277,19 @@
stream.should_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()"
+ subject.dial dial_command
+ end
+ end
+
context 'with a timeout specified' do
let :dial_command_options do
{ :timeout => 10000 }
end
@@ -763,55 +772,55 @@
context 'with an Output component' do
let :command do
Punchblock::Component::Output.new
end
- let(:mock_component) { mock 'Freeswitch::Component::Output', :id => 'foo' }
+ let(:mock_component) { Translator::Freeswitch::Component::Output.new(command, subject) }
['freeswitch', nil].each do |media_engine|
let(:media_engine) { media_engine }
context "with a media engine of #{media_engine}" 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
+ mock_component.async.should_receive(:execute).once
subject.execute_command command
- subject.component_with_id('foo').should be mock_component
+ subject.component_with_id(mock_component.id).should be mock_component
end
end
end
context 'with the media engine of :flite' do
let(:media_engine) { :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.with(media_engine, default_voice)
+ mock_component.async.should_receive(:execute).once.with(media_engine, default_voice)
subject.execute_command command
- subject.component_with_id('foo').should be mock_component
+ subject.component_with_id(mock_component.id).should be mock_component
end
end
context 'with the media engine of :cepstral' do
let(:media_engine) { :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.with(media_engine, default_voice)
+ mock_component.async.should_receive(:execute).once.with(media_engine, default_voice)
subject.execute_command command
- subject.component_with_id('foo').should be mock_component
+ subject.component_with_id(mock_component.id).should be mock_component
end
end
context 'with the media engine of :unimrcp' do
let(:media_engine) { :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.with(media_engine, default_voice)
+ mock_component.async.should_receive(:execute).once.with(media_engine, default_voice)
subject.execute_command command
- subject.component_with_id('foo').should be mock_component
+ subject.component_with_id(mock_component.id).should be mock_component
end
end
context "with a media renderer set on the component" do
let(:media_engine) { :cepstral }
@@ -820,40 +829,40 @@
Punchblock::Component::Output.new :renderer => media_renderer
end
it "should use the component media engine and not the platform one if it is set" do
Component::Output.should_receive(:new_link).once.with(command_with_renderer, subject).and_return mock_component
- mock_component.should_receive(:execute!).once
+ mock_component.async.should_receive(:execute).once
subject.execute_command command_with_renderer
- subject.component_with_id('foo').should be mock_component
+ subject.component_with_id(mock_component.id).should be mock_component
end
end
end
context 'with an Input component' do
let :command do
Punchblock::Component::Input.new
end
- let(:mock_component) { mock 'Freeswitch::Component::Input', :id => 'foo' }
+ 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
+ mock_component.async.should_receive(:execute).once
subject.execute_command command
end
end
context 'with a Record component' do
let :command do
Punchblock::Component::Record.new
end
- let(:mock_component) { mock 'Freeswitch::Component::Record', :id => 'foo' }
+ 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
+ mock_component.async.should_receive(:execute).once
subject.execute_command command
end
end
context 'with a component command' do