punchblock 2.5.2 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.hound.yml +2 -0
- data/CHANGELOG.md +6 -0
- data/README.markdown +2 -1
- data/lib/punchblock/translator/asterisk/call.rb +3 -3
- data/lib/punchblock/translator/asterisk/component/mrcp_recog_prompt.rb +15 -9
- data/lib/punchblock/translator/asterisk/component/output.rb +8 -1
- data/lib/punchblock/translator/input_component.rb +2 -0
- data/lib/punchblock/version.rb +1 -1
- data/punchblock.gemspec +1 -1
- data/spec/punchblock/client/component_registry_spec.rb +3 -3
- data/spec/punchblock/client_spec.rb +22 -15
- data/spec/punchblock/command/accept_spec.rb +17 -7
- data/spec/punchblock/command/answer_spec.rb +19 -9
- data/spec/punchblock/command/dial_spec.rb +76 -27
- data/spec/punchblock/command/hangup_spec.rb +17 -7
- data/spec/punchblock/command/join_spec.rb +78 -24
- data/spec/punchblock/command/mute_spec.rb +3 -3
- data/spec/punchblock/command/redirect_spec.rb +33 -12
- data/spec/punchblock/command/reject_spec.rb +41 -14
- data/spec/punchblock/command/unjoin_spec.rb +29 -12
- data/spec/punchblock/command/unmute_spec.rb +3 -3
- data/spec/punchblock/command_node_spec.rb +43 -20
- data/spec/punchblock/component/asterisk/agi/command_spec.rb +52 -12
- data/spec/punchblock/component/asterisk/ami/action_spec.rb +69 -21
- data/spec/punchblock/component/component_node_spec.rb +12 -12
- data/spec/punchblock/component/input_spec.rb +304 -87
- data/spec/punchblock/component/output_spec.rb +434 -173
- data/spec/punchblock/component/prompt_spec.rb +63 -20
- data/spec/punchblock/component/receive_fax_spec.rb +43 -14
- data/spec/punchblock/component/record_spec.rb +215 -71
- data/spec/punchblock/component/send_fax_spec.rb +54 -15
- data/spec/punchblock/connection/asterisk_spec.rb +34 -24
- data/spec/punchblock/connection/freeswitch_spec.rb +9 -9
- data/spec/punchblock/connection/xmpp_spec.rb +92 -83
- data/spec/punchblock/event/answered_spec.rb +14 -4
- data/spec/punchblock/event/asterisk/ami/event_spec.rb +34 -12
- data/spec/punchblock/event/complete_spec.rb +36 -16
- data/spec/punchblock/event/dtmf_spec.rb +9 -3
- data/spec/punchblock/event/end_spec.rb +43 -10
- data/spec/punchblock/event/input_timers_started_spec.rb +1 -1
- data/spec/punchblock/event/joined_spec.rb +29 -7
- data/spec/punchblock/event/offer_spec.rb +41 -10
- data/spec/punchblock/event/ringing_spec.rb +14 -4
- data/spec/punchblock/event/started_speaking_spec.rb +9 -3
- data/spec/punchblock/event/stopped_speaking_spec.rb +9 -3
- data/spec/punchblock/event/unjoined_spec.rb +24 -6
- data/spec/punchblock/protocol_error_spec.rb +16 -13
- data/spec/punchblock/ref_spec.rb +90 -26
- data/spec/punchblock/translator/asterisk/call_spec.rb +176 -161
- data/spec/punchblock/translator/asterisk/component/asterisk/agi_command_spec.rb +18 -18
- data/spec/punchblock/translator/asterisk/component/asterisk/ami_action_spec.rb +9 -9
- data/spec/punchblock/translator/asterisk/component/composed_prompt_spec.rb +14 -14
- data/spec/punchblock/translator/asterisk/component/input_spec.rb +57 -36
- data/spec/punchblock/translator/asterisk/component/mrcp_native_prompt_spec.rb +50 -50
- data/spec/punchblock/translator/asterisk/component/mrcp_prompt_spec.rb +59 -48
- data/spec/punchblock/translator/asterisk/component/output_spec.rb +231 -221
- data/spec/punchblock/translator/asterisk/component/record_spec.rb +82 -82
- data/spec/punchblock/translator/asterisk/component/stop_by_redirect_spec.rb +10 -10
- data/spec/punchblock/translator/asterisk/component_spec.rb +4 -4
- data/spec/punchblock/translator/asterisk_spec.rb +89 -82
- data/spec/punchblock/translator/freeswitch/call_spec.rb +114 -99
- data/spec/punchblock/translator/freeswitch/component/flite_output_spec.rb +19 -19
- data/spec/punchblock/translator/freeswitch/component/input_spec.rb +24 -24
- data/spec/punchblock/translator/freeswitch/component/output_spec.rb +23 -23
- data/spec/punchblock/translator/freeswitch/component/record_spec.rb +78 -78
- data/spec/punchblock/translator/freeswitch/component/tts_output_spec.rb +19 -19
- data/spec/punchblock/translator/freeswitch/component_spec.rb +8 -8
- data/spec/punchblock/translator/freeswitch_spec.rb +66 -59
- data/spec/punchblock/uri_list_spec.rb +45 -10
- data/spec/punchblock_spec.rb +13 -13
- data/spec/spec_helper.rb +18 -11
- data/spec/support/mock_connection_with_event_handler.rb +1 -1
- metadata +5 -4
|
@@ -33,14 +33,14 @@ module Punchblock
|
|
|
33
33
|
subject { Output.new original_command, mock_call }
|
|
34
34
|
|
|
35
35
|
def expect_answered(value = true)
|
|
36
|
-
mock_call.
|
|
36
|
+
allow(mock_call).to receive(:answered?).and_return(value)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def expect_mrcpsynth_with_options(options)
|
|
40
|
-
mock_call.
|
|
41
|
-
args[0].
|
|
42
|
-
args[1].
|
|
43
|
-
|
|
40
|
+
expect(mock_call).to receive(:execute_agi_command).once.with { |*args|
|
|
41
|
+
expect(args[0]).to eq('EXEC MRCPSynth')
|
|
42
|
+
expect(args[1]).to match options
|
|
43
|
+
}.and_return code: 200, result: 1
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
describe '#execute' do
|
|
@@ -52,7 +52,7 @@ module Punchblock
|
|
|
52
52
|
it "should return an error and not execute any actions" do
|
|
53
53
|
subject.execute
|
|
54
54
|
error = ProtocolError.new.setup 'option error', 'The renderer foobar is unsupported.'
|
|
55
|
-
original_command.response(0.1).
|
|
55
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -80,34 +80,34 @@ module Punchblock
|
|
|
80
80
|
before { expect_answered }
|
|
81
81
|
|
|
82
82
|
it "should execute Swift" do
|
|
83
|
-
mock_call.
|
|
83
|
+
expect(mock_call).to receive(:execute_agi_command).once.with 'EXEC Swift', ssml_with_options
|
|
84
84
|
subject.execute
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
it 'should send a complete event when Swift completes' do
|
|
88
|
-
mock_call.
|
|
88
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
89
89
|
subject.execute
|
|
90
|
-
original_command.complete_event(0.1).reason.
|
|
90
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
context "when we get a RubyAMI Error" do
|
|
94
94
|
it "should send an error complete event" do
|
|
95
95
|
error = RubyAMI::Error.new.tap { |e| e.message = 'FooBar' }
|
|
96
|
-
mock_call.
|
|
96
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
97
97
|
subject.execute
|
|
98
98
|
complete_reason = original_command.complete_event(0.1).reason
|
|
99
|
-
complete_reason.
|
|
100
|
-
complete_reason.details.
|
|
99
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
100
|
+
expect(complete_reason.details).to eq("Terminated due to AMI error 'FooBar'")
|
|
101
101
|
end
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
context "when the channel is gone" do
|
|
105
105
|
it "should send an error complete event" do
|
|
106
106
|
error = ChannelGoneError.new 'FooBar'
|
|
107
|
-
mock_call.
|
|
107
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
108
108
|
subject.execute
|
|
109
109
|
complete_reason = original_command.complete_event(0.1).reason
|
|
110
|
-
complete_reason.
|
|
110
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Hangup
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
|
|
@@ -115,8 +115,8 @@ module Punchblock
|
|
|
115
115
|
before { expect_answered false }
|
|
116
116
|
|
|
117
117
|
it "should send progress" do
|
|
118
|
-
mock_call.
|
|
119
|
-
mock_call.
|
|
118
|
+
expect(mock_call).to receive(:send_progress)
|
|
119
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
120
120
|
subject.execute
|
|
121
121
|
end
|
|
122
122
|
end
|
|
@@ -125,7 +125,7 @@ module Punchblock
|
|
|
125
125
|
context "set to nil" do
|
|
126
126
|
let(:command_opts) { { :interrupt_on => nil } }
|
|
127
127
|
it "should not add interrupt arguments" do
|
|
128
|
-
mock_call.
|
|
128
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Swift', ssml_with_options).and_return code: 200, result: 1
|
|
129
129
|
subject.execute
|
|
130
130
|
end
|
|
131
131
|
end
|
|
@@ -133,7 +133,7 @@ module Punchblock
|
|
|
133
133
|
context "set to :any" do
|
|
134
134
|
let(:command_opts) { { :interrupt_on => :any } }
|
|
135
135
|
it "should add the interrupt options to the argument" do
|
|
136
|
-
mock_call.
|
|
136
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Swift', ssml_with_options('', '|1|1')).and_return code: 200, result: 1
|
|
137
137
|
subject.execute
|
|
138
138
|
end
|
|
139
139
|
end
|
|
@@ -141,7 +141,7 @@ module Punchblock
|
|
|
141
141
|
context "set to :dtmf" do
|
|
142
142
|
let(:command_opts) { { :interrupt_on => :dtmf } }
|
|
143
143
|
it "should add the interrupt options to the argument" do
|
|
144
|
-
mock_call.
|
|
144
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Swift', ssml_with_options('', '|1|1')).and_return code: 200, result: 1
|
|
145
145
|
subject.execute
|
|
146
146
|
end
|
|
147
147
|
end
|
|
@@ -151,7 +151,7 @@ module Punchblock
|
|
|
151
151
|
it "should return an error and not execute any actions" do
|
|
152
152
|
subject.execute
|
|
153
153
|
error = ProtocolError.new.setup 'option error', 'An interrupt-on value of speech is unsupported.'
|
|
154
|
-
original_command.response(0.1).
|
|
154
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
155
155
|
end
|
|
156
156
|
end
|
|
157
157
|
end
|
|
@@ -160,7 +160,7 @@ module Punchblock
|
|
|
160
160
|
context "set to nil" do
|
|
161
161
|
let(:command_opts) { { :voice => nil } }
|
|
162
162
|
it "should not add a voice at the beginning of the argument" do
|
|
163
|
-
mock_call.
|
|
163
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Swift', ssml_with_options).and_return code: 200, result: 1
|
|
164
164
|
subject.execute
|
|
165
165
|
end
|
|
166
166
|
end
|
|
@@ -168,7 +168,7 @@ module Punchblock
|
|
|
168
168
|
context "set to Leonard" do
|
|
169
169
|
let(:command_opts) { { :voice => "Leonard" } }
|
|
170
170
|
it "should add a voice at the beginning of the argument" do
|
|
171
|
-
mock_call.
|
|
171
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Swift', ssml_with_options('Leonard^', '')).and_return code: 200, result: 1
|
|
172
172
|
subject.execute
|
|
173
173
|
end
|
|
174
174
|
end
|
|
@@ -189,7 +189,7 @@ module Punchblock
|
|
|
189
189
|
let(:command_opts) { { render_documents: [{value: first_ssml_doc}, {value: second_ssml_doc}] } }
|
|
190
190
|
|
|
191
191
|
it "executes Swift with a concatenated version of the documents" do
|
|
192
|
-
mock_call.
|
|
192
|
+
expect(mock_call).to receive(:execute_agi_command).once.with 'EXEC Swift', ssml_with_options
|
|
193
193
|
subject.execute
|
|
194
194
|
end
|
|
195
195
|
end
|
|
@@ -214,39 +214,39 @@ module Punchblock
|
|
|
214
214
|
end
|
|
215
215
|
|
|
216
216
|
let(:synthstatus) { 'OK' }
|
|
217
|
-
before { mock_call.
|
|
217
|
+
before { allow(mock_call).to receive(:channel_var).with('SYNTHSTATUS').and_return synthstatus }
|
|
218
218
|
|
|
219
219
|
before { expect_answered }
|
|
220
220
|
|
|
221
221
|
it "should execute MRCPSynth" do
|
|
222
|
-
mock_call.
|
|
222
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC MRCPSynth', ["\"#{ssml_doc.to_s.squish.gsub('"', '\"')}\"", ''].join(',')).and_return code: 200, result: 1
|
|
223
223
|
subject.execute
|
|
224
224
|
end
|
|
225
225
|
|
|
226
226
|
it 'should send a complete event when MRCPSynth completes' do
|
|
227
|
-
mock_call.
|
|
227
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
228
228
|
subject.execute
|
|
229
|
-
original_command.complete_event(0.1).reason.
|
|
229
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
230
230
|
end
|
|
231
231
|
|
|
232
232
|
context "when we get a RubyAMI Error" do
|
|
233
233
|
it "should send an error complete event" do
|
|
234
234
|
error = RubyAMI::Error.new.tap { |e| e.message = 'FooBar' }
|
|
235
|
-
mock_call.
|
|
235
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
236
236
|
subject.execute
|
|
237
237
|
complete_reason = original_command.complete_event(0.1).reason
|
|
238
|
-
complete_reason.
|
|
239
|
-
complete_reason.details.
|
|
238
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
239
|
+
expect(complete_reason.details).to eq("Terminated due to AMI error 'FooBar'")
|
|
240
240
|
end
|
|
241
241
|
end
|
|
242
242
|
|
|
243
243
|
context "when the channel is gone" do
|
|
244
244
|
it "should send an error complete event" do
|
|
245
245
|
error = ChannelGoneError.new 'FooBar'
|
|
246
|
-
mock_call.
|
|
246
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
247
247
|
subject.execute
|
|
248
248
|
complete_reason = original_command.complete_event(0.1).reason
|
|
249
|
-
complete_reason.
|
|
249
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Hangup
|
|
250
250
|
end
|
|
251
251
|
end
|
|
252
252
|
|
|
@@ -254,8 +254,8 @@ module Punchblock
|
|
|
254
254
|
before { expect_answered false }
|
|
255
255
|
|
|
256
256
|
it "should send progress" do
|
|
257
|
-
mock_call.
|
|
258
|
-
mock_call.
|
|
257
|
+
expect(mock_call).to receive(:send_progress)
|
|
258
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
259
259
|
subject.execute
|
|
260
260
|
end
|
|
261
261
|
end
|
|
@@ -264,11 +264,11 @@ module Punchblock
|
|
|
264
264
|
let(:synthstatus) { 'ERROR' }
|
|
265
265
|
|
|
266
266
|
it "should send an error complete event" do
|
|
267
|
-
mock_call.
|
|
267
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
268
268
|
subject.execute
|
|
269
269
|
complete_reason = original_command.complete_event(0.1).reason
|
|
270
|
-
complete_reason.
|
|
271
|
-
complete_reason.details.
|
|
270
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
271
|
+
expect(complete_reason.details).to eq("Terminated due to UniMRCP error")
|
|
272
272
|
end
|
|
273
273
|
end
|
|
274
274
|
|
|
@@ -278,7 +278,7 @@ module Punchblock
|
|
|
278
278
|
it "should return an error and not execute any actions" do
|
|
279
279
|
subject.execute
|
|
280
280
|
error = ProtocolError.new.setup 'option error', 'An SSML document is required.'
|
|
281
|
-
original_command.response(0.1).
|
|
281
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
282
282
|
end
|
|
283
283
|
end
|
|
284
284
|
|
|
@@ -287,27 +287,27 @@ module Punchblock
|
|
|
287
287
|
|
|
288
288
|
it "should execute MRCPSynth once with each document" do
|
|
289
289
|
param = ["\"#{ssml_doc.to_s.squish.gsub('"', '\"')}\"", ''].join(',')
|
|
290
|
-
mock_call.
|
|
291
|
-
mock_call.
|
|
290
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC MRCPSynth', param).and_return code: 200, result: 1
|
|
291
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC MRCPSynth', param).and_return code: 200, result: 1
|
|
292
292
|
subject.execute
|
|
293
293
|
end
|
|
294
294
|
|
|
295
295
|
it 'should not execute further output after a stop command' do
|
|
296
|
-
mock_call.
|
|
296
|
+
expect(mock_call).to receive(:execute_agi_command).once.ordered do
|
|
297
297
|
sleep 0.5
|
|
298
298
|
end
|
|
299
299
|
latch = CountDownLatch.new 1
|
|
300
|
-
original_command.
|
|
301
|
-
e.reason.
|
|
300
|
+
expect(original_command).to receive(:add_event).once.with { |e|
|
|
301
|
+
expect(e.reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
302
302
|
latch.countdown!
|
|
303
|
-
|
|
303
|
+
}
|
|
304
304
|
Celluloid::Future.new { subject.execute }
|
|
305
305
|
sleep 0.2
|
|
306
|
-
mock_call.
|
|
306
|
+
expect(mock_call).to receive(:redirect_back).ordered
|
|
307
307
|
stop_command = Punchblock::Component::Stop.new
|
|
308
308
|
stop_command.request!
|
|
309
309
|
subject.execute_command stop_command
|
|
310
|
-
latch.wait(2).
|
|
310
|
+
expect(latch.wait(2)).to be_true
|
|
311
311
|
end
|
|
312
312
|
end
|
|
313
313
|
end
|
|
@@ -326,7 +326,7 @@ module Punchblock
|
|
|
326
326
|
it "should return an error and not execute any actions" do
|
|
327
327
|
subject.execute
|
|
328
328
|
error = ProtocolError.new.setup 'option error', 'A start_offset value is unsupported on Asterisk.'
|
|
329
|
-
original_command.response(0.1).
|
|
329
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
330
330
|
end
|
|
331
331
|
end
|
|
332
332
|
end
|
|
@@ -345,7 +345,7 @@ module Punchblock
|
|
|
345
345
|
it "should return an error and not execute any actions" do
|
|
346
346
|
subject.execute
|
|
347
347
|
error = ProtocolError.new.setup 'option error', 'A start_paused value is unsupported on Asterisk.'
|
|
348
|
-
original_command.response(0.1).
|
|
348
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
349
349
|
end
|
|
350
350
|
end
|
|
351
351
|
end
|
|
@@ -364,7 +364,7 @@ module Punchblock
|
|
|
364
364
|
it "should return an error and not execute any actions" do
|
|
365
365
|
subject.execute
|
|
366
366
|
error = ProtocolError.new.setup 'option error', 'A repeat_interval value is unsupported on Asterisk.'
|
|
367
|
-
original_command.response(0.1).
|
|
367
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
368
368
|
end
|
|
369
369
|
end
|
|
370
370
|
end
|
|
@@ -384,7 +384,7 @@ module Punchblock
|
|
|
384
384
|
it "should render the specified number of times" do
|
|
385
385
|
2.times { expect_mrcpsynth_with_options(//) }
|
|
386
386
|
subject.execute
|
|
387
|
-
original_command.complete_event(0.1).reason.
|
|
387
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
388
388
|
end
|
|
389
389
|
|
|
390
390
|
context 'to 0' do
|
|
@@ -394,26 +394,26 @@ module Punchblock
|
|
|
394
394
|
expect_answered
|
|
395
395
|
1000.times { expect_mrcpsynth_with_options(//) }
|
|
396
396
|
subject.execute
|
|
397
|
-
original_command.complete_event(0.1).reason.
|
|
397
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
398
398
|
end
|
|
399
399
|
end
|
|
400
400
|
|
|
401
401
|
it 'should not execute further output after a stop command' do
|
|
402
|
-
mock_call.
|
|
402
|
+
expect(mock_call).to receive(:execute_agi_command).once.ordered do
|
|
403
403
|
sleep 0.2
|
|
404
404
|
end
|
|
405
405
|
latch = CountDownLatch.new 1
|
|
406
|
-
original_command.
|
|
407
|
-
e.reason.
|
|
406
|
+
expect(original_command).to receive(:add_event).once.with { |e|
|
|
407
|
+
expect(e.reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
408
408
|
latch.countdown!
|
|
409
|
-
|
|
409
|
+
}
|
|
410
410
|
Celluloid::Future.new { subject.execute }
|
|
411
411
|
sleep 0.1
|
|
412
|
-
mock_call.
|
|
412
|
+
expect(mock_call).to receive(:redirect_back).ordered
|
|
413
413
|
stop_command = Punchblock::Component::Stop.new
|
|
414
414
|
stop_command.request!
|
|
415
415
|
subject.execute_command stop_command
|
|
416
|
-
latch.wait(2).
|
|
416
|
+
expect(latch.wait(2)).to be_true
|
|
417
417
|
end
|
|
418
418
|
end
|
|
419
419
|
end
|
|
@@ -432,7 +432,7 @@ module Punchblock
|
|
|
432
432
|
it "should return an error and not execute any actions" do
|
|
433
433
|
subject.execute
|
|
434
434
|
error = ProtocolError.new.setup 'option error', 'A max_time value is unsupported on Asterisk.'
|
|
435
|
-
original_command.response(0.1).
|
|
435
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
436
436
|
end
|
|
437
437
|
end
|
|
438
438
|
end
|
|
@@ -485,7 +485,7 @@ module Punchblock
|
|
|
485
485
|
it "should return an error and not execute any actions" do
|
|
486
486
|
subject.execute
|
|
487
487
|
error = ProtocolError.new.setup 'option error', 'An interrupt-on value of speech is unsupported.'
|
|
488
|
-
original_command.response(0.1).
|
|
488
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
489
489
|
end
|
|
490
490
|
end
|
|
491
491
|
end
|
|
@@ -494,11 +494,11 @@ module Punchblock
|
|
|
494
494
|
[:asterisk, nil].each do |renderer|
|
|
495
495
|
context "with a renderer of #{renderer.inspect}" do
|
|
496
496
|
def expect_playback(filename = audio_filename)
|
|
497
|
-
mock_call.
|
|
497
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Playback', filename).and_return code: 200
|
|
498
498
|
end
|
|
499
499
|
|
|
500
500
|
def expect_playback_noanswer
|
|
501
|
-
mock_call.
|
|
501
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Playback', audio_filename + ',noanswer').and_return code: 200
|
|
502
502
|
end
|
|
503
503
|
|
|
504
504
|
let(:audio_filename) { 'tt-monkeys' }
|
|
@@ -520,7 +520,7 @@ module Punchblock
|
|
|
520
520
|
end
|
|
521
521
|
|
|
522
522
|
let(:playbackstatus) { 'SUCCESS' }
|
|
523
|
-
before { mock_call.
|
|
523
|
+
before { allow(mock_call).to receive(:channel_var).with('PLAYBACKSTATUS').and_return playbackstatus }
|
|
524
524
|
|
|
525
525
|
describe 'ssml' do
|
|
526
526
|
context 'unset' do
|
|
@@ -528,7 +528,7 @@ module Punchblock
|
|
|
528
528
|
it "should return an error and not execute any actions" do
|
|
529
529
|
subject.execute
|
|
530
530
|
error = ProtocolError.new.setup 'option error', 'An SSML document is required.'
|
|
531
|
-
original_command.response(0.1).
|
|
531
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
532
532
|
end
|
|
533
533
|
end
|
|
534
534
|
|
|
@@ -550,7 +550,7 @@ module Punchblock
|
|
|
550
550
|
end
|
|
551
551
|
expect_playback
|
|
552
552
|
subject.execute
|
|
553
|
-
original_command.complete_event(0.1).reason.
|
|
553
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
554
554
|
end
|
|
555
555
|
|
|
556
556
|
context "when the audio filename is prefixed by file://" do
|
|
@@ -580,6 +580,16 @@ module Punchblock
|
|
|
580
580
|
expect_playback 'blue.tt-monkeys'
|
|
581
581
|
subject.execute
|
|
582
582
|
end
|
|
583
|
+
|
|
584
|
+
context "and no file extension" do
|
|
585
|
+
let(:audio_filename) { '/var/lib/gems/1.9.1/gems/myapp-1.0.0/prompts/greeting' }
|
|
586
|
+
|
|
587
|
+
it 'should playback the audio file using Playback' do
|
|
588
|
+
expect_answered
|
|
589
|
+
expect_playback '/var/lib/gems/1.9.1/gems/myapp-1.0.0/prompts/greeting'
|
|
590
|
+
subject.execute
|
|
591
|
+
end
|
|
592
|
+
end
|
|
583
593
|
end
|
|
584
594
|
end
|
|
585
595
|
|
|
@@ -587,11 +597,11 @@ module Punchblock
|
|
|
587
597
|
it "should send an error complete event" do
|
|
588
598
|
expect_answered
|
|
589
599
|
error = RubyAMI::Error.new.tap { |e| e.message = 'FooBar' }
|
|
590
|
-
mock_call.
|
|
600
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
591
601
|
subject.execute
|
|
592
602
|
complete_reason = original_command.complete_event(0.1).reason
|
|
593
|
-
complete_reason.
|
|
594
|
-
complete_reason.details.
|
|
603
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
604
|
+
expect(complete_reason.details).to eq("Terminated due to AMI error 'FooBar'")
|
|
595
605
|
end
|
|
596
606
|
end
|
|
597
607
|
|
|
@@ -599,10 +609,10 @@ module Punchblock
|
|
|
599
609
|
it "should send an error complete event" do
|
|
600
610
|
expect_answered
|
|
601
611
|
error = ChannelGoneError.new 'FooBar'
|
|
602
|
-
mock_call.
|
|
612
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
603
613
|
subject.execute
|
|
604
614
|
complete_reason = original_command.complete_event(0.1).reason
|
|
605
|
-
complete_reason.
|
|
615
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Hangup
|
|
606
616
|
end
|
|
607
617
|
end
|
|
608
618
|
|
|
@@ -611,11 +621,11 @@ module Punchblock
|
|
|
611
621
|
|
|
612
622
|
it "should send an error complete event" do
|
|
613
623
|
expect_answered
|
|
614
|
-
mock_call.
|
|
624
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
615
625
|
subject.execute
|
|
616
626
|
complete_reason = original_command.complete_event(0.1).reason
|
|
617
|
-
complete_reason.
|
|
618
|
-
complete_reason.details.
|
|
627
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
628
|
+
expect(complete_reason.details).to eq("Terminated due to playback error")
|
|
619
629
|
end
|
|
620
630
|
end
|
|
621
631
|
end
|
|
@@ -636,18 +646,18 @@ module Punchblock
|
|
|
636
646
|
expect_answered
|
|
637
647
|
expect_playback
|
|
638
648
|
subject.execute
|
|
639
|
-
original_command.complete_event(0.1).reason.
|
|
649
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
640
650
|
end
|
|
641
651
|
|
|
642
652
|
context "when we get a RubyAMI Error" do
|
|
643
653
|
it "should send an error complete event" do
|
|
644
654
|
expect_answered
|
|
645
655
|
error = RubyAMI::Error.new.tap { |e| e.message = 'FooBar' }
|
|
646
|
-
mock_call.
|
|
656
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
647
657
|
subject.execute
|
|
648
658
|
complete_reason = original_command.complete_event(0.1).reason
|
|
649
|
-
complete_reason.
|
|
650
|
-
complete_reason.details.
|
|
659
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
660
|
+
expect(complete_reason.details).to eq("Terminated due to AMI error 'FooBar'")
|
|
651
661
|
end
|
|
652
662
|
end
|
|
653
663
|
|
|
@@ -655,7 +665,7 @@ module Punchblock
|
|
|
655
665
|
it "should play the file with Playback" do
|
|
656
666
|
expect_answered false
|
|
657
667
|
expect_playback_noanswer
|
|
658
|
-
mock_call.
|
|
668
|
+
expect(mock_call).to receive(:send_progress)
|
|
659
669
|
subject.execute
|
|
660
670
|
end
|
|
661
671
|
|
|
@@ -673,7 +683,7 @@ module Punchblock
|
|
|
673
683
|
expect_answered false
|
|
674
684
|
error = ProtocolError.new.setup 'option error', 'Interrupt digits are not allowed with early media.'
|
|
675
685
|
subject.execute
|
|
676
|
-
original_command.response(0.1).
|
|
686
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
677
687
|
end
|
|
678
688
|
end
|
|
679
689
|
end
|
|
@@ -702,12 +712,12 @@ module Punchblock
|
|
|
702
712
|
expect_answered
|
|
703
713
|
expect_playback [audio_filename1, audio_filename2].join('&')
|
|
704
714
|
latch = CountDownLatch.new 1
|
|
705
|
-
original_command.
|
|
706
|
-
e.reason.
|
|
715
|
+
expect(original_command).to receive(:add_event).once.with { |e|
|
|
716
|
+
expect(e.reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
707
717
|
latch.countdown!
|
|
708
|
-
|
|
718
|
+
}
|
|
709
719
|
subject.execute
|
|
710
|
-
latch.wait(2).
|
|
720
|
+
expect(latch.wait(2)).to be_true
|
|
711
721
|
end
|
|
712
722
|
end
|
|
713
723
|
|
|
@@ -721,7 +731,7 @@ module Punchblock
|
|
|
721
731
|
it "should return an unrenderable document error" do
|
|
722
732
|
subject.execute
|
|
723
733
|
error = ProtocolError.new.setup 'unrenderable document error', 'The provided document could not be rendered. See http://adhearsion.com/docs/common_problems#unrenderable-document-error for details.'
|
|
724
|
-
original_command.response(0.1).
|
|
734
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
725
735
|
end
|
|
726
736
|
end
|
|
727
737
|
|
|
@@ -732,26 +742,26 @@ module Punchblock
|
|
|
732
742
|
expect_answered
|
|
733
743
|
2.times { expect_playback }
|
|
734
744
|
subject.execute
|
|
735
|
-
original_command.complete_event(0.1).reason.
|
|
745
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
736
746
|
end
|
|
737
747
|
|
|
738
748
|
it 'should not execute further output after a stop command' do
|
|
739
749
|
expect_answered
|
|
740
|
-
mock_call.
|
|
750
|
+
expect(mock_call).to receive(:execute_agi_command).once.ordered do
|
|
741
751
|
sleep 0.2
|
|
742
752
|
end
|
|
743
753
|
latch = CountDownLatch.new 1
|
|
744
|
-
original_command.
|
|
745
|
-
e.reason.
|
|
754
|
+
expect(original_command).to receive(:add_event).once.with { |e|
|
|
755
|
+
expect(e.reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
746
756
|
latch.countdown!
|
|
747
|
-
|
|
757
|
+
}
|
|
748
758
|
Celluloid::Future.new { subject.execute }
|
|
749
759
|
sleep 0.1
|
|
750
|
-
mock_call.
|
|
760
|
+
expect(mock_call).to receive(:redirect_back).ordered
|
|
751
761
|
stop_command = Punchblock::Component::Stop.new
|
|
752
762
|
stop_command.request!
|
|
753
763
|
subject.execute_command stop_command
|
|
754
|
-
latch.wait(2).
|
|
764
|
+
expect(latch.wait(2)).to be_true
|
|
755
765
|
end
|
|
756
766
|
|
|
757
767
|
context "when the PLAYBACKSTATUS variable is set to 'FAILED'" do
|
|
@@ -759,11 +769,11 @@ module Punchblock
|
|
|
759
769
|
|
|
760
770
|
it "should terminate playback and send an error complete event" do
|
|
761
771
|
expect_answered
|
|
762
|
-
mock_call.
|
|
772
|
+
expect(mock_call).to receive(:execute_agi_command).once.and_return code: 200, result: 1
|
|
763
773
|
subject.execute
|
|
764
774
|
complete_reason = original_command.complete_event(0.1).reason
|
|
765
|
-
complete_reason.
|
|
766
|
-
complete_reason.details.
|
|
775
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
776
|
+
expect(complete_reason.details).to eq("Terminated due to playback error")
|
|
767
777
|
end
|
|
768
778
|
end
|
|
769
779
|
end
|
|
@@ -784,7 +794,7 @@ module Punchblock
|
|
|
784
794
|
it "should return an error and not execute any actions" do
|
|
785
795
|
subject.execute
|
|
786
796
|
error = ProtocolError.new.setup 'option error', 'A start_offset value is unsupported on Asterisk.'
|
|
787
|
-
original_command.response(0.1).
|
|
797
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
788
798
|
end
|
|
789
799
|
end
|
|
790
800
|
end
|
|
@@ -804,7 +814,7 @@ module Punchblock
|
|
|
804
814
|
it "should return an error and not execute any actions" do
|
|
805
815
|
subject.execute
|
|
806
816
|
error = ProtocolError.new.setup 'option error', 'A start_paused value is unsupported on Asterisk.'
|
|
807
|
-
original_command.response(0.1).
|
|
817
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
808
818
|
end
|
|
809
819
|
end
|
|
810
820
|
end
|
|
@@ -824,7 +834,7 @@ module Punchblock
|
|
|
824
834
|
it "should return an error and not execute any actions" do
|
|
825
835
|
subject.execute
|
|
826
836
|
error = ProtocolError.new.setup 'option error', 'A repeat_interval value is unsupported on Asterisk.'
|
|
827
|
-
original_command.response(0.1).
|
|
837
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
828
838
|
end
|
|
829
839
|
end
|
|
830
840
|
end
|
|
@@ -846,7 +856,7 @@ module Punchblock
|
|
|
846
856
|
expect_answered
|
|
847
857
|
2.times { expect_playback }
|
|
848
858
|
subject.execute
|
|
849
|
-
original_command.complete_event(0.1).reason.
|
|
859
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
850
860
|
end
|
|
851
861
|
|
|
852
862
|
context 'to 0' do
|
|
@@ -856,27 +866,27 @@ module Punchblock
|
|
|
856
866
|
expect_answered
|
|
857
867
|
1000.times { expect_playback }
|
|
858
868
|
subject.execute
|
|
859
|
-
original_command.complete_event(0.1).reason.
|
|
869
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
860
870
|
end
|
|
861
871
|
end
|
|
862
872
|
|
|
863
873
|
it 'should not execute further output after a stop command' do
|
|
864
874
|
expect_answered
|
|
865
|
-
mock_call.
|
|
875
|
+
expect(mock_call).to receive(:execute_agi_command).once.ordered do
|
|
866
876
|
sleep 0.2
|
|
867
877
|
end
|
|
868
878
|
latch = CountDownLatch.new 1
|
|
869
|
-
original_command.
|
|
870
|
-
e.reason.
|
|
879
|
+
expect(original_command).to receive(:add_event).once.with { |e|
|
|
880
|
+
expect(e.reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
871
881
|
latch.countdown!
|
|
872
|
-
|
|
882
|
+
}
|
|
873
883
|
Celluloid::Future.new { subject.execute }
|
|
874
884
|
sleep 0.1
|
|
875
|
-
mock_call.
|
|
885
|
+
expect(mock_call).to receive(:redirect_back).ordered
|
|
876
886
|
stop_command = Punchblock::Component::Stop.new
|
|
877
887
|
stop_command.request!
|
|
878
888
|
subject.execute_command stop_command
|
|
879
|
-
latch.wait(2).
|
|
889
|
+
expect(latch.wait(2)).to be_true
|
|
880
890
|
end
|
|
881
891
|
end
|
|
882
892
|
end
|
|
@@ -896,7 +906,7 @@ module Punchblock
|
|
|
896
906
|
it "should return an error and not execute any actions" do
|
|
897
907
|
subject.execute
|
|
898
908
|
error = ProtocolError.new.setup 'option error', 'A max_time value is unsupported on Asterisk.'
|
|
899
|
-
original_command.response(0.1).
|
|
909
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
900
910
|
end
|
|
901
911
|
end
|
|
902
912
|
end
|
|
@@ -916,7 +926,7 @@ module Punchblock
|
|
|
916
926
|
it "should return an error and not execute any actions" do
|
|
917
927
|
subject.execute
|
|
918
928
|
error = ProtocolError.new.setup 'option error', 'A voice value is unsupported on Asterisk.'
|
|
919
|
-
original_command.response(0.1).
|
|
929
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
920
930
|
end
|
|
921
931
|
end
|
|
922
932
|
end
|
|
@@ -948,9 +958,9 @@ module Punchblock
|
|
|
948
958
|
it "does not redirect the call" do
|
|
949
959
|
expect_answered
|
|
950
960
|
expect_playback
|
|
951
|
-
mock_call.
|
|
961
|
+
expect(mock_call).to receive(:redirect_back).never
|
|
952
962
|
subject.execute
|
|
953
|
-
original_command.response(0.1).
|
|
963
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
954
964
|
send_ami_events_for_dtmf 1
|
|
955
965
|
end
|
|
956
966
|
end
|
|
@@ -960,27 +970,27 @@ module Punchblock
|
|
|
960
970
|
|
|
961
971
|
before do
|
|
962
972
|
expect_answered
|
|
963
|
-
mock_call.
|
|
964
|
-
subject.
|
|
973
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Playback', audio_filename)
|
|
974
|
+
expect(subject).to receive(:send_finish).and_return nil
|
|
965
975
|
end
|
|
966
976
|
|
|
967
977
|
context "when a DTMF digit is received" do
|
|
968
978
|
it "sends the correct complete event" do
|
|
969
|
-
mock_call.
|
|
979
|
+
expect(mock_call).to receive :redirect_back
|
|
970
980
|
subject.execute
|
|
971
|
-
original_command.response(0.1).
|
|
972
|
-
original_command.
|
|
981
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
982
|
+
expect(original_command).not_to be_complete
|
|
973
983
|
send_ami_events_for_dtmf 1
|
|
974
984
|
mock_call.process_ami_event ami_event
|
|
975
985
|
sleep 0.2
|
|
976
|
-
original_command.
|
|
977
|
-
reason.
|
|
986
|
+
expect(original_command).to be_complete
|
|
987
|
+
expect(reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
978
988
|
end
|
|
979
989
|
|
|
980
990
|
it "redirects the call back to async AGI" do
|
|
981
|
-
mock_call.
|
|
991
|
+
expect(mock_call).to receive(:redirect_back).once
|
|
982
992
|
subject.execute
|
|
983
|
-
original_command.response(0.1).
|
|
993
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
984
994
|
send_ami_events_for_dtmf 1
|
|
985
995
|
end
|
|
986
996
|
end
|
|
@@ -991,27 +1001,27 @@ module Punchblock
|
|
|
991
1001
|
|
|
992
1002
|
before do
|
|
993
1003
|
expect_answered
|
|
994
|
-
mock_call.
|
|
995
|
-
subject.
|
|
1004
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Playback', audio_filename)
|
|
1005
|
+
expect(subject).to receive(:send_finish).and_return nil
|
|
996
1006
|
end
|
|
997
1007
|
|
|
998
1008
|
context "when a DTMF digit is received" do
|
|
999
1009
|
it "sends the correct complete event" do
|
|
1000
|
-
mock_call.
|
|
1010
|
+
expect(mock_call).to receive :redirect_back
|
|
1001
1011
|
subject.execute
|
|
1002
|
-
original_command.response(0.1).
|
|
1003
|
-
original_command.
|
|
1012
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
1013
|
+
expect(original_command).not_to be_complete
|
|
1004
1014
|
send_ami_events_for_dtmf 1
|
|
1005
1015
|
mock_call.process_ami_event ami_event
|
|
1006
1016
|
sleep 0.2
|
|
1007
|
-
original_command.
|
|
1008
|
-
reason.
|
|
1017
|
+
expect(original_command).to be_complete
|
|
1018
|
+
expect(reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1009
1019
|
end
|
|
1010
1020
|
|
|
1011
1021
|
it "redirects the call back to async AGI" do
|
|
1012
|
-
mock_call.
|
|
1022
|
+
expect(mock_call).to receive(:redirect_back).once
|
|
1013
1023
|
subject.execute
|
|
1014
|
-
original_command.response(0.1).
|
|
1024
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
1015
1025
|
send_ami_events_for_dtmf 1
|
|
1016
1026
|
end
|
|
1017
1027
|
end
|
|
@@ -1022,7 +1032,7 @@ module Punchblock
|
|
|
1022
1032
|
it "should return an error and not execute any actions" do
|
|
1023
1033
|
subject.execute
|
|
1024
1034
|
error = ProtocolError.new.setup 'option error', 'An interrupt-on value of speech is unsupported.'
|
|
1025
|
-
original_command.response(0.1).
|
|
1035
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
1026
1036
|
end
|
|
1027
1037
|
end
|
|
1028
1038
|
end
|
|
@@ -1031,15 +1041,15 @@ module Punchblock
|
|
|
1031
1041
|
|
|
1032
1042
|
context "with a renderer of :native_or_unimrcp" do
|
|
1033
1043
|
def expect_playback(filename = audio_filename)
|
|
1034
|
-
mock_call.
|
|
1044
|
+
expect(mock_call).to receive(:execute_agi_command).ordered.once.with('EXEC Playback', filename).and_return code: 200
|
|
1035
1045
|
end
|
|
1036
1046
|
|
|
1037
1047
|
def expect_playback_noanswer
|
|
1038
|
-
mock_call.
|
|
1048
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Playback', audio_filename + ',noanswer').and_return code: 200
|
|
1039
1049
|
end
|
|
1040
1050
|
|
|
1041
1051
|
def expect_mrcpsynth(doc = ssml_doc)
|
|
1042
|
-
mock_call.
|
|
1052
|
+
expect(mock_call).to receive(:execute_agi_command).ordered.once.with('EXEC MRCPSynth', ["\"#{doc.to_s.squish.gsub('"', '\"')}\"", ''].join(',')).and_return code: 200, result: 1
|
|
1043
1053
|
end
|
|
1044
1054
|
|
|
1045
1055
|
let(:audio_filename) { 'tt-monkeys' }
|
|
@@ -1063,7 +1073,7 @@ module Punchblock
|
|
|
1063
1073
|
end
|
|
1064
1074
|
|
|
1065
1075
|
let(:playbackstatus) { 'SUCCESS' }
|
|
1066
|
-
before { mock_call.
|
|
1076
|
+
before { allow(mock_call).to receive(:channel_var).with('PLAYBACKSTATUS').and_return playbackstatus }
|
|
1067
1077
|
|
|
1068
1078
|
describe 'ssml' do
|
|
1069
1079
|
context 'unset' do
|
|
@@ -1071,7 +1081,7 @@ module Punchblock
|
|
|
1071
1081
|
it "should return an error and not execute any actions" do
|
|
1072
1082
|
subject.execute
|
|
1073
1083
|
error = ProtocolError.new.setup 'option error', 'An SSML document is required.'
|
|
1074
|
-
original_command.response(0.1).
|
|
1084
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
1075
1085
|
end
|
|
1076
1086
|
end
|
|
1077
1087
|
|
|
@@ -1099,7 +1109,7 @@ module Punchblock
|
|
|
1099
1109
|
end
|
|
1100
1110
|
expect_playback
|
|
1101
1111
|
subject.execute
|
|
1102
|
-
original_command.complete_event(0.1).reason.
|
|
1112
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1103
1113
|
end
|
|
1104
1114
|
|
|
1105
1115
|
context "when the audio filename is prefixed by file://" do
|
|
@@ -1136,11 +1146,11 @@ module Punchblock
|
|
|
1136
1146
|
it "should send an error complete event" do
|
|
1137
1147
|
expect_answered
|
|
1138
1148
|
error = RubyAMI::Error.new.tap { |e| e.message = 'FooBar' }
|
|
1139
|
-
mock_call.
|
|
1149
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
1140
1150
|
subject.execute
|
|
1141
1151
|
complete_reason = original_command.complete_event(0.1).reason
|
|
1142
|
-
complete_reason.
|
|
1143
|
-
complete_reason.details.
|
|
1152
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
1153
|
+
expect(complete_reason.details).to eq("Terminated due to AMI error 'FooBar'")
|
|
1144
1154
|
end
|
|
1145
1155
|
end
|
|
1146
1156
|
|
|
@@ -1148,10 +1158,10 @@ module Punchblock
|
|
|
1148
1158
|
it "should send an error complete event" do
|
|
1149
1159
|
expect_answered
|
|
1150
1160
|
error = ChannelGoneError.new 'FooBar'
|
|
1151
|
-
mock_call.
|
|
1161
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
1152
1162
|
subject.execute
|
|
1153
1163
|
complete_reason = original_command.complete_event(0.1).reason
|
|
1154
|
-
complete_reason.
|
|
1164
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Hangup
|
|
1155
1165
|
end
|
|
1156
1166
|
end
|
|
1157
1167
|
|
|
@@ -1159,7 +1169,7 @@ module Punchblock
|
|
|
1159
1169
|
let(:playbackstatus) { 'FAILED' }
|
|
1160
1170
|
|
|
1161
1171
|
let(:synthstatus) { 'SUCCESS' }
|
|
1162
|
-
before { mock_call.
|
|
1172
|
+
before { allow(mock_call).to receive(:channel_var).with('SYNTHSTATUS').and_return synthstatus }
|
|
1163
1173
|
|
|
1164
1174
|
let :fallback_doc do
|
|
1165
1175
|
RubySpeech::SSML.draw language: 'pt-BR' do
|
|
@@ -1174,7 +1184,7 @@ module Punchblock
|
|
|
1174
1184
|
expect_playback
|
|
1175
1185
|
expect_mrcpsynth fallback_doc
|
|
1176
1186
|
subject.execute
|
|
1177
|
-
original_command.complete_event(0.1).reason.
|
|
1187
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1178
1188
|
end
|
|
1179
1189
|
|
|
1180
1190
|
context "and the SYNTHSTATUS variable is set to 'ERROR'" do
|
|
@@ -1186,8 +1196,8 @@ module Punchblock
|
|
|
1186
1196
|
expect_mrcpsynth fallback_doc
|
|
1187
1197
|
subject.execute
|
|
1188
1198
|
complete_reason = original_command.complete_event(0.1).reason
|
|
1189
|
-
complete_reason.
|
|
1190
|
-
complete_reason.details.
|
|
1199
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
1200
|
+
expect(complete_reason.details).to eq("Terminated due to UniMRCP error")
|
|
1191
1201
|
end
|
|
1192
1202
|
end
|
|
1193
1203
|
end
|
|
@@ -1209,18 +1219,18 @@ module Punchblock
|
|
|
1209
1219
|
expect_answered
|
|
1210
1220
|
expect_playback
|
|
1211
1221
|
subject.execute
|
|
1212
|
-
original_command.complete_event(0.1).reason.
|
|
1222
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1213
1223
|
end
|
|
1214
1224
|
|
|
1215
1225
|
context "when we get a RubyAMI Error" do
|
|
1216
1226
|
it "should send an error complete event" do
|
|
1217
1227
|
expect_answered
|
|
1218
1228
|
error = RubyAMI::Error.new.tap { |e| e.message = 'FooBar' }
|
|
1219
|
-
mock_call.
|
|
1229
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
1220
1230
|
subject.execute
|
|
1221
1231
|
complete_reason = original_command.complete_event(0.1).reason
|
|
1222
|
-
complete_reason.
|
|
1223
|
-
complete_reason.details.
|
|
1232
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
1233
|
+
expect(complete_reason.details).to eq("Terminated due to AMI error 'FooBar'")
|
|
1224
1234
|
end
|
|
1225
1235
|
end
|
|
1226
1236
|
|
|
@@ -1228,7 +1238,7 @@ module Punchblock
|
|
|
1228
1238
|
it "should play the file with Playback" do
|
|
1229
1239
|
expect_answered false
|
|
1230
1240
|
expect_playback_noanswer
|
|
1231
|
-
mock_call.
|
|
1241
|
+
expect(mock_call).to receive(:send_progress)
|
|
1232
1242
|
subject.execute
|
|
1233
1243
|
end
|
|
1234
1244
|
|
|
@@ -1246,7 +1256,7 @@ module Punchblock
|
|
|
1246
1256
|
expect_answered false
|
|
1247
1257
|
error = ProtocolError.new.setup 'option error', 'Interrupt digits are not allowed with early media.'
|
|
1248
1258
|
subject.execute
|
|
1249
|
-
original_command.response(0.1).
|
|
1259
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
1250
1260
|
end
|
|
1251
1261
|
end
|
|
1252
1262
|
end
|
|
@@ -1287,37 +1297,37 @@ module Punchblock
|
|
|
1287
1297
|
expect_playback audio_filename2
|
|
1288
1298
|
expect_playback audio_filename3
|
|
1289
1299
|
latch = CountDownLatch.new 1
|
|
1290
|
-
original_command.
|
|
1291
|
-
e.reason.
|
|
1300
|
+
expect(original_command).to receive(:add_event).once.with { |e|
|
|
1301
|
+
expect(e.reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1292
1302
|
latch.countdown!
|
|
1293
|
-
|
|
1303
|
+
}
|
|
1294
1304
|
subject.execute
|
|
1295
|
-
latch.wait(2).
|
|
1305
|
+
expect(latch.wait(2)).to be_true
|
|
1296
1306
|
end
|
|
1297
1307
|
|
|
1298
1308
|
it 'should not execute further output after a stop command' do
|
|
1299
1309
|
expect_answered
|
|
1300
|
-
mock_call.
|
|
1310
|
+
expect(mock_call).to receive(:execute_agi_command).once.ordered do
|
|
1301
1311
|
sleep 0.2
|
|
1302
1312
|
end
|
|
1303
1313
|
latch = CountDownLatch.new 1
|
|
1304
|
-
original_command.
|
|
1305
|
-
e.reason.
|
|
1314
|
+
expect(original_command).to receive(:add_event).once.with { |e|
|
|
1315
|
+
expect(e.reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1306
1316
|
latch.countdown!
|
|
1307
|
-
|
|
1317
|
+
}
|
|
1308
1318
|
Celluloid::Future.new { subject.execute }
|
|
1309
1319
|
sleep 0.1
|
|
1310
|
-
mock_call.
|
|
1320
|
+
expect(mock_call).to receive(:redirect_back).ordered
|
|
1311
1321
|
stop_command = Punchblock::Component::Stop.new
|
|
1312
1322
|
stop_command.request!
|
|
1313
1323
|
subject.execute_command stop_command
|
|
1314
|
-
latch.wait(2).
|
|
1324
|
+
expect(latch.wait(2)).to be_true
|
|
1315
1325
|
end
|
|
1316
1326
|
|
|
1317
1327
|
context "when the PLAYBACKSTATUS variable is set to 'FAILED'" do
|
|
1318
1328
|
let(:synthstatus) { 'SUCCESS' }
|
|
1319
|
-
before { mock_call.
|
|
1320
|
-
before { mock_call.
|
|
1329
|
+
before { allow(mock_call).to receive(:channel_var).with('PLAYBACKSTATUS').and_return 'SUCCESS', 'FAILED', 'SUCCESS' }
|
|
1330
|
+
before { allow(mock_call).to receive(:channel_var).with('SYNTHSTATUS').and_return synthstatus }
|
|
1321
1331
|
|
|
1322
1332
|
let :fallback_doc do
|
|
1323
1333
|
RubySpeech::SSML.draw do
|
|
@@ -1332,7 +1342,7 @@ module Punchblock
|
|
|
1332
1342
|
expect_mrcpsynth fallback_doc
|
|
1333
1343
|
expect_playback audio_filename3
|
|
1334
1344
|
subject.execute
|
|
1335
|
-
original_command.complete_event(0.1).reason.
|
|
1345
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1336
1346
|
end
|
|
1337
1347
|
|
|
1338
1348
|
context "and the SYNTHSTATUS variable is set to 'ERROR'" do
|
|
@@ -1345,8 +1355,8 @@ module Punchblock
|
|
|
1345
1355
|
expect_mrcpsynth fallback_doc
|
|
1346
1356
|
subject.execute
|
|
1347
1357
|
complete_reason = original_command.complete_event(0.1).reason
|
|
1348
|
-
complete_reason.
|
|
1349
|
-
complete_reason.details.
|
|
1358
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
1359
|
+
expect(complete_reason.details).to eq("Terminated due to UniMRCP error")
|
|
1350
1360
|
end
|
|
1351
1361
|
end
|
|
1352
1362
|
end
|
|
@@ -1361,13 +1371,13 @@ module Punchblock
|
|
|
1361
1371
|
end
|
|
1362
1372
|
end
|
|
1363
1373
|
|
|
1364
|
-
before { mock_call.
|
|
1374
|
+
before { allow(mock_call).to receive(:channel_var).with('SYNTHSTATUS').and_return 'SUCCESS' }
|
|
1365
1375
|
|
|
1366
1376
|
it "should attempt to render the document via MRCP and then send a complete event" do
|
|
1367
1377
|
expect_answered
|
|
1368
1378
|
expect_mrcpsynth ssml_doc
|
|
1369
1379
|
subject.execute
|
|
1370
|
-
original_command.complete_event(0.1).reason.
|
|
1380
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1371
1381
|
end
|
|
1372
1382
|
end
|
|
1373
1383
|
|
|
@@ -1401,7 +1411,7 @@ module Punchblock
|
|
|
1401
1411
|
end
|
|
1402
1412
|
end
|
|
1403
1413
|
|
|
1404
|
-
before { mock_call.
|
|
1414
|
+
before { allow(mock_call).to receive(:channel_var).with('SYNTHSTATUS').and_return 'SUCCESS' }
|
|
1405
1415
|
|
|
1406
1416
|
it "should attempt to render the document via MRCP and then send a complete event" do
|
|
1407
1417
|
expect_answered
|
|
@@ -1410,7 +1420,7 @@ module Punchblock
|
|
|
1410
1420
|
expect_mrcpsynth second_doc
|
|
1411
1421
|
expect_playback 'tt-weasels'
|
|
1412
1422
|
subject.execute
|
|
1413
|
-
original_command.complete_event(0.1).reason.
|
|
1423
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1414
1424
|
end
|
|
1415
1425
|
end
|
|
1416
1426
|
|
|
@@ -1439,32 +1449,32 @@ module Punchblock
|
|
|
1439
1449
|
expect_playback 'two'
|
|
1440
1450
|
expect_playback 'three'
|
|
1441
1451
|
subject.execute
|
|
1442
|
-
original_command.complete_event(0.1).reason.
|
|
1452
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1443
1453
|
end
|
|
1444
1454
|
|
|
1445
1455
|
it 'should not execute further output after a stop command' do
|
|
1446
1456
|
expect_answered
|
|
1447
|
-
mock_call.
|
|
1457
|
+
expect(mock_call).to receive(:execute_agi_command).once.ordered do
|
|
1448
1458
|
sleep 0.2
|
|
1449
1459
|
end
|
|
1450
1460
|
latch = CountDownLatch.new 1
|
|
1451
|
-
original_command.
|
|
1452
|
-
e.reason.
|
|
1461
|
+
expect(original_command).to receive(:add_event).once.with { |e|
|
|
1462
|
+
expect(e.reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1453
1463
|
latch.countdown!
|
|
1454
|
-
|
|
1464
|
+
}
|
|
1455
1465
|
Celluloid::Future.new { subject.execute }
|
|
1456
1466
|
sleep 0.1
|
|
1457
|
-
mock_call.
|
|
1467
|
+
expect(mock_call).to receive(:redirect_back).ordered
|
|
1458
1468
|
stop_command = Punchblock::Component::Stop.new
|
|
1459
1469
|
stop_command.request!
|
|
1460
1470
|
subject.execute_command stop_command
|
|
1461
|
-
latch.wait(2).
|
|
1471
|
+
expect(latch.wait(2)).to be_true
|
|
1462
1472
|
end
|
|
1463
1473
|
|
|
1464
1474
|
context "when the PLAYBACKSTATUS variable is set to 'FAILED'" do
|
|
1465
1475
|
let(:synthstatus) { 'SUCCESS' }
|
|
1466
|
-
before { mock_call.
|
|
1467
|
-
before { mock_call.
|
|
1476
|
+
before { allow(mock_call).to receive(:channel_var).with('PLAYBACKSTATUS').and_return 'SUCCESS', 'FAILED', 'SUCCESS' }
|
|
1477
|
+
before { allow(mock_call).to receive(:channel_var).with('SYNTHSTATUS').and_return synthstatus }
|
|
1468
1478
|
|
|
1469
1479
|
let :fallback_doc do
|
|
1470
1480
|
RubySpeech::SSML.draw do
|
|
@@ -1479,7 +1489,7 @@ module Punchblock
|
|
|
1479
1489
|
expect_mrcpsynth fallback_doc
|
|
1480
1490
|
expect_playback 'three'
|
|
1481
1491
|
subject.execute
|
|
1482
|
-
original_command.complete_event(0.1).reason.
|
|
1492
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1483
1493
|
end
|
|
1484
1494
|
|
|
1485
1495
|
context "and the SYNTHSTATUS variable is set to 'ERROR'" do
|
|
@@ -1492,8 +1502,8 @@ module Punchblock
|
|
|
1492
1502
|
expect_mrcpsynth fallback_doc
|
|
1493
1503
|
subject.execute
|
|
1494
1504
|
complete_reason = original_command.complete_event(0.1).reason
|
|
1495
|
-
complete_reason.
|
|
1496
|
-
complete_reason.details.
|
|
1505
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
1506
|
+
expect(complete_reason.details).to eq("Terminated due to UniMRCP error")
|
|
1497
1507
|
end
|
|
1498
1508
|
end
|
|
1499
1509
|
end
|
|
@@ -1515,7 +1525,7 @@ module Punchblock
|
|
|
1515
1525
|
it "should return an error and not execute any actions" do
|
|
1516
1526
|
subject.execute
|
|
1517
1527
|
error = ProtocolError.new.setup 'option error', 'A start_offset value is unsupported on Asterisk.'
|
|
1518
|
-
original_command.response(0.1).
|
|
1528
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
1519
1529
|
end
|
|
1520
1530
|
end
|
|
1521
1531
|
end
|
|
@@ -1535,7 +1545,7 @@ module Punchblock
|
|
|
1535
1545
|
it "should return an error and not execute any actions" do
|
|
1536
1546
|
subject.execute
|
|
1537
1547
|
error = ProtocolError.new.setup 'option error', 'A start_paused value is unsupported on Asterisk.'
|
|
1538
|
-
original_command.response(0.1).
|
|
1548
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
1539
1549
|
end
|
|
1540
1550
|
end
|
|
1541
1551
|
end
|
|
@@ -1555,7 +1565,7 @@ module Punchblock
|
|
|
1555
1565
|
it "should return an error and not execute any actions" do
|
|
1556
1566
|
subject.execute
|
|
1557
1567
|
error = ProtocolError.new.setup 'option error', 'A repeat_interval value is unsupported on Asterisk.'
|
|
1558
|
-
original_command.response(0.1).
|
|
1568
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
1559
1569
|
end
|
|
1560
1570
|
end
|
|
1561
1571
|
end
|
|
@@ -1577,7 +1587,7 @@ module Punchblock
|
|
|
1577
1587
|
expect_answered
|
|
1578
1588
|
2.times { expect_playback }
|
|
1579
1589
|
subject.execute
|
|
1580
|
-
original_command.complete_event(0.1).reason.
|
|
1590
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1581
1591
|
end
|
|
1582
1592
|
|
|
1583
1593
|
context 'to 0' do
|
|
@@ -1587,27 +1597,27 @@ module Punchblock
|
|
|
1587
1597
|
expect_answered
|
|
1588
1598
|
1000.times { expect_playback }
|
|
1589
1599
|
subject.execute
|
|
1590
|
-
original_command.complete_event(0.1).reason.
|
|
1600
|
+
expect(original_command.complete_event(0.1).reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1591
1601
|
end
|
|
1592
1602
|
end
|
|
1593
1603
|
|
|
1594
1604
|
it 'should not execute further output after a stop command' do
|
|
1595
1605
|
expect_answered
|
|
1596
|
-
mock_call.
|
|
1606
|
+
expect(mock_call).to receive(:execute_agi_command).once.ordered do
|
|
1597
1607
|
sleep 0.2
|
|
1598
1608
|
end
|
|
1599
1609
|
latch = CountDownLatch.new 1
|
|
1600
|
-
original_command.
|
|
1601
|
-
e.reason.
|
|
1610
|
+
expect(original_command).to receive(:add_event).once.with { |e|
|
|
1611
|
+
expect(e.reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1602
1612
|
latch.countdown!
|
|
1603
|
-
|
|
1613
|
+
}
|
|
1604
1614
|
Celluloid::Future.new { subject.execute }
|
|
1605
1615
|
sleep 0.1
|
|
1606
|
-
mock_call.
|
|
1616
|
+
expect(mock_call).to receive(:redirect_back).ordered
|
|
1607
1617
|
stop_command = Punchblock::Component::Stop.new
|
|
1608
1618
|
stop_command.request!
|
|
1609
1619
|
subject.execute_command stop_command
|
|
1610
|
-
latch.wait(2).
|
|
1620
|
+
expect(latch.wait(2)).to be_true
|
|
1611
1621
|
end
|
|
1612
1622
|
end
|
|
1613
1623
|
end
|
|
@@ -1627,7 +1637,7 @@ module Punchblock
|
|
|
1627
1637
|
it "should return an error and not execute any actions" do
|
|
1628
1638
|
subject.execute
|
|
1629
1639
|
error = ProtocolError.new.setup 'option error', 'A max_time value is unsupported on Asterisk.'
|
|
1630
|
-
original_command.response(0.1).
|
|
1640
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
1631
1641
|
end
|
|
1632
1642
|
end
|
|
1633
1643
|
end
|
|
@@ -1647,7 +1657,7 @@ module Punchblock
|
|
|
1647
1657
|
it "should return an error and not execute any actions" do
|
|
1648
1658
|
subject.execute
|
|
1649
1659
|
error = ProtocolError.new.setup 'option error', 'A voice value is unsupported on Asterisk.'
|
|
1650
|
-
original_command.response(0.1).
|
|
1660
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
1651
1661
|
end
|
|
1652
1662
|
end
|
|
1653
1663
|
end
|
|
@@ -1679,9 +1689,9 @@ module Punchblock
|
|
|
1679
1689
|
it "does not redirect the call" do
|
|
1680
1690
|
expect_answered
|
|
1681
1691
|
expect_playback
|
|
1682
|
-
mock_call.
|
|
1692
|
+
expect(mock_call).to receive(:redirect_back).never
|
|
1683
1693
|
subject.execute
|
|
1684
|
-
original_command.response(0.1).
|
|
1694
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
1685
1695
|
send_ami_events_for_dtmf 1
|
|
1686
1696
|
end
|
|
1687
1697
|
end
|
|
@@ -1691,27 +1701,27 @@ module Punchblock
|
|
|
1691
1701
|
|
|
1692
1702
|
before do
|
|
1693
1703
|
expect_answered
|
|
1694
|
-
mock_call.
|
|
1695
|
-
subject.
|
|
1704
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Playback', audio_filename)
|
|
1705
|
+
expect(subject).to receive(:send_finish).and_return nil
|
|
1696
1706
|
end
|
|
1697
1707
|
|
|
1698
1708
|
context "when a DTMF digit is received" do
|
|
1699
1709
|
it "sends the correct complete event" do
|
|
1700
|
-
mock_call.
|
|
1710
|
+
expect(mock_call).to receive :redirect_back
|
|
1701
1711
|
subject.execute
|
|
1702
|
-
original_command.response(0.1).
|
|
1703
|
-
original_command.
|
|
1712
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
1713
|
+
expect(original_command).not_to be_complete
|
|
1704
1714
|
send_ami_events_for_dtmf 1
|
|
1705
1715
|
mock_call.process_ami_event ami_event
|
|
1706
1716
|
sleep 0.2
|
|
1707
|
-
original_command.
|
|
1708
|
-
reason.
|
|
1717
|
+
expect(original_command).to be_complete
|
|
1718
|
+
expect(reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1709
1719
|
end
|
|
1710
1720
|
|
|
1711
1721
|
it "redirects the call back to async AGI" do
|
|
1712
|
-
mock_call.
|
|
1722
|
+
expect(mock_call).to receive(:redirect_back).once
|
|
1713
1723
|
subject.execute
|
|
1714
|
-
original_command.response(0.1).
|
|
1724
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
1715
1725
|
send_ami_events_for_dtmf 1
|
|
1716
1726
|
end
|
|
1717
1727
|
end
|
|
@@ -1722,27 +1732,27 @@ module Punchblock
|
|
|
1722
1732
|
|
|
1723
1733
|
before do
|
|
1724
1734
|
expect_answered
|
|
1725
|
-
mock_call.
|
|
1726
|
-
subject.
|
|
1735
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC Playback', audio_filename)
|
|
1736
|
+
expect(subject).to receive(:send_finish).and_return nil
|
|
1727
1737
|
end
|
|
1728
1738
|
|
|
1729
1739
|
context "when a DTMF digit is received" do
|
|
1730
1740
|
it "sends the correct complete event" do
|
|
1731
|
-
mock_call.
|
|
1741
|
+
expect(mock_call).to receive :redirect_back
|
|
1732
1742
|
subject.execute
|
|
1733
|
-
original_command.response(0.1).
|
|
1734
|
-
original_command.
|
|
1743
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
1744
|
+
expect(original_command).not_to be_complete
|
|
1735
1745
|
send_ami_events_for_dtmf 1
|
|
1736
1746
|
mock_call.process_ami_event ami_event
|
|
1737
1747
|
sleep 0.2
|
|
1738
|
-
original_command.
|
|
1739
|
-
reason.
|
|
1748
|
+
expect(original_command).to be_complete
|
|
1749
|
+
expect(reason).to be_a Punchblock::Component::Output::Complete::Finish
|
|
1740
1750
|
end
|
|
1741
1751
|
|
|
1742
1752
|
it "redirects the call back to async AGI" do
|
|
1743
|
-
mock_call.
|
|
1753
|
+
expect(mock_call).to receive(:redirect_back).once
|
|
1744
1754
|
subject.execute
|
|
1745
|
-
original_command.response(0.1).
|
|
1755
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
1746
1756
|
send_ami_events_for_dtmf 1
|
|
1747
1757
|
end
|
|
1748
1758
|
end
|
|
@@ -1753,7 +1763,7 @@ module Punchblock
|
|
|
1753
1763
|
it "should return an error and not execute any actions" do
|
|
1754
1764
|
subject.execute
|
|
1755
1765
|
error = ProtocolError.new.setup 'option error', 'An interrupt-on value of speech is unsupported.'
|
|
1756
|
-
original_command.response(0.1).
|
|
1766
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
1757
1767
|
end
|
|
1758
1768
|
end
|
|
1759
1769
|
end
|
|
@@ -1767,7 +1777,7 @@ module Punchblock
|
|
|
1767
1777
|
before { command.request! }
|
|
1768
1778
|
it "returns a ProtocolError response" do
|
|
1769
1779
|
subject.execute_command command
|
|
1770
|
-
command.response(0.1).
|
|
1780
|
+
expect(command.response(0.1)).to be_a ProtocolError
|
|
1771
1781
|
end
|
|
1772
1782
|
end
|
|
1773
1783
|
|
|
@@ -1789,22 +1799,22 @@ module Punchblock
|
|
|
1789
1799
|
end
|
|
1790
1800
|
|
|
1791
1801
|
it "sets the command response to true" do
|
|
1792
|
-
mock_call.
|
|
1802
|
+
expect(mock_call).to receive(:redirect_back)
|
|
1793
1803
|
subject.execute_command command
|
|
1794
|
-
command.response(0.1).
|
|
1804
|
+
expect(command.response(0.1)).to eq(true)
|
|
1795
1805
|
end
|
|
1796
1806
|
|
|
1797
1807
|
it "sends the correct complete event" do
|
|
1798
|
-
mock_call.
|
|
1808
|
+
expect(mock_call).to receive(:redirect_back)
|
|
1799
1809
|
subject.execute_command command
|
|
1800
|
-
original_command.
|
|
1810
|
+
expect(original_command).not_to be_complete
|
|
1801
1811
|
mock_call.process_ami_event ami_event
|
|
1802
|
-
reason.
|
|
1803
|
-
original_command.
|
|
1812
|
+
expect(reason).to be_a Punchblock::Event::Complete::Stop
|
|
1813
|
+
expect(original_command).to be_complete
|
|
1804
1814
|
end
|
|
1805
1815
|
|
|
1806
1816
|
it "redirects the call by unjoining it" do
|
|
1807
|
-
mock_call.
|
|
1817
|
+
expect(mock_call).to receive(:redirect_back)
|
|
1808
1818
|
subject.execute_command command
|
|
1809
1819
|
end
|
|
1810
1820
|
end
|