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
|
@@ -90,7 +90,7 @@ module Punchblock
|
|
|
90
90
|
'RECOG_COMPLETION_CAUSE' => recog_completion_cause,
|
|
91
91
|
'RECOG_RESULT' => recog_result
|
|
92
92
|
}.each do |var, val|
|
|
93
|
-
mock_call.
|
|
93
|
+
allow(mock_call).to receive(:channel_var).with(var).and_return val
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
|
|
@@ -100,7 +100,7 @@ module Punchblock
|
|
|
100
100
|
it "should return an error and not execute any actions" do
|
|
101
101
|
subject.execute
|
|
102
102
|
error = ProtocolError.new.setup 'option error', 'The recognizer foobar is unsupported.'
|
|
103
|
-
original_command.response(0.1).
|
|
103
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
|
|
@@ -111,7 +111,7 @@ module Punchblock
|
|
|
111
111
|
it "should return an error and not execute any actions" do
|
|
112
112
|
subject.execute
|
|
113
113
|
error = ProtocolError.new.setup 'option error', "The recognizer #{recognizer} is unsupported."
|
|
114
|
-
original_command.response(0.1).
|
|
114
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
end
|
|
@@ -121,10 +121,10 @@ module Punchblock
|
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
def expect_app_with_options(app, options)
|
|
124
|
-
mock_call.
|
|
125
|
-
args[0].
|
|
126
|
-
args[1].
|
|
127
|
-
|
|
124
|
+
expect(mock_call).to receive(:execute_agi_command).once.with { |*args|
|
|
125
|
+
expect(args[0]).to eq("EXEC #{app}")
|
|
126
|
+
expect(args[1]).to match options
|
|
127
|
+
}.and_return code: 200, result: 1
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
describe 'Output#document' do
|
|
@@ -134,7 +134,7 @@ module Punchblock
|
|
|
134
134
|
it "should return an error and not execute any actions" do
|
|
135
135
|
subject.execute
|
|
136
136
|
error = ProtocolError.new.setup 'option error', 'Only one document is allowed.'
|
|
137
|
-
original_command.response(0.1).
|
|
137
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
138
138
|
end
|
|
139
139
|
end
|
|
140
140
|
|
|
@@ -144,7 +144,7 @@ module Punchblock
|
|
|
144
144
|
it "should return an error and not execute any actions" do
|
|
145
145
|
subject.execute
|
|
146
146
|
error = ProtocolError.new.setup 'option error', 'Only inline documents are allowed.'
|
|
147
|
-
original_command.response(0.1).
|
|
147
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
150
|
|
|
@@ -154,7 +154,7 @@ module Punchblock
|
|
|
154
154
|
it "should return an error and not execute any actions" do
|
|
155
155
|
subject.execute
|
|
156
156
|
error = ProtocolError.new.setup 'option error', 'Only one audio file is allowed.'
|
|
157
|
-
original_command.response(0.1).
|
|
157
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
|
|
@@ -164,7 +164,7 @@ module Punchblock
|
|
|
164
164
|
it "should return an error and not execute any actions" do
|
|
165
165
|
subject.execute
|
|
166
166
|
error = ProtocolError.new.setup 'option error', 'A document is required.'
|
|
167
|
-
original_command.response(0.1).
|
|
167
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
170
|
end
|
|
@@ -176,9 +176,9 @@ module Punchblock
|
|
|
176
176
|
|
|
177
177
|
it "should return a ref and execute MRCPRecog" do
|
|
178
178
|
param = ["\"#{grammar.to_doc.to_s.squish.gsub('"', '\"')}\"", "uer=1&b=1&f=#{audio_filename}"].join(',')
|
|
179
|
-
mock_call.
|
|
179
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC MRCPRecog', param).and_return code: 200, result: 1
|
|
180
180
|
subject.execute
|
|
181
|
-
original_command.response(0.1).
|
|
181
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
182
182
|
end
|
|
183
183
|
|
|
184
184
|
context "when MRCPRecog completes" do
|
|
@@ -189,15 +189,15 @@ module Punchblock
|
|
|
189
189
|
input 'Hello', mode: :speech
|
|
190
190
|
instance 'Hello'
|
|
191
191
|
end
|
|
192
|
-
end
|
|
192
|
+
end
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
it 'should send a match complete event' do
|
|
196
196
|
expected_complete_reason = Punchblock::Component::Input::Complete::Match.new nlsml: expected_nlsml
|
|
197
197
|
|
|
198
|
-
mock_call.
|
|
198
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
199
199
|
subject.execute
|
|
200
|
-
original_command.complete_event(0.1).reason.
|
|
200
|
+
expect(original_command.complete_event(0.1).reason).to eq(expected_complete_reason)
|
|
201
201
|
end
|
|
202
202
|
end
|
|
203
203
|
|
|
@@ -206,9 +206,9 @@ module Punchblock
|
|
|
206
206
|
|
|
207
207
|
it 'should send a nomatch complete event' do
|
|
208
208
|
expected_complete_reason = Punchblock::Component::Input::Complete::NoMatch.new
|
|
209
|
-
mock_call.
|
|
209
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
210
210
|
subject.execute
|
|
211
|
-
original_command.complete_event(0.1).reason.
|
|
211
|
+
expect(original_command.complete_event(0.1).reason).to eq(expected_complete_reason)
|
|
212
212
|
end
|
|
213
213
|
end
|
|
214
214
|
|
|
@@ -217,9 +217,9 @@ module Punchblock
|
|
|
217
217
|
|
|
218
218
|
it 'should send a nomatch complete event' do
|
|
219
219
|
expected_complete_reason = Punchblock::Component::Input::Complete::NoInput.new
|
|
220
|
-
mock_call.
|
|
220
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
221
221
|
subject.execute
|
|
222
|
-
original_command.complete_event(0.1).reason.
|
|
222
|
+
expect(original_command.complete_event(0.1).reason).to eq(expected_complete_reason)
|
|
223
223
|
end
|
|
224
224
|
end
|
|
225
225
|
|
|
@@ -227,11 +227,11 @@ module Punchblock
|
|
|
227
227
|
let(:recog_status) { 'ERROR' }
|
|
228
228
|
|
|
229
229
|
it "should send an error complete event" do
|
|
230
|
-
mock_call.
|
|
230
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
231
231
|
subject.execute
|
|
232
232
|
complete_reason = original_command.complete_event(0.1).reason
|
|
233
|
-
complete_reason.
|
|
234
|
-
complete_reason.details.
|
|
233
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
234
|
+
expect(complete_reason.details).to eq("Terminated due to UniMRCP error")
|
|
235
235
|
end
|
|
236
236
|
end
|
|
237
237
|
end
|
|
@@ -239,21 +239,21 @@ module Punchblock
|
|
|
239
239
|
context "when we get a RubyAMI Error" do
|
|
240
240
|
it "should send an error complete event" do
|
|
241
241
|
error = RubyAMI::Error.new.tap { |e| e.message = 'FooBar' }
|
|
242
|
-
mock_call.
|
|
242
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
243
243
|
subject.execute
|
|
244
244
|
complete_reason = original_command.complete_event(0.1).reason
|
|
245
|
-
complete_reason.
|
|
246
|
-
complete_reason.details.
|
|
245
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
246
|
+
expect(complete_reason.details).to eq("Terminated due to AMI error 'FooBar'")
|
|
247
247
|
end
|
|
248
248
|
end
|
|
249
249
|
|
|
250
250
|
context "when the channel is gone" do
|
|
251
251
|
it "should send an error complete event" do
|
|
252
252
|
error = ChannelGoneError.new 'FooBar'
|
|
253
|
-
mock_call.
|
|
253
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
254
254
|
subject.execute
|
|
255
255
|
complete_reason = original_command.complete_event(0.1).reason
|
|
256
|
-
complete_reason.
|
|
256
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Hangup
|
|
257
257
|
end
|
|
258
258
|
end
|
|
259
259
|
end
|
|
@@ -266,7 +266,7 @@ module Punchblock
|
|
|
266
266
|
it "should return an error and not execute any actions" do
|
|
267
267
|
subject.execute
|
|
268
268
|
error = ProtocolError.new.setup 'option error', "The renderer #{renderer} is unsupported."
|
|
269
|
-
original_command.response(0.1).
|
|
269
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
270
270
|
end
|
|
271
271
|
end
|
|
272
272
|
end
|
|
@@ -335,7 +335,7 @@ module Punchblock
|
|
|
335
335
|
it "should return an error and not execute any actions" do
|
|
336
336
|
subject.execute
|
|
337
337
|
error = ProtocolError.new.setup 'option error', 'A start_offset value is unsupported on Asterisk.'
|
|
338
|
-
original_command.response(0.1).
|
|
338
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
339
339
|
end
|
|
340
340
|
end
|
|
341
341
|
end
|
|
@@ -354,7 +354,7 @@ module Punchblock
|
|
|
354
354
|
it "should return an error and not execute any actions" do
|
|
355
355
|
subject.execute
|
|
356
356
|
error = ProtocolError.new.setup 'option error', 'A start_paused value is unsupported on Asterisk.'
|
|
357
|
-
original_command.response(0.1).
|
|
357
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
358
358
|
end
|
|
359
359
|
end
|
|
360
360
|
end
|
|
@@ -373,7 +373,7 @@ module Punchblock
|
|
|
373
373
|
it "should return an error and not execute any actions" do
|
|
374
374
|
subject.execute
|
|
375
375
|
error = ProtocolError.new.setup 'option error', 'A repeat_interval value is unsupported on Asterisk.'
|
|
376
|
-
original_command.response(0.1).
|
|
376
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
377
377
|
end
|
|
378
378
|
end
|
|
379
379
|
end
|
|
@@ -392,7 +392,7 @@ module Punchblock
|
|
|
392
392
|
it "should return an error and not execute any actions" do
|
|
393
393
|
subject.execute
|
|
394
394
|
error = ProtocolError.new.setup 'option error', 'A repeat_times value is unsupported on Asterisk.'
|
|
395
|
-
original_command.response(0.1).
|
|
395
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
396
396
|
end
|
|
397
397
|
end
|
|
398
398
|
end
|
|
@@ -411,7 +411,7 @@ module Punchblock
|
|
|
411
411
|
it "should return an error and not execute any actions" do
|
|
412
412
|
subject.execute
|
|
413
413
|
error = ProtocolError.new.setup 'option error', 'A max_time value is unsupported on Asterisk.'
|
|
414
|
-
original_command.response(0.1).
|
|
414
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
415
415
|
end
|
|
416
416
|
end
|
|
417
417
|
end
|
|
@@ -430,7 +430,7 @@ module Punchblock
|
|
|
430
430
|
it "should return an error and not execute any actions" do
|
|
431
431
|
subject.execute
|
|
432
432
|
error = ProtocolError.new.setup 'option error', 'A interrupt_on value is unsupported on Asterisk.'
|
|
433
|
-
original_command.response(0.1).
|
|
433
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
434
434
|
end
|
|
435
435
|
end
|
|
436
436
|
end
|
|
@@ -441,9 +441,9 @@ module Punchblock
|
|
|
441
441
|
|
|
442
442
|
it "should return a ref and execute MRCPRecog" do
|
|
443
443
|
param = ["\"#{[voice_grammar.to_doc.to_s, dtmf_grammar.to_doc.to_s].join(',').squish.gsub('"', '\"')}\"", "uer=1&b=1&f=#{audio_filename}"].join(',')
|
|
444
|
-
mock_call.
|
|
444
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC MRCPRecog', param).and_return code: 200, result: 1
|
|
445
445
|
subject.execute
|
|
446
|
-
original_command.response(0.1).
|
|
446
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
447
447
|
end
|
|
448
448
|
end
|
|
449
449
|
|
|
@@ -452,9 +452,9 @@ module Punchblock
|
|
|
452
452
|
|
|
453
453
|
it "should return a ref and execute MRCPRecog" do
|
|
454
454
|
param = ["\"#{"http://example.com/grammar1.grxml,http://example.com/grammar2.grxml".squish.gsub('"', '\"')}\"", "uer=1&b=1&f=#{audio_filename}"].join(',')
|
|
455
|
-
mock_call.
|
|
455
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC MRCPRecog', param).and_return code: 200, result: 1
|
|
456
456
|
subject.execute
|
|
457
|
-
original_command.response(0.1).
|
|
457
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
458
458
|
end
|
|
459
459
|
end
|
|
460
460
|
|
|
@@ -464,7 +464,7 @@ module Punchblock
|
|
|
464
464
|
it "should return an error and not execute any actions" do
|
|
465
465
|
subject.execute
|
|
466
466
|
error = ProtocolError.new.setup 'option error', 'A grammar is required.'
|
|
467
|
-
original_command.response(0.1).
|
|
467
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
468
468
|
end
|
|
469
469
|
end
|
|
470
470
|
end
|
|
@@ -503,7 +503,7 @@ module Punchblock
|
|
|
503
503
|
it "should return an error and not execute any actions" do
|
|
504
504
|
subject.execute
|
|
505
505
|
error = ProtocolError.new.setup 'option error', 'An initial-timeout value must be -1 or a positive integer.'
|
|
506
|
-
original_command.response(0.1).
|
|
506
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
507
507
|
end
|
|
508
508
|
end
|
|
509
509
|
end
|
|
@@ -542,7 +542,7 @@ module Punchblock
|
|
|
542
542
|
it "should return an error and not execute any actions" do
|
|
543
543
|
subject.execute
|
|
544
544
|
error = ProtocolError.new.setup 'option error', 'An inter-digit-timeout value must be -1 or a positive integer.'
|
|
545
|
-
original_command.response(0.1).
|
|
545
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
546
546
|
end
|
|
547
547
|
end
|
|
548
548
|
end
|
|
@@ -650,7 +650,7 @@ module Punchblock
|
|
|
650
650
|
before { command.request! }
|
|
651
651
|
it "returns a ProtocolError response" do
|
|
652
652
|
subject.execute_command command
|
|
653
|
-
command.response(0.1).
|
|
653
|
+
expect(command.response(0.1)).to be_a ProtocolError
|
|
654
654
|
end
|
|
655
655
|
end
|
|
656
656
|
|
|
@@ -671,22 +671,22 @@ module Punchblock
|
|
|
671
671
|
end
|
|
672
672
|
|
|
673
673
|
it "sets the command response to true" do
|
|
674
|
-
mock_call.
|
|
674
|
+
expect(mock_call).to receive(:redirect_back)
|
|
675
675
|
subject.execute_command command
|
|
676
|
-
command.response(0.1).
|
|
676
|
+
expect(command.response(0.1)).to eq(true)
|
|
677
677
|
end
|
|
678
678
|
|
|
679
679
|
it "sends the correct complete event" do
|
|
680
|
-
mock_call.
|
|
680
|
+
expect(mock_call).to receive(:redirect_back)
|
|
681
681
|
subject.execute_command command
|
|
682
|
-
original_command.
|
|
682
|
+
expect(original_command).not_to be_complete
|
|
683
683
|
mock_call.process_ami_event ami_event
|
|
684
|
-
reason.
|
|
685
|
-
original_command.
|
|
684
|
+
expect(reason).to be_a Punchblock::Event::Complete::Stop
|
|
685
|
+
expect(original_command).to be_complete
|
|
686
686
|
end
|
|
687
687
|
|
|
688
688
|
it "redirects the call by unjoining it" do
|
|
689
|
-
mock_call.
|
|
689
|
+
expect(mock_call).to receive(:redirect_back)
|
|
690
690
|
subject.execute_command command
|
|
691
691
|
end
|
|
692
692
|
end
|
|
@@ -88,7 +88,7 @@ module Punchblock
|
|
|
88
88
|
'RECOG_COMPLETION_CAUSE' => recog_completion_cause,
|
|
89
89
|
'RECOG_RESULT' => recog_result
|
|
90
90
|
}.each do |var, val|
|
|
91
|
-
mock_call.
|
|
91
|
+
allow(mock_call).to receive(:channel_var).with(var).and_return val
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
@@ -98,7 +98,7 @@ module Punchblock
|
|
|
98
98
|
it "should return an error and not execute any actions" do
|
|
99
99
|
subject.execute
|
|
100
100
|
error = ProtocolError.new.setup 'option error', 'The recognizer foobar is unsupported.'
|
|
101
|
-
original_command.response(0.1).
|
|
101
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
|
|
@@ -109,7 +109,7 @@ module Punchblock
|
|
|
109
109
|
it "should return an error and not execute any actions" do
|
|
110
110
|
subject.execute
|
|
111
111
|
error = ProtocolError.new.setup 'option error', "The recognizer #{recognizer} is unsupported."
|
|
112
|
-
original_command.response(0.1).
|
|
112
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
115
|
end
|
|
@@ -123,10 +123,10 @@ module Punchblock
|
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
def expect_app_with_options(app, options)
|
|
126
|
-
mock_call.
|
|
127
|
-
args[0].
|
|
128
|
-
args[1].
|
|
129
|
-
|
|
126
|
+
expect(mock_call).to receive(:execute_agi_command).once.with { |*args|
|
|
127
|
+
expect(args[0]).to eq("EXEC #{app}")
|
|
128
|
+
expect(args[1]).to match options
|
|
129
|
+
}.and_return code: 200, result: 1
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
describe 'Output#document' do
|
|
@@ -136,7 +136,7 @@ module Punchblock
|
|
|
136
136
|
it "should return an error and not execute any actions" do
|
|
137
137
|
subject.execute
|
|
138
138
|
error = ProtocolError.new.setup 'option error', 'Only one document is allowed.'
|
|
139
|
-
original_command.response(0.1).
|
|
139
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
140
140
|
end
|
|
141
141
|
end
|
|
142
142
|
|
|
@@ -146,7 +146,7 @@ module Punchblock
|
|
|
146
146
|
it "should return an error and not execute any actions" do
|
|
147
147
|
subject.execute
|
|
148
148
|
error = ProtocolError.new.setup 'option error', 'Only one document is allowed.'
|
|
149
|
-
original_command.response(0.1).
|
|
149
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
150
150
|
end
|
|
151
151
|
end
|
|
152
152
|
|
|
@@ -156,7 +156,7 @@ module Punchblock
|
|
|
156
156
|
it "should return an error and not execute any actions" do
|
|
157
157
|
subject.execute
|
|
158
158
|
error = ProtocolError.new.setup 'option error', 'An SSML document is required.'
|
|
159
|
-
original_command.response(0.1).
|
|
159
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
end
|
|
@@ -168,9 +168,9 @@ module Punchblock
|
|
|
168
168
|
|
|
169
169
|
it "should return a ref and execute SynthAndRecog" do
|
|
170
170
|
param = [ssml_doc.to_doc, grammar.to_doc].map { |o| "\"#{o.to_s.squish.gsub('"', '\"')}\"" }.push('uer=1&b=1').join(',')
|
|
171
|
-
mock_call.
|
|
171
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC SynthAndRecog', param).and_return code: 200, result: 1
|
|
172
172
|
subject.execute
|
|
173
|
-
original_command.response(0.1).
|
|
173
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
context "when SynthAndRecog completes" do
|
|
@@ -187,9 +187,9 @@ module Punchblock
|
|
|
187
187
|
it 'should send a match complete event' do
|
|
188
188
|
expected_complete_reason = Punchblock::Component::Input::Complete::Match.new nlsml: expected_nlsml
|
|
189
189
|
|
|
190
|
-
mock_call.
|
|
190
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
191
191
|
subject.execute
|
|
192
|
-
original_command.complete_event(0.1).reason.
|
|
192
|
+
expect(original_command.complete_event(0.1).reason).to eq(expected_complete_reason)
|
|
193
193
|
end
|
|
194
194
|
end
|
|
195
195
|
|
|
@@ -198,9 +198,9 @@ module Punchblock
|
|
|
198
198
|
|
|
199
199
|
it 'should send a nomatch complete event' do
|
|
200
200
|
expected_complete_reason = Punchblock::Component::Input::Complete::NoMatch.new
|
|
201
|
-
mock_call.
|
|
201
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
202
202
|
subject.execute
|
|
203
|
-
original_command.complete_event(0.1).reason.
|
|
203
|
+
expect(original_command.complete_event(0.1).reason).to eq(expected_complete_reason)
|
|
204
204
|
end
|
|
205
205
|
end
|
|
206
206
|
|
|
@@ -209,9 +209,20 @@ module Punchblock
|
|
|
209
209
|
|
|
210
210
|
it 'should send a nomatch complete event' do
|
|
211
211
|
expected_complete_reason = Punchblock::Component::Input::Complete::NoInput.new
|
|
212
|
-
mock_call.
|
|
212
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
213
213
|
subject.execute
|
|
214
|
-
original_command.complete_event(0.1).reason.
|
|
214
|
+
expect(original_command.complete_event(0.1).reason).to eq(expected_complete_reason)
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
context "when the RECOG_STATUS variable is set to 'INTERRUPTED' after a successful recognition" do
|
|
219
|
+
let(:recog_status) { 'INTERRUPTED' }
|
|
220
|
+
|
|
221
|
+
it "should send an error complete event" do
|
|
222
|
+
expected_complete_reason = Punchblock::Component::Input::Complete::NoMatch.new
|
|
223
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
224
|
+
subject.execute
|
|
225
|
+
expect(original_command.complete_event(0.1).reason).to eq(expected_complete_reason)
|
|
215
226
|
end
|
|
216
227
|
end
|
|
217
228
|
|
|
@@ -219,11 +230,11 @@ module Punchblock
|
|
|
219
230
|
let(:recog_status) { 'ERROR' }
|
|
220
231
|
|
|
221
232
|
it "should send an error complete event" do
|
|
222
|
-
mock_call.
|
|
233
|
+
expect(mock_call).to receive(:execute_agi_command).and_return code: 200, result: 1
|
|
223
234
|
subject.execute
|
|
224
235
|
complete_reason = original_command.complete_event(0.1).reason
|
|
225
|
-
complete_reason.
|
|
226
|
-
complete_reason.details.
|
|
236
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
237
|
+
expect(complete_reason.details).to eq("Terminated due to UniMRCP error")
|
|
227
238
|
end
|
|
228
239
|
end
|
|
229
240
|
end
|
|
@@ -231,21 +242,21 @@ module Punchblock
|
|
|
231
242
|
context "when we get a RubyAMI Error" do
|
|
232
243
|
it "should send an error complete event" do
|
|
233
244
|
error = RubyAMI::Error.new.tap { |e| e.message = 'FooBar' }
|
|
234
|
-
mock_call.
|
|
245
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
235
246
|
subject.execute
|
|
236
247
|
complete_reason = original_command.complete_event(0.1).reason
|
|
237
|
-
complete_reason.
|
|
238
|
-
complete_reason.details.
|
|
248
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Error
|
|
249
|
+
expect(complete_reason.details).to eq("Terminated due to AMI error 'FooBar'")
|
|
239
250
|
end
|
|
240
251
|
end
|
|
241
252
|
|
|
242
253
|
context "when the channel is gone" do
|
|
243
254
|
it "should send an error complete event" do
|
|
244
255
|
error = ChannelGoneError.new 'FooBar'
|
|
245
|
-
mock_call.
|
|
256
|
+
expect(mock_call).to receive(:execute_agi_command).and_raise error
|
|
246
257
|
subject.execute
|
|
247
258
|
complete_reason = original_command.complete_event(0.1).reason
|
|
248
|
-
complete_reason.
|
|
259
|
+
expect(complete_reason).to be_a Punchblock::Event::Complete::Hangup
|
|
249
260
|
end
|
|
250
261
|
end
|
|
251
262
|
end
|
|
@@ -258,7 +269,7 @@ module Punchblock
|
|
|
258
269
|
it "should return an error and not execute any actions" do
|
|
259
270
|
subject.execute
|
|
260
271
|
error = ProtocolError.new.setup 'option error', "The renderer #{renderer} is unsupported."
|
|
261
|
-
original_command.response(0.1).
|
|
272
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
262
273
|
end
|
|
263
274
|
end
|
|
264
275
|
end
|
|
@@ -327,7 +338,7 @@ module Punchblock
|
|
|
327
338
|
it "should return an error and not execute any actions" do
|
|
328
339
|
subject.execute
|
|
329
340
|
error = ProtocolError.new.setup 'option error', 'A start_offset value is unsupported on Asterisk.'
|
|
330
|
-
original_command.response(0.1).
|
|
341
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
331
342
|
end
|
|
332
343
|
end
|
|
333
344
|
end
|
|
@@ -346,7 +357,7 @@ module Punchblock
|
|
|
346
357
|
it "should return an error and not execute any actions" do
|
|
347
358
|
subject.execute
|
|
348
359
|
error = ProtocolError.new.setup 'option error', 'A start_paused value is unsupported on Asterisk.'
|
|
349
|
-
original_command.response(0.1).
|
|
360
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
350
361
|
end
|
|
351
362
|
end
|
|
352
363
|
end
|
|
@@ -365,7 +376,7 @@ module Punchblock
|
|
|
365
376
|
it "should return an error and not execute any actions" do
|
|
366
377
|
subject.execute
|
|
367
378
|
error = ProtocolError.new.setup 'option error', 'A repeat_interval value is unsupported on Asterisk.'
|
|
368
|
-
original_command.response(0.1).
|
|
379
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
369
380
|
end
|
|
370
381
|
end
|
|
371
382
|
end
|
|
@@ -384,7 +395,7 @@ module Punchblock
|
|
|
384
395
|
it "should return an error and not execute any actions" do
|
|
385
396
|
subject.execute
|
|
386
397
|
error = ProtocolError.new.setup 'option error', 'A repeat_times value is unsupported on Asterisk.'
|
|
387
|
-
original_command.response(0.1).
|
|
398
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
388
399
|
end
|
|
389
400
|
end
|
|
390
401
|
end
|
|
@@ -403,7 +414,7 @@ module Punchblock
|
|
|
403
414
|
it "should return an error and not execute any actions" do
|
|
404
415
|
subject.execute
|
|
405
416
|
error = ProtocolError.new.setup 'option error', 'A max_time value is unsupported on Asterisk.'
|
|
406
|
-
original_command.response(0.1).
|
|
417
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
407
418
|
end
|
|
408
419
|
end
|
|
409
420
|
end
|
|
@@ -422,7 +433,7 @@ module Punchblock
|
|
|
422
433
|
it "should return an error and not execute any actions" do
|
|
423
434
|
subject.execute
|
|
424
435
|
error = ProtocolError.new.setup 'option error', 'A interrupt_on value is unsupported on Asterisk.'
|
|
425
|
-
original_command.response(0.1).
|
|
436
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
426
437
|
end
|
|
427
438
|
end
|
|
428
439
|
end
|
|
@@ -433,9 +444,9 @@ module Punchblock
|
|
|
433
444
|
|
|
434
445
|
it "should return a ref and execute SynthAndRecog" do
|
|
435
446
|
param = [ssml_doc.to_doc, [voice_grammar.to_doc.to_s, dtmf_grammar.to_doc.to_s].join(',')].map { |o| "\"#{o.to_s.squish.gsub('"', '\"')}\"" }.push('uer=1&b=1').join(',')
|
|
436
|
-
mock_call.
|
|
447
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC SynthAndRecog', param).and_return code: 200, result: 1
|
|
437
448
|
subject.execute
|
|
438
|
-
original_command.response(0.1).
|
|
449
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
439
450
|
end
|
|
440
451
|
end
|
|
441
452
|
|
|
@@ -444,9 +455,9 @@ module Punchblock
|
|
|
444
455
|
|
|
445
456
|
it "should return a ref and execute SynthAndRecog" do
|
|
446
457
|
param = [ssml_doc.to_doc, ['http://example.com/grammar1.grxml', 'http://example.com/grammar2.grxml'].join(',')].map { |o| "\"#{o.to_s.squish.gsub('"', '\"')}\"" }.push('uer=1&b=1').join(',')
|
|
447
|
-
mock_call.
|
|
458
|
+
expect(mock_call).to receive(:execute_agi_command).once.with('EXEC SynthAndRecog', param).and_return code: 200, result: 1
|
|
448
459
|
subject.execute
|
|
449
|
-
original_command.response(0.1).
|
|
460
|
+
expect(original_command.response(0.1)).to be_a Ref
|
|
450
461
|
end
|
|
451
462
|
end
|
|
452
463
|
|
|
@@ -456,7 +467,7 @@ module Punchblock
|
|
|
456
467
|
it "should return an error and not execute any actions" do
|
|
457
468
|
subject.execute
|
|
458
469
|
error = ProtocolError.new.setup 'option error', 'A grammar is required.'
|
|
459
|
-
original_command.response(0.1).
|
|
470
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
460
471
|
end
|
|
461
472
|
end
|
|
462
473
|
end
|
|
@@ -495,7 +506,7 @@ module Punchblock
|
|
|
495
506
|
it "should return an error and not execute any actions" do
|
|
496
507
|
subject.execute
|
|
497
508
|
error = ProtocolError.new.setup 'option error', 'An initial-timeout value must be -1 or a positive integer.'
|
|
498
|
-
original_command.response(0.1).
|
|
509
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
499
510
|
end
|
|
500
511
|
end
|
|
501
512
|
end
|
|
@@ -534,7 +545,7 @@ module Punchblock
|
|
|
534
545
|
it "should return an error and not execute any actions" do
|
|
535
546
|
subject.execute
|
|
536
547
|
error = ProtocolError.new.setup 'option error', 'An inter-digit-timeout value must be -1 or a positive integer.'
|
|
537
|
-
original_command.response(0.1).
|
|
548
|
+
expect(original_command.response(0.1)).to eq(error)
|
|
538
549
|
end
|
|
539
550
|
end
|
|
540
551
|
end
|
|
@@ -642,7 +653,7 @@ module Punchblock
|
|
|
642
653
|
before { command.request! }
|
|
643
654
|
it "returns a ProtocolError response" do
|
|
644
655
|
subject.execute_command command
|
|
645
|
-
command.response(0.1).
|
|
656
|
+
expect(command.response(0.1)).to be_a ProtocolError
|
|
646
657
|
end
|
|
647
658
|
end
|
|
648
659
|
|
|
@@ -663,22 +674,22 @@ module Punchblock
|
|
|
663
674
|
end
|
|
664
675
|
|
|
665
676
|
it "sets the command response to true" do
|
|
666
|
-
mock_call.
|
|
677
|
+
expect(mock_call).to receive(:redirect_back)
|
|
667
678
|
subject.execute_command command
|
|
668
|
-
command.response(0.1).
|
|
679
|
+
expect(command.response(0.1)).to eq(true)
|
|
669
680
|
end
|
|
670
681
|
|
|
671
682
|
it "sends the correct complete event" do
|
|
672
|
-
mock_call.
|
|
683
|
+
expect(mock_call).to receive(:redirect_back)
|
|
673
684
|
subject.execute_command command
|
|
674
|
-
original_command.
|
|
685
|
+
expect(original_command).not_to be_complete
|
|
675
686
|
mock_call.process_ami_event ami_event
|
|
676
|
-
reason.
|
|
677
|
-
original_command.
|
|
687
|
+
expect(reason).to be_a Punchblock::Event::Complete::Stop
|
|
688
|
+
expect(original_command).to be_complete
|
|
678
689
|
end
|
|
679
690
|
|
|
680
691
|
it "redirects the call by unjoining it" do
|
|
681
|
-
mock_call.
|
|
692
|
+
expect(mock_call).to receive(:redirect_back)
|
|
682
693
|
subject.execute_command command
|
|
683
694
|
end
|
|
684
695
|
end
|