spec/punchblock/translator/asterisk/component/output_spec.rb in punchblock-2.0.0.beta1 vs spec/punchblock/translator/asterisk/component/output_spec.rb in punchblock-2.0.0.beta2
- old
+ new
@@ -7,14 +7,14 @@
class Asterisk
module Component
describe Output do
include HasMockCallbackConnection
- let(:media_engine) { nil }
- let(:ami_client) { double('AMI') }
- let(:translator) { Punchblock::Translator::Asterisk.new ami_client, connection, media_engine }
- let(:mock_call) { Punchblock::Translator::Asterisk::Call.new 'foo', translator, ami_client, connection }
+ let(:renderer) { nil }
+ let(:ami_client) { double('AMI') }
+ let(:translator) { Punchblock::Translator::Asterisk.new ami_client, connection }
+ let(:mock_call) { Punchblock::Translator::Asterisk::Call.new 'foo', translator, ami_client, connection }
let :original_command do
Punchblock::Component::Output.new command_options
end
@@ -22,12 +22,14 @@
RubySpeech::SSML.draw do
say_as(:interpret_as => :cardinal) { 'FOO' }
end
end
+ let(:command_opts) { {} }
+
let :command_options do
- { :render_document => {:value => ssml_doc} }
+ { :render_document => {:value => ssml_doc}, renderer: renderer }
end
subject { Output.new original_command, mock_call }
def expect_answered(value = true)
@@ -35,36 +37,34 @@
end
describe '#execute' do
before { original_command.request! }
- context 'with an invalid media engine' do
- let(:media_engine) { 'foobar' }
+ context 'with an invalid renderer' do
+ let(:renderer) { 'foobar' }
it "should return an error and not execute any actions" do
subject.execute
error = ProtocolError.new.setup 'option error', 'The renderer foobar is unsupported.'
original_command.response(0.1).should be == error
end
end
- context 'with a media engine of :swift' do
- let(:media_engine) { 'swift' }
+ context 'with a renderer of :swift' do
+ let(:renderer) { 'swift' }
let(:audio_filename) { 'http://foo.com/bar.mp3' }
let :ssml_doc do
RubySpeech::SSML.draw do
audio :src => audio_filename
say_as(:interpret_as => :cardinal) { 'FOO' }
end
end
- let(:command_opts) { {} }
-
let :command_options do
- { :render_document => {:value => ssml_doc} }.merge(command_opts)
+ { :render_document => {:value => ssml_doc}, renderer: renderer }.merge(command_opts)
end
def ssml_with_options(prefix = '', postfix = '')
base_doc = ssml_doc.to_s.squish.gsub(/["\\]/) { |m| "\\#{m}" }
prefix + base_doc + postfix
@@ -167,12 +167,12 @@
end
end
end
- context 'with a media engine of :unimrcp' do
- let(:media_engine) { :unimrcp }
+ context 'with a renderer of :unimrcp' do
+ let(:renderer) { :unimrcp }
let(:audio_filename) { 'http://foo.com/bar.mp3' }
let :ssml_doc do
RubySpeech::SSML.draw do
@@ -182,11 +182,11 @@
end
let(:command_opts) { {} }
let :command_options do
- { :render_document => {:value => ssml_doc} }.merge(command_opts)
+ { :render_document => {:value => ssml_doc}, renderer: renderer }.merge(command_opts)
end
let(:synthstatus) { 'OK' }
before { mock_call.stub(:channel_var).with('SYNTHSTATUS').and_return synthstatus }
@@ -420,12 +420,12 @@
end
end
end
end
- [:asterisk, nil].each do |media_engine|
- context "with a media engine of #{media_engine.inspect}" do
+ [:asterisk, nil].each do |renderer|
+ context "with a renderer of #{renderer.inspect}" do
def expect_playback(filename = audio_filename)
mock_call.should_receive(:execute_agi_command).once.with('EXEC Playback', filename).and_return code: 200
end
def expect_playback_noanswer
@@ -441,11 +441,11 @@
end
let(:command_opts) { {} }
let :command_options do
- { :render_document => {:value => ssml_doc} }.merge(command_opts)
+ { :render_document => {:value => ssml_doc}, renderer: renderer }.merge(command_opts)
end
let :original_command do
Punchblock::Component::Output.new command_options
end
@@ -860,38 +860,9 @@
error = ProtocolError.new.setup 'option error', 'An interrupt-on value of speech is unsupported.'
original_command.response(0.1).should be == error
end
end
end
- end
- end
-
- context "with a media renderer set on itself" do
- let(:media_engine) { :swift }
- let(:audio_filename) { '/foo/bar.wav' }
- let :ssml_doc do
- RubySpeech::SSML.draw do
- audio :src => audio_filename
- end
- end
-
- let(:command_opts) { {:renderer => :asterisk} }
-
- let :command_options do
- { :render_document => {:value => ssml_doc} }.merge(command_opts)
- end
-
- let :original_command do
- Punchblock::Component::Output.new command_options
- end
-
- let(:playbackstatus) { 'SUCCESS' }
- before { mock_call.stub(:channel_var).with('PLAYBACKSTATUS').and_return playbackstatus }
-
- it "should use the media renderer set and not the platform default" do
- expect_answered
- mock_call.should_receive(:execute_agi_command).once.with 'EXEC Playback', audio_filename
- subject.execute
end
end
end
describe "#execute_command" do