spec/punchblock/translator/asterisk_spec.rb in punchblock-1.8.2 vs spec/punchblock/translator/asterisk_spec.rb in punchblock-1.9.0
- old
+ new
@@ -5,11 +5,11 @@
module Punchblock
module Translator
describe Asterisk do
let(:ami_client) { mock 'RubyAMI::Client' }
- let(:connection) { mock 'Connection::Asterisk' }
+ let(:connection) { mock 'Connection::Asterisk', handle_event: nil }
let(:media_engine) { :asterisk }
let(:translator) { Asterisk.new ami_client, connection, media_engine }
subject { translator }
@@ -29,11 +29,11 @@
its(:media_engine) { should be == :unimrcp }
end
describe '#shutdown' do
it "instructs all calls to shutdown" do
- call = Asterisk::Call.new 'foo', subject
+ call = Asterisk::Call.new 'foo', subject, ami_client, connection
call.async.should_receive(:shutdown).once
subject.register_call call
subject.shutdown
end
@@ -82,11 +82,11 @@
end
describe '#register_call' do
let(:call_id) { 'abc123' }
let(:channel) { 'SIP/foo' }
- let(:call) { Translator::Asterisk::Call.new channel, subject }
+ let(:call) { Translator::Asterisk::Call.new channel, subject, ami_client, connection }
before do
call.stub(:id).and_return call_id
subject.register_call call
end
@@ -101,11 +101,11 @@
end
describe '#deregister_call' do
let(:call_id) { 'abc123' }
let(:channel) { 'SIP/foo' }
- let(:call) { Translator::Asterisk::Call.new channel, subject }
+ let(:call) { Translator::Asterisk::Call.new channel, subject, ami_client, connection }
before do
call.stub(:id).and_return call_id
subject.register_call call
end
@@ -136,11 +136,11 @@
describe '#execute_call_command' do
let(:call_id) { 'abc123' }
let(:command) { Command::Answer.new.tap { |c| c.target_call_id = call_id } }
context "with a known call ID" do
- let(:call) { Translator::Asterisk::Call.new 'SIP/foo', subject }
+ let(:call) { Translator::Asterisk::Call.new 'SIP/foo', subject, ami_client, connection }
before do
command.request!
call.stub(:id).and_return call_id
subject.register_call call
@@ -163,12 +163,12 @@
let(:dial_command) { Command::Dial.new :to => 'SIP/1234', :from => 'abc123' }
let(:call_id) { dial_command.response.id }
before do
+ subject.async.should_receive(:execute_global_command)
subject.execute_command dial_command
- ami_client.as_null_object
end
it 'sends an error in response to the command' do
call = subject.call_with_id call_id
@@ -189,15 +189,14 @@
end
end
context "for an incoming call which began executing but crashed" do
let :ami_event do
- RubyAMI::Event.new('AsyncAGI').tap do |e|
- e['SubEvent'] = "Start"
- e['Channel'] = "SIP/1234-00000000"
- e['Env'] = "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
- end
+ RubyAMI::Event.new 'AsyncAGI',
+ 'SubEvent' => "Start",
+ 'Channel' => "SIP/1234-00000000",
+ 'Env' => "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
end
let(:call) { subject.call_for_channel('SIP/1234-00000000') }
let(:call_id) { call.id }
@@ -233,11 +232,11 @@
end
end
end
describe '#execute_component_command' do
- let(:call) { Translator::Asterisk::Call.new 'SIP/foo', subject }
+ let(:call) { Translator::Asterisk::Call.new 'SIP/foo', subject, ami_client, connection }
let(:component_node) { Component::Output.new }
let(:component) { Translator::Asterisk::Component::Output.new(component_node, call) }
let(:command) { Component::Stop.new.tap { |c| c.component_id = component.id } }
@@ -270,11 +269,11 @@
Command::Dial.new :to => 'SIP/1234', :from => 'abc123'
end
before do
command.request!
- ami_client.as_null_object
+ ami_client.stub(:send_action).and_return RubyAMI::Response.new
end
it 'should be able to look up the call by channel ID' do
subject.execute_global_command command
call_actor = subject.call_for_channel('SIP/1234')
@@ -295,17 +294,17 @@
end
let(:mock_action) { stub('Asterisk::Component::Asterisk::AMIAction').as_null_object }
it 'should create a component actor and execute it asynchronously' do
- Asterisk::Component::Asterisk::AMIAction.should_receive(:new).once.with(command, subject).and_return mock_action
+ Asterisk::Component::Asterisk::AMIAction.should_receive(:new).once.with(command, subject, ami_client).and_return mock_action
mock_action.async.should_receive(:execute).once
subject.execute_global_command command
end
it 'registers the component' do
- Asterisk::Component::Asterisk::AMIAction.should_receive(:new).once.with(command, subject).and_return mock_action
+ Asterisk::Component::Asterisk::AMIAction.should_receive(:new).once.with(command, subject, ami_client).and_return mock_action
subject.wrapped_object.should_receive(:register_component).with mock_action
subject.execute_global_command command
end
end
@@ -329,16 +328,15 @@
end
end
describe '#handle_ami_event' do
let :ami_event do
- RubyAMI::Event.new('Newchannel').tap do |e|
- e['Channel'] = "SIP/101-3f3f"
- e['State'] = "Ring"
- e['Callerid'] = "101"
- e['Uniqueid'] = "1094154427.10"
- end
+ RubyAMI::Event.new 'Newchannel',
+ 'Channel' => "SIP/101-3f3f",
+ 'State' => "Ring",
+ 'Callerid' => "101",
+ 'Uniqueid' => "1094154427.10"
end
let :expected_pb_event do
Event::Asterisk::AMI::Event.new :name => 'Newchannel',
:attributes => { :channel => "SIP/101-3f3f",
@@ -360,34 +358,23 @@
end
describe 'with a FullyBooted event' do
let(:ami_event) { RubyAMI::Event.new 'FullyBooted' }
- context 'once' do
- it 'does not send anything to the connection' do
- subject.connection.should_receive(:handle_event).never
- subject.handle_ami_event ami_event
- end
+ it 'sends a connected event to the event handler' do
+ subject.connection.should_receive(:handle_event).once.with Connection::Connected.new
+ subject.wrapped_object.should_receive(:run_at_fully_booted).once
+ subject.handle_ami_event ami_event
end
-
- context 'twice' do
- it 'sends a connected event to the event handler' do
- subject.connection.should_receive(:handle_event).once.with Connection::Connected.new
- subject.wrapped_object.should_receive(:run_at_fully_booted).once
- subject.handle_ami_event ami_event
- subject.handle_ami_event ami_event
- end
- end
end
describe 'with an AsyncAGI Start event' do
let :ami_event do
- RubyAMI::Event.new('AsyncAGI').tap do |e|
- e['SubEvent'] = "Start"
- e['Channel'] = "SIP/1234-00000000"
- e['Env'] = "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
- end
+ RubyAMI::Event.new 'AsyncAGI',
+ 'SubEvent' => "Start",
+ 'Channel' => "SIP/1234-00000000",
+ 'Env' => "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
end
before { subject.wrapped_object.stub :handle_pb_event }
it 'should be able to look up the call by channel ID' do
@@ -426,11 +413,11 @@
mock_call.async.should_receive(:send_offer).once
subject.handle_ami_event ami_event
end
context 'if a call already exists for a matching channel' do
- let(:call) { Asterisk::Call.new "SIP/1234-00000000", subject }
+ let(:call) { Asterisk::Call.new "SIP/1234-00000000", subject, ami_client, connection }
before do
subject.register_call call
end
@@ -440,15 +427,14 @@
end
end
context "for a 'h' extension" do
let :ami_event do
- RubyAMI::Event.new('AsyncAGI').tap do |e|
- e['SubEvent'] = "Start"
- e['Channel'] = "SIP/1234-00000000"
- e['Env'] = "agi_extension%3A%20h%0A%0A"
- end
+ RubyAMI::Event.new 'AsyncAGI',
+ 'SubEvent' => "Start",
+ 'Channel' => "SIP/1234-00000000",
+ 'Env' => "agi_extension%3A%20h%0A%0A"
end
it "should not create a new call" do
Asterisk::Call.should_receive(:new).never
subject.handle_ami_event ami_event
@@ -460,15 +446,14 @@
end
end
context "for a 'Kill' type" do
let :ami_event do
- RubyAMI::Event.new('AsyncAGI').tap do |e|
- e['SubEvent'] = "Start"
- e['Channel'] = "SIP/1234-00000000"
- e['Env'] = "agi_type%3A%20Kill%0A%0A"
- end
+ RubyAMI::Event.new 'AsyncAGI',
+ 'SubEvent' => "Start",
+ 'Channel' => "SIP/1234-00000000",
+ 'Env' => "agi_type%3A%20Kill%0A%0A"
end
it "should not create a new call" do
Asterisk::Call.should_receive(:new).never
subject.handle_ami_event ami_event
@@ -481,17 +466,16 @@
end
end
describe 'with a VarSet event including a punchblock_call_id' do
let :ami_event do
- RubyAMI::Event.new('VarSet').tap do |e|
- e["Privilege"] = "dialplan,all"
- e["Channel"] = "SIP/1234-00000000"
- e["Variable"] = "punchblock_call_id"
- e["Value"] = call_id
- e["Uniqueid"] = "1326210224.0"
- end
+ RubyAMI::Event.new 'VarSet',
+ "Privilege" => "dialplan,all",
+ "Channel" => "SIP/1234-00000000",
+ "Variable" => "punchblock_call_id",
+ "Value" => call_id,
+ "Uniqueid" => "1326210224.0"
end
before do
ami_client.as_null_object
subject.wrapped_object.stub :handle_pb_event
@@ -534,22 +518,21 @@
end
end
describe 'with an AMI event for a known channel' do
let :ami_event do
- RubyAMI::Event.new('Hangup').tap do |e|
- e['Uniqueid'] = "1320842458.8"
- e['Calleridnum'] = "5678"
- e['Calleridname'] = "Jane Smith"
- e['Cause'] = "0"
- e['Cause-txt'] = "Unknown"
- e['Channel'] = "SIP/1234-00000000"
- end
+ RubyAMI::Event.new 'Hangup',
+ 'Uniqueid' => "1320842458.8",
+ 'Calleridnum' => "5678",
+ 'Calleridname' => "Jane Smith",
+ 'Cause' => "0",
+ 'Cause-txt' => "Unknown",
+ 'Channel' => "SIP/1234-00000000"
end
let(:call) do
- Asterisk::Call.new "SIP/1234-00000000", subject, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
+ Asterisk::Call.new "SIP/1234-00000000", subject, ami_client, connection, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
end
before do
subject.register_call call
end
@@ -559,21 +542,20 @@
subject.handle_ami_event ami_event
end
context 'with a Channel1 and Channel2 specified on the event' do
let :ami_event do
- RubyAMI::Event.new('BridgeAction').tap do |e|
- e['Privilege'] = "call,all"
- e['Response'] = "Success"
- e['Channel1'] = "SIP/1234-00000000"
- e['Channel2'] = "SIP/5678-00000000"
- end
+ RubyAMI::Event.new 'BridgeAction',
+ 'Privilege' => "call,all",
+ 'Response' => "Success",
+ 'Channel1' => "SIP/1234-00000000",
+ 'Channel2' => "SIP/5678-00000000"
end
context 'with calls for those channels' do
let(:call2) do
- Asterisk::Call.new "SIP/5678-00000000", subject, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
+ Asterisk::Call.new "SIP/5678-00000000", subject, ami_client, connection, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
end
before { subject.register_call call2 }
it 'should send the event to both calls and to the connection once as a PB event' do
@@ -585,29 +567,27 @@
end
end
describe 'with an event for a channel with Bridge and special statuses appended' do
let :ami_event do
- RubyAMI::Event.new('AGIExec').tap do |e|
- e['SubEvent'] = "End"
- e['Channel'] = "Bridge/SIP/1234-00000000<ZOMBIE>"
- end
+ RubyAMI::Event.new 'AGIExec',
+ 'SubEvent' => "End",
+ 'Channel' => "Bridge/SIP/1234-00000000<ZOMBIE>"
end
let :ami_event2 do
- RubyAMI::Event.new('Hangup').tap do |e|
- e['Uniqueid'] = "1320842458.8"
- e['Calleridnum'] = "5678"
- e['Calleridname'] = "Jane Smith"
- e['Cause'] = "0"
- e['Cause-txt'] = "Unknown"
- e['Channel'] = "Bridge/SIP/1234-00000000<ZOMBIE>"
- end
+ RubyAMI::Event.new 'Hangup',
+ 'Uniqueid' => "1320842458.8",
+ 'Calleridnum' => "5678",
+ 'Calleridname' => "Jane Smith",
+ 'Cause' => "0",
+ 'Cause-txt' => "Unknown",
+ 'Channel' => "Bridge/SIP/1234-00000000<ZOMBIE>"
end
let(:call) do
- Asterisk::Call.new "SIP/1234-00000000", subject, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
+ Asterisk::Call.new "SIP/1234-00000000", subject, ami_client, connection, "agi_request%3A%20async%0Aagi_channel%3A%20SIP%2F1234-00000000%0Aagi_language%3A%20en%0Aagi_type%3A%20SIP%0Aagi_uniqueid%3A%201320835995.0%0Aagi_version%3A%201.8.4.1%0Aagi_callerid%3A%205678%0Aagi_calleridname%3A%20Jane%20Smith%0Aagi_callingpres%3A%200%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%201000%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20default%0Aagi_extension%3A%201000%0Aagi_priority%3A%201%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%204366221312%0A%0A"
end
before do
subject.register_call call
end
@@ -621,52 +601,45 @@
call.async.should_receive(:process_ami_event).never.with ami_event2
subject.handle_ami_event ami_event2
end
end
- end#handle_ami_event
-
- describe '#send_ami_action' do
- it 'should send the action to the AMI client' do
- ami_client.should_receive(:send_action).once.with 'foo', :foo => :bar
- subject.send_ami_action 'foo', :foo => :bar
- end
end
describe '#run_at_fully_booted' do
let(:broken_path) { "/this/is/not/a/valid/path" }
let(:passed_show) do
- OpenStruct.new({:text_body => "[ Context 'adhearsion-redirect' created by 'pbx_config' ]\n '1' => 1. AGI(agi:async)[pbx_config]\n\n-= 1 extension (1 priority) in 1 context. =-"})
+ OpenStruct.new text_body: "[ Context 'adhearsion-redirect' created by 'pbx_config' ]\n '1' => 1. AGI(agi:async)[pbx_config]\n\n-= 1 extension (1 priority) in 1 context. =-"
end
let(:failed_show) do
- OpenStruct.new({:text_body => "There is no existence of 'adhearsion-redirect' context\nCommand 'dialplan show adhearsion-redirect' failed."})
+ OpenStruct.new text_body: "There is no existence of 'adhearsion-redirect' context\nCommand 'dialplan show adhearsion-redirect' failed."
end
it 'should send the redirect extension Command to the AMI client' do
ami_client.should_receive(:send_action).once.with 'Command', 'Command' => "dialplan add extension #{Asterisk::REDIRECT_EXTENSION},#{Asterisk::REDIRECT_PRIORITY},AGI,agi:async into #{Asterisk::REDIRECT_CONTEXT}"
- ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}")
+ ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").and_return(passed_show)
subject.run_at_fully_booted
end
it 'should check the context for existence and do nothing if it is there' do
ami_client.should_receive(:send_action).once.with 'Command', 'Command' => "dialplan add extension #{Asterisk::REDIRECT_EXTENSION},#{Asterisk::REDIRECT_PRIORITY},AGI,agi:async into #{Asterisk::REDIRECT_CONTEXT}"
- ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").and_yield(passed_show)
+ ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").and_return(passed_show)
subject.run_at_fully_booted
end
it 'should check the context for existence and log an error if it is not there' do
ami_client.should_receive(:send_action).once.with 'Command', 'Command' => "dialplan add extension #{Asterisk::REDIRECT_EXTENSION},#{Asterisk::REDIRECT_PRIORITY},AGI,agi:async into #{Asterisk::REDIRECT_CONTEXT}"
- ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").and_yield(failed_show)
+ ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").and_return(failed_show)
Punchblock.logger.should_receive(:error).once.with("Punchblock failed to add the #{Asterisk::REDIRECT_EXTENSION} extension to the #{Asterisk::REDIRECT_CONTEXT} context. Please add a [#{Asterisk::REDIRECT_CONTEXT}] entry to your dialplan.")
subject.run_at_fully_booted
end
it 'should check the recording directory for existence' do
stub_const('Punchblock::Translator::Asterisk::Component::Record::RECORDING_BASE_PATH', broken_path)
ami_client.should_receive(:send_action).once.with 'Command', 'Command' => "dialplan add extension #{Asterisk::REDIRECT_EXTENSION},#{Asterisk::REDIRECT_PRIORITY},AGI,agi:async into #{Asterisk::REDIRECT_CONTEXT}"
- ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}")
+ ami_client.should_receive(:send_action).once.with('Command', 'Command' => "dialplan show #{Asterisk::REDIRECT_CONTEXT}").and_return(passed_show)
Punchblock.logger.should_receive(:warn).once.with("Recordings directory #{broken_path} does not exist. Recording might not work. This warning can be ignored if Adhearsion is running on a separate machine than Asterisk. See http://adhearsion.com/docs/call-controllers#recording")
subject.run_at_fully_booted
end
end