spec/punchblock/translator/freeswitch/call_spec.rb in punchblock-2.0.0.beta1 vs spec/punchblock/translator/freeswitch/call_spec.rb in punchblock-2.0.0.beta2

- old
+ new

@@ -4,14 +4,12 @@ module Punchblock module Translator class Freeswitch describe Call do - let(:id) { Punchblock.new_uuid } + let(:id) { Punchblock.new_uuid } let(:stream) { double('RubyFS::Stream').as_null_object } - let(:media_engine) { 'freeswitch' } - let(:default_voice) { :hal } let(:translator) { Freeswitch.new double('Connection::Freeswitch').as_null_object } let(:es_env) do { :variable_direction => "inbound", :variable_uuid => "3f0e1e18-c056-11e1-b099-fffeda3ce54f", @@ -163,17 +161,16 @@ 'X-variable_export_vars' => "RFC2822_DATE", 'X-variable_current_application' => "park" } end - subject { Call.new id, translator, es_env, stream, media_engine, default_voice } + 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 } - its(:media_engine) { should be media_engine } + its(:id) { should be == id } + its(:translator) { should be translator } + its(:es_env) { should be == es_env } + its(:stream) { should be stream } describe '#register_component' do it 'should make the component accessible by ID' do component_id = 'abc123' component = double 'Translator::Freeswitch::Component', :id => component_id @@ -775,71 +772,56 @@ end end context 'with an Output component' do let :command do - Punchblock::Component::Output.new + Punchblock::Component::Output.new renderer: renderer end let(:mock_component) { Translator::Freeswitch::Component::Output.new(command, subject) } - ['freeswitch', nil].each do |media_engine| - let(:media_engine) { media_engine } + ['freeswitch', 'native', nil].each do |renderer| + let(:renderer) { renderer } - context "with a media engine of #{media_engine}" do + 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 subject.execute_command command 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 } + 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.with(media_engine, default_voice) + mock_component.should_receive(:execute).once subject.execute_command command 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 } + 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.with(media_engine, default_voice) + mock_component.should_receive(:execute).once subject.execute_command command 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 } + 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.with(media_engine, default_voice) - subject.execute_command command - 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 } - let(:media_renderer) { :native } - let :command_with_renderer do - 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 - subject.execute_command command_with_renderer + subject.execute_command command subject.component_with_id(mock_component.id).should be mock_component end end end