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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +2 -0
  3. data/CHANGELOG.md +6 -0
  4. data/README.markdown +2 -1
  5. data/lib/punchblock/translator/asterisk/call.rb +3 -3
  6. data/lib/punchblock/translator/asterisk/component/mrcp_recog_prompt.rb +15 -9
  7. data/lib/punchblock/translator/asterisk/component/output.rb +8 -1
  8. data/lib/punchblock/translator/input_component.rb +2 -0
  9. data/lib/punchblock/version.rb +1 -1
  10. data/punchblock.gemspec +1 -1
  11. data/spec/punchblock/client/component_registry_spec.rb +3 -3
  12. data/spec/punchblock/client_spec.rb +22 -15
  13. data/spec/punchblock/command/accept_spec.rb +17 -7
  14. data/spec/punchblock/command/answer_spec.rb +19 -9
  15. data/spec/punchblock/command/dial_spec.rb +76 -27
  16. data/spec/punchblock/command/hangup_spec.rb +17 -7
  17. data/spec/punchblock/command/join_spec.rb +78 -24
  18. data/spec/punchblock/command/mute_spec.rb +3 -3
  19. data/spec/punchblock/command/redirect_spec.rb +33 -12
  20. data/spec/punchblock/command/reject_spec.rb +41 -14
  21. data/spec/punchblock/command/unjoin_spec.rb +29 -12
  22. data/spec/punchblock/command/unmute_spec.rb +3 -3
  23. data/spec/punchblock/command_node_spec.rb +43 -20
  24. data/spec/punchblock/component/asterisk/agi/command_spec.rb +52 -12
  25. data/spec/punchblock/component/asterisk/ami/action_spec.rb +69 -21
  26. data/spec/punchblock/component/component_node_spec.rb +12 -12
  27. data/spec/punchblock/component/input_spec.rb +304 -87
  28. data/spec/punchblock/component/output_spec.rb +434 -173
  29. data/spec/punchblock/component/prompt_spec.rb +63 -20
  30. data/spec/punchblock/component/receive_fax_spec.rb +43 -14
  31. data/spec/punchblock/component/record_spec.rb +215 -71
  32. data/spec/punchblock/component/send_fax_spec.rb +54 -15
  33. data/spec/punchblock/connection/asterisk_spec.rb +34 -24
  34. data/spec/punchblock/connection/freeswitch_spec.rb +9 -9
  35. data/spec/punchblock/connection/xmpp_spec.rb +92 -83
  36. data/spec/punchblock/event/answered_spec.rb +14 -4
  37. data/spec/punchblock/event/asterisk/ami/event_spec.rb +34 -12
  38. data/spec/punchblock/event/complete_spec.rb +36 -16
  39. data/spec/punchblock/event/dtmf_spec.rb +9 -3
  40. data/spec/punchblock/event/end_spec.rb +43 -10
  41. data/spec/punchblock/event/input_timers_started_spec.rb +1 -1
  42. data/spec/punchblock/event/joined_spec.rb +29 -7
  43. data/spec/punchblock/event/offer_spec.rb +41 -10
  44. data/spec/punchblock/event/ringing_spec.rb +14 -4
  45. data/spec/punchblock/event/started_speaking_spec.rb +9 -3
  46. data/spec/punchblock/event/stopped_speaking_spec.rb +9 -3
  47. data/spec/punchblock/event/unjoined_spec.rb +24 -6
  48. data/spec/punchblock/protocol_error_spec.rb +16 -13
  49. data/spec/punchblock/ref_spec.rb +90 -26
  50. data/spec/punchblock/translator/asterisk/call_spec.rb +176 -161
  51. data/spec/punchblock/translator/asterisk/component/asterisk/agi_command_spec.rb +18 -18
  52. data/spec/punchblock/translator/asterisk/component/asterisk/ami_action_spec.rb +9 -9
  53. data/spec/punchblock/translator/asterisk/component/composed_prompt_spec.rb +14 -14
  54. data/spec/punchblock/translator/asterisk/component/input_spec.rb +57 -36
  55. data/spec/punchblock/translator/asterisk/component/mrcp_native_prompt_spec.rb +50 -50
  56. data/spec/punchblock/translator/asterisk/component/mrcp_prompt_spec.rb +59 -48
  57. data/spec/punchblock/translator/asterisk/component/output_spec.rb +231 -221
  58. data/spec/punchblock/translator/asterisk/component/record_spec.rb +82 -82
  59. data/spec/punchblock/translator/asterisk/component/stop_by_redirect_spec.rb +10 -10
  60. data/spec/punchblock/translator/asterisk/component_spec.rb +4 -4
  61. data/spec/punchblock/translator/asterisk_spec.rb +89 -82
  62. data/spec/punchblock/translator/freeswitch/call_spec.rb +114 -99
  63. data/spec/punchblock/translator/freeswitch/component/flite_output_spec.rb +19 -19
  64. data/spec/punchblock/translator/freeswitch/component/input_spec.rb +24 -24
  65. data/spec/punchblock/translator/freeswitch/component/output_spec.rb +23 -23
  66. data/spec/punchblock/translator/freeswitch/component/record_spec.rb +78 -78
  67. data/spec/punchblock/translator/freeswitch/component/tts_output_spec.rb +19 -19
  68. data/spec/punchblock/translator/freeswitch/component_spec.rb +8 -8
  69. data/spec/punchblock/translator/freeswitch_spec.rb +66 -59
  70. data/spec/punchblock/uri_list_spec.rb +45 -10
  71. data/spec/punchblock_spec.rb +13 -13
  72. data/spec/spec_helper.rb +18 -11
  73. data/spec/support/mock_connection_with_event_handler.rb +1 -1
  74. metadata +5 -4
@@ -165,17 +165,32 @@ module Punchblock
165
165
 
166
166
  subject { Call.new id, translator, es_env, stream }
167
167
 
168
- its(:id) { should be == id }
169
- its(:translator) { should be translator }
170
- its(:es_env) { should be == es_env }
171
- its(:stream) { should be stream }
168
+ describe '#id' do
169
+ subject { super().id }
170
+ it { should be == id }
171
+ end
172
+
173
+ describe '#translator' do
174
+ subject { super().translator }
175
+ it { should be translator }
176
+ end
177
+
178
+ describe '#es_env' do
179
+ subject { super().es_env }
180
+ it { should be == es_env }
181
+ end
182
+
183
+ describe '#stream' do
184
+ subject { super().stream }
185
+ it { should be stream }
186
+ end
172
187
 
173
188
  describe '#register_component' do
174
189
  it 'should make the component accessible by ID' do
175
190
  component_id = 'abc123'
176
191
  component = double 'Translator::Freeswitch::Component', :id => component_id
177
192
  subject.register_component component
178
- subject.component_with_id(component_id).should be component
193
+ expect(subject.component_with_id(component_id)).to be component
179
194
  end
180
195
  end
181
196
 
@@ -185,35 +200,35 @@ module Punchblock
185
200
  :to => "10@127.0.0.1",
186
201
  :from => "Extension 1000 <1000@127.0.0.1>",
187
202
  :headers => headers
188
- translator.should_receive(:handle_pb_event).with expected_offer
203
+ expect(translator).to receive(:handle_pb_event).with expected_offer
189
204
  subject.send_offer
190
205
  end
191
206
 
192
207
  it 'should make the call identify as inbound' do
193
208
  subject.send_offer
194
- subject.direction.should be == :inbound
195
- subject.inbound?.should be true
196
- subject.outbound?.should be false
209
+ expect(subject.direction).to eq(:inbound)
210
+ expect(subject.inbound?).to be true
211
+ expect(subject.outbound?).to be false
197
212
  end
198
213
  end
199
214
 
200
215
  describe "#application" do
201
216
  it "should execute a FS application on the current call" do
202
- stream.should_receive(:application).once.with(id, 'appname', 'options')
217
+ expect(stream).to receive(:application).once.with(id, 'appname', 'options')
203
218
  subject.application 'appname', 'options'
204
219
  end
205
220
  end
206
221
 
207
222
  describe "#sendmsg" do
208
223
  it "should execute a FS sendmsg on the current call" do
209
- stream.should_receive(:sendmsg).once.with(id, 'msg', :foo => 'bar')
224
+ expect(stream).to receive(:sendmsg).once.with(id, 'msg', :foo => 'bar')
210
225
  subject.sendmsg 'msg', :foo => 'bar'
211
226
  end
212
227
  end
213
228
 
214
229
  describe "#uuid_foo" do
215
230
  it "should execute a FS uuid_* on the current call using bgapi" do
216
- stream.should_receive(:bgapi).once.with("uuid_record #{id} blah.mp3")
231
+ expect(stream).to receive(:bgapi).once.with("uuid_record #{id} blah.mp3")
217
232
  subject.uuid_foo 'record', 'blah.mp3'
218
233
  end
219
234
  end
@@ -231,7 +246,7 @@ module Punchblock
231
246
  before { dial_command.request! }
232
247
 
233
248
  it 'sends an originate bgapi command' do
234
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}'}#{to} &park()"
249
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}'}#{to} &park()"
235
250
  subject.dial dial_command
236
251
  end
237
252
 
@@ -241,7 +256,7 @@ module Punchblock
241
256
  let(:from) { "#{from_name} <#{from_number}>" }
242
257
 
243
258
  it 'sends an originate bgapi command with the cid fields set correctly' do
244
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from_number}',origination_caller_id_name='#{from_name}'}#{to} &park()"
259
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from_number}',origination_caller_id_name='#{from_name}'}#{to} &park()"
245
260
  subject.dial dial_command
246
261
  end
247
262
  end
@@ -252,7 +267,7 @@ module Punchblock
252
267
  let(:from) { "#{from_name} <#{from_number}>" }
253
268
 
254
269
  it 'sends an originate bgapi command with the cid fields set correctly' do
255
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_name='#{from_name}'}#{to} &park()"
270
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_name='#{from_name}'}#{to} &park()"
256
271
  subject.dial dial_command
257
272
  end
258
273
  end
@@ -262,7 +277,7 @@ module Punchblock
262
277
  let(:from) { "<#{from_number}>" }
263
278
 
264
279
  it 'sends an originate bgapi command with the cid fields set correctly' do
265
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from_number}'}#{to} &park()"
280
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from_number}'}#{to} &park()"
266
281
  subject.dial dial_command
267
282
  end
268
283
  end
@@ -271,7 +286,7 @@ module Punchblock
271
286
  let(:from) { '' }
272
287
 
273
288
  it 'sends an originate bgapi command with the cid fields set correctly' do
274
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id}}#{to} &park()"
289
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id}}#{to} &park()"
275
290
  subject.dial dial_command
276
291
  end
277
292
  end
@@ -280,7 +295,7 @@ module Punchblock
280
295
  let(:from) { nil }
281
296
 
282
297
  it 'sends an originate bgapi command with the cid fields set correctly' do
283
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id}}#{to} &park()"
298
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id}}#{to} &park()"
284
299
  subject.dial dial_command
285
300
  end
286
301
  end
@@ -291,7 +306,7 @@ module Punchblock
291
306
  end
292
307
 
293
308
  it 'includes the timeout in the originate command' do
294
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}',originate_timeout=10}#{to} &park()"
309
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}',originate_timeout=10}#{to} &park()"
295
310
  subject.dial dial_command
296
311
  end
297
312
  end
@@ -302,7 +317,7 @@ module Punchblock
302
317
  end
303
318
 
304
319
  it 'includes the headers in the originate command' do
305
- stream.should_receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}',sip_h_X-foo='bar',sip_h_X-doo='dah'}#{to} &park()"
320
+ expect(stream).to receive(:bgapi).once.with "originate {return_ring_ready=true,origination_uuid=#{subject.id},origination_caller_id_number='#{from}',sip_h_X-foo='bar',sip_h_X-doo='dah'}#{to} &park()"
306
321
  subject.dial dial_command
307
322
  end
308
323
  end
@@ -310,14 +325,14 @@ module Punchblock
310
325
  it 'sends the call ID as a response to the Dial' do
311
326
  subject.dial dial_command
312
327
  dial_command.response
313
- dial_command.target_call_id.should be == subject.id
328
+ expect(dial_command.target_call_id).to eq(subject.id)
314
329
  end
315
330
 
316
331
  it 'should make the call identify as outbound' do
317
332
  subject.dial dial_command
318
- subject.direction.should be == :outbound
319
- subject.outbound?.should be true
320
- subject.inbound?.should be false
333
+ expect(subject.direction).to eq(:outbound)
334
+ expect(subject.outbound?).to be true
335
+ expect(subject.inbound?).to be false
321
336
  end
322
337
  end
323
338
 
@@ -339,15 +354,15 @@ module Punchblock
339
354
  let(:cause) { 'ORIGINATOR_CANCEL' }
340
355
 
341
356
  it "should cause the actor to be terminated" do
342
- translator.should_receive(:handle_pb_event).once
357
+ expect(translator).to receive(:handle_pb_event).once
343
358
  subject.handle_es_event es_event
344
359
  sleep 0.25
345
- subject.should_not be_alive
360
+ expect(subject.alive?).to be false
346
361
  end
347
362
 
348
363
  it "de-registers the call from the translator" do
349
- translator.stub :handle_pb_event
350
- translator.should_receive(:deregister_call).once.with(id)
364
+ allow(translator).to receive :handle_pb_event
365
+ expect(translator).to receive(:deregister_call).once.with(id)
351
366
  subject.handle_es_event es_event
352
367
  end
353
368
 
@@ -356,14 +371,14 @@ module Punchblock
356
371
  comp_command = Punchblock::Component::Output.new :render_document => {:value => ssml_doc}
357
372
  comp_command.request!
358
373
  component = subject.execute_command comp_command
359
- comp_command.response(0.1).should be_a Ref
374
+ expect(comp_command.response(0.1)).to be_a Ref
360
375
 
361
376
  expected_complete_event = Punchblock::Event::Complete.new :target_call_id => subject.id, :component_id => component.id, source_uri: component.id
362
377
  expected_complete_event.reason = Punchblock::Event::Complete::Hangup.new
363
378
  expected_end_event = Punchblock::Event::End.new :reason => :hangup, :target_call_id => subject.id
364
379
 
365
- translator.should_receive(:handle_pb_event).with(expected_complete_event).once.ordered
366
- translator.should_receive(:handle_pb_event).with(expected_end_event).once.ordered
380
+ expect(translator).to receive(:handle_pb_event).with(expected_complete_event).once.ordered
381
+ expect(translator).to receive(:handle_pb_event).with(expected_end_event).once.ordered
367
382
  subject.handle_es_event es_event
368
383
  end
369
384
 
@@ -382,7 +397,7 @@ module Punchblock
382
397
  it 'should send an end (hangup) event to the translator' do
383
398
  expected_end_event = Punchblock::Event::End.new :reason => :hangup,
384
399
  :target_call_id => subject.id
385
- translator.should_receive(:handle_pb_event).with expected_end_event
400
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
386
401
  subject.handle_es_event es_event
387
402
  end
388
403
  end
@@ -394,7 +409,7 @@ module Punchblock
394
409
  it 'should send an end (hangup-command) event to the translator' do
395
410
  expected_end_event = Punchblock::Event::End.new :reason => :hangup_command,
396
411
  :target_call_id => subject.id
397
- translator.should_receive(:handle_pb_event).with expected_end_event
412
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
398
413
  subject.handle_es_event es_event
399
414
  end
400
415
  end
@@ -405,7 +420,7 @@ module Punchblock
405
420
  it 'should send an end (busy) event to the translator' do
406
421
  expected_end_event = Punchblock::Event::End.new :reason => :busy,
407
422
  :target_call_id => subject.id
408
- translator.should_receive(:handle_pb_event).with expected_end_event
423
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
409
424
  subject.handle_es_event es_event
410
425
  end
411
426
  end
@@ -424,7 +439,7 @@ module Punchblock
424
439
  it 'should send an end (timeout) event to the translator' do
425
440
  expected_end_event = Punchblock::Event::End.new :reason => :timeout,
426
441
  :target_call_id => subject.id
427
- translator.should_receive(:handle_pb_event).with expected_end_event
442
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
428
443
  subject.handle_es_event es_event
429
444
  end
430
445
  end
@@ -455,7 +470,7 @@ module Punchblock
455
470
  it 'should send an end (reject) event to the translator' do
456
471
  expected_end_event = Punchblock::Event::End.new :reason => :reject,
457
472
  :target_call_id => subject.id
458
- translator.should_receive(:handle_pb_event).with expected_end_event
473
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
459
474
  subject.handle_es_event es_event
460
475
  end
461
476
  end
@@ -499,7 +514,7 @@ module Punchblock
499
514
  it 'should send an end (error) event to the translator' do
500
515
  expected_end_event = Punchblock::Event::End.new :reason => :error,
501
516
  :target_call_id => subject.id
502
- translator.should_receive(:handle_pb_event).with expected_end_event
517
+ expect(translator).to receive(:handle_pb_event).with expected_end_event
503
518
  subject.handle_es_event es_event
504
519
  end
505
520
  end
@@ -521,7 +536,7 @@ module Punchblock
521
536
  end
522
537
 
523
538
  it 'should send the event to the component' do
524
- component.should_receive(:handle_es_event).once.with es_event
539
+ expect(component).to receive(:handle_es_event).once.with es_event
525
540
  subject.handle_es_event es_event
526
541
  end
527
542
  end
@@ -540,13 +555,13 @@ module Punchblock
540
555
  it 'should send a ringing event' do
541
556
  expected_ringing = Punchblock::Event::Ringing.new
542
557
  expected_ringing.target_call_id = subject.id
543
- translator.should_receive(:handle_pb_event).with expected_ringing
558
+ expect(translator).to receive(:handle_pb_event).with expected_ringing
544
559
  subject.handle_es_event es_event
545
560
  end
546
561
 
547
562
  it '#answered? should return false' do
548
563
  subject.handle_es_event es_event
549
- subject.should_not be_answered
564
+ expect(subject).not_to be_answered
550
565
  end
551
566
  end
552
567
 
@@ -554,13 +569,13 @@ module Punchblock
554
569
  let(:channel_call_state) { 'FOO' }
555
570
 
556
571
  it 'should not send a ringing event' do
557
- translator.should_receive(:handle_pb_event).never
572
+ expect(translator).to receive(:handle_pb_event).never
558
573
  subject.handle_es_event es_event
559
574
  end
560
575
 
561
576
  it '#answered? should return false' do
562
577
  subject.handle_es_event es_event
563
- subject.should_not be_answered
578
+ expect(subject).not_to be_answered
564
579
  end
565
580
  end
566
581
  end
@@ -573,13 +588,13 @@ module Punchblock
573
588
  it 'should send an answered event' do
574
589
  expected_answered = Punchblock::Event::Answered.new
575
590
  expected_answered.target_call_id = subject.id
576
- translator.should_receive(:handle_pb_event).with expected_answered
591
+ expect(translator).to receive(:handle_pb_event).with expected_answered
577
592
  subject.handle_es_event es_event
578
593
  end
579
594
 
580
595
  it '#answered? should be true' do
581
596
  subject.handle_es_event es_event
582
- subject.should be_answered
597
+ expect(subject).to be_answered
583
598
  end
584
599
  end
585
600
 
@@ -591,7 +606,7 @@ module Punchblock
591
606
  let(:response) { double 'Response' }
592
607
 
593
608
  it 'should execute the handler' do
594
- response.should_receive(:call).once.with es_event
609
+ expect(response).to receive(:call).once.with es_event
595
610
  subject.register_handler :es, :event_name => 'DTMF' do |event|
596
611
  response.call event
597
612
  end
@@ -617,7 +632,7 @@ module Punchblock
617
632
  end
618
633
 
619
634
  it "should send a joined event with the correct call ID" do
620
- translator.should_receive(:handle_pb_event).with expected_joined
635
+ expect(translator).to receive(:handle_pb_event).with expected_joined
621
636
  subject.handle_es_event bridge_event
622
637
  end
623
638
  end
@@ -632,7 +647,7 @@ module Punchblock
632
647
  end
633
648
 
634
649
  it "should send a joined event with the correct call ID" do
635
- translator.should_receive(:handle_pb_event).with expected_joined
650
+ expect(translator).to receive(:handle_pb_event).with expected_joined
636
651
  subject.handle_es_event bridge_event
637
652
  end
638
653
  end
@@ -656,7 +671,7 @@ module Punchblock
656
671
  end
657
672
 
658
673
  it "should send a unjoined event with the correct call ID" do
659
- translator.should_receive(:handle_pb_event).with expected_unjoined
674
+ expect(translator).to receive(:handle_pb_event).with expected_unjoined
660
675
  subject.handle_es_event unbridge_event
661
676
  end
662
677
  end
@@ -671,7 +686,7 @@ module Punchblock
671
686
  end
672
687
 
673
688
  it "should send a unjoined event with the correct call ID" do
674
- translator.should_receive(:handle_pb_event).with expected_unjoined
689
+ expect(translator).to receive(:handle_pb_event).with expected_unjoined
675
690
  subject.handle_es_event unbridge_event
676
691
  end
677
692
  end
@@ -687,9 +702,9 @@ module Punchblock
687
702
  let(:command) { Command::Accept.new }
688
703
 
689
704
  it "should send a respond 180 command and set the command's response" do
690
- subject.wrapped_object.should_receive(:application).once.with('respond', '180 Ringing')
705
+ expect(subject.wrapped_object).to receive(:application).once.with('respond', '180 Ringing')
691
706
  subject.execute_command command
692
- command.response(0.5).should be true
707
+ expect(command.response(0.5)).to be true
693
708
  end
694
709
  end
695
710
 
@@ -698,43 +713,43 @@ module Punchblock
698
713
 
699
714
  it "should execute the answer application and set the command's response" do
700
715
  subject
701
- Punchblock.should_receive(:new_uuid).once.and_return 'abc123'
702
- subject.wrapped_object.should_receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
703
- subject.should_not be_answered
716
+ expect(Punchblock).to receive(:new_uuid).once.and_return 'abc123'
717
+ expect(subject.wrapped_object).to receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
718
+ expect(subject).not_to be_answered
704
719
  subject.execute_command command
705
720
  subject.handle_es_event RubyFS::Event.new(nil, :event_name => 'CHANNEL_ANSWER', :scope_variable_punchblock_command_id => 'abc123')
706
- command.response(0.5).should be true
707
- subject.should be_answered
721
+ expect(command.response(0.5)).to be true
722
+ expect(subject).to be_answered
708
723
  end
709
724
 
710
725
  it "should not execute the answer application twice if already answered" do
711
726
  subject
712
- Punchblock.should_receive(:new_uuid).once.and_return 'abc123'
713
- subject.wrapped_object.should_receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
714
- subject.should_not be_answered
727
+ expect(Punchblock).to receive(:new_uuid).once.and_return 'abc123'
728
+ expect(subject.wrapped_object).to receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
729
+ expect(subject).not_to be_answered
715
730
  subject.execute_command command
716
731
  subject.handle_es_event RubyFS::Event.new(nil, :event_name => 'CHANNEL_ANSWER', :scope_variable_punchblock_command_id => 'abc123')
717
- command.response(0.5).should be true
718
- subject.should be_answered
732
+ expect(command.response(0.5)).to be true
733
+ expect(subject).to be_answered
719
734
  subject.execute_command command
720
735
  end
721
736
 
722
737
  context "when a component has previously been executed" do
723
738
  it "should set the answer command's response correctly" do
724
739
  subject
725
- Punchblock.should_receive(:new_uuid).once.and_return 'abc123'
726
- subject.wrapped_object.should_receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
727
- subject.should_not be_answered
740
+ expect(Punchblock).to receive(:new_uuid).once.and_return 'abc123'
741
+ expect(subject.wrapped_object).to receive(:application).once.with('answer', "%[punchblock_command_id=abc123]")
742
+ expect(subject).not_to be_answered
728
743
  subject.execute_command command
729
744
  subject.handle_es_event RubyFS::Event.new(nil, :event_name => 'CHANNEL_ANSWER', :scope_variable_punchblock_command_id => 'abc123', :scope_variable_punchblock_component_id => 'dj182989j')
730
- command.response(0.5).should be true
731
- subject.should be_answered
745
+ expect(command.response(0.5)).to be true
746
+ expect(subject).to be_answered
732
747
  end
733
748
  end
734
749
  end
735
750
 
736
751
  def expect_hangup_with_reason(reason)
737
- subject.wrapped_object.should_receive(:sendmsg).once.with(:call_command => 'hangup', :hangup_cause => reason)
752
+ expect(subject.wrapped_object).to receive(:sendmsg).once.with(:call_command => 'hangup', :hangup_cause => reason)
738
753
  end
739
754
 
740
755
  context 'with a hangup command' do
@@ -743,7 +758,7 @@ module Punchblock
743
758
  it "should send a hangup message and set the command's response" do
744
759
  expect_hangup_with_reason 'MANAGER_REQUEST'
745
760
  subject.execute_command command
746
- command.response(0.5).should be true
761
+ expect(command.response(0.5)).to be true
747
762
  end
748
763
  end
749
764
 
@@ -754,21 +769,21 @@ module Punchblock
754
769
  command.reason = :busy
755
770
  expect_hangup_with_reason 'USER_BUSY'
756
771
  subject.execute_command command
757
- command.response(0.5).should be true
772
+ expect(command.response(0.5)).to be true
758
773
  end
759
774
 
760
775
  it "with a :decline reason should send a CALL_REJECTED hangup command and set the command's response" do
761
776
  command.reason = :decline
762
777
  expect_hangup_with_reason 'CALL_REJECTED'
763
778
  subject.execute_command command
764
- command.response(0.5).should be true
779
+ expect(command.response(0.5)).to be true
765
780
  end
766
781
 
767
782
  it "with an :error reason should send a NORMAL_TEMPORARY_FAILURE hangup command and set the command's response" do
768
783
  command.reason = :error
769
784
  expect_hangup_with_reason 'NORMAL_TEMPORARY_FAILURE'
770
785
  subject.execute_command command
771
- command.response(0.5).should be true
786
+ expect(command.response(0.5)).to be true
772
787
  end
773
788
  end
774
789
 
@@ -784,10 +799,10 @@ module Punchblock
784
799
 
785
800
  context "with a renderer of #{renderer}" do
786
801
  it 'should create an Output component and execute it asynchronously' do
787
- Component::Output.should_receive(:new_link).once.with(command, subject).and_return mock_component
788
- mock_component.should_receive(:execute).once
802
+ expect(Component::Output).to receive(:new_link).once.with(command, subject).and_return mock_component
803
+ expect(mock_component).to receive(:execute).once
789
804
  subject.execute_command command
790
- subject.component_with_id(mock_component.id).should be mock_component
805
+ expect(subject.component_with_id(mock_component.id)).to be mock_component
791
806
  end
792
807
  end
793
808
  end
@@ -796,10 +811,10 @@ module Punchblock
796
811
  let(:renderer) { :flite }
797
812
 
798
813
  it 'should create a FliteOutput component and execute it asynchronously using flite and the calls default voice' do
799
- Component::FliteOutput.should_receive(:new_link).once.with(command, subject).and_return mock_component
800
- mock_component.should_receive(:execute).once
814
+ expect(Component::FliteOutput).to receive(:new_link).once.with(command, subject).and_return mock_component
815
+ expect(mock_component).to receive(:execute).once
801
816
  subject.execute_command command
802
- subject.component_with_id(mock_component.id).should be mock_component
817
+ expect(subject.component_with_id(mock_component.id)).to be mock_component
803
818
  end
804
819
  end
805
820
 
@@ -807,10 +822,10 @@ module Punchblock
807
822
  let(:renderer) { :cepstral }
808
823
 
809
824
  it 'should create a TTSOutput component and execute it asynchronously using cepstral and the calls default voice' do
810
- Component::TTSOutput.should_receive(:new_link).once.with(command, subject).and_return mock_component
811
- mock_component.should_receive(:execute).once
825
+ expect(Component::TTSOutput).to receive(:new_link).once.with(command, subject).and_return mock_component
826
+ expect(mock_component).to receive(:execute).once
812
827
  subject.execute_command command
813
- subject.component_with_id(mock_component.id).should be mock_component
828
+ expect(subject.component_with_id(mock_component.id)).to be mock_component
814
829
  end
815
830
  end
816
831
 
@@ -818,10 +833,10 @@ module Punchblock
818
833
  let(:renderer) { :unimrcp }
819
834
 
820
835
  it 'should create a TTSOutput component and execute it asynchronously using unimrcp and the calls default voice' do
821
- Component::TTSOutput.should_receive(:new_link).once.with(command, subject).and_return mock_component
822
- mock_component.should_receive(:execute).once
836
+ expect(Component::TTSOutput).to receive(:new_link).once.with(command, subject).and_return mock_component
837
+ expect(mock_component).to receive(:execute).once
823
838
  subject.execute_command command
824
- subject.component_with_id(mock_component.id).should be mock_component
839
+ expect(subject.component_with_id(mock_component.id)).to be mock_component
825
840
  end
826
841
  end
827
842
  end
@@ -834,8 +849,8 @@ module Punchblock
834
849
  let(:mock_component) { Translator::Freeswitch::Component::Input.new(command, subject) }
835
850
 
836
851
  it 'should create an Input component and execute it asynchronously' do
837
- Component::Input.should_receive(:new_link).once.with(command, subject).and_return mock_component
838
- mock_component.should_receive(:execute).once
852
+ expect(Component::Input).to receive(:new_link).once.with(command, subject).and_return mock_component
853
+ expect(mock_component).to receive(:execute).once
839
854
  subject.execute_command command
840
855
  end
841
856
  end
@@ -848,8 +863,8 @@ module Punchblock
848
863
  let(:mock_component) { Translator::Freeswitch::Component::Record.new(command, subject) }
849
864
 
850
865
  it 'should create a Record component and execute it asynchronously' do
851
- Component::Record.should_receive(:new_link).once.with(command, subject).and_return mock_component
852
- mock_component.should_receive(:execute).once
866
+ expect(Component::Record).to receive(:new_link).once.with(command, subject).and_return mock_component
867
+ expect(mock_component).to receive(:execute).once
853
868
  subject.execute_command command
854
869
  end
855
870
  end
@@ -869,7 +884,7 @@ module Punchblock
869
884
  before { subject.register_component mock_component }
870
885
 
871
886
  it 'should send the command to the component for execution' do
872
- mock_component.should_receive(:execute_command).once
887
+ expect(mock_component).to receive(:execute_command).once
873
888
  subject.execute_command command
874
889
  end
875
890
  end
@@ -902,23 +917,23 @@ module Punchblock
902
917
  raise 'Woops, I died'
903
918
  end
904
919
 
905
- translator.should_receive(:handle_pb_event).once.with expected_event
920
+ expect(translator).to receive(:handle_pb_event).once.with expected_event
906
921
 
907
- lambda { component.oops }.should raise_error(/Woops, I died/)
922
+ expect { component.oops }.to raise_error(/Woops, I died/)
908
923
  sleep 0.1
909
- component.should_not be_alive
910
- subject.component_with_id(comp_id).should be_nil
924
+ expect(component.alive?).to be false
925
+ expect(subject.component_with_id(comp_id)).to be_nil
911
926
 
912
927
  subsequent_command.request!
913
928
  subject.execute_command subsequent_command
914
- subsequent_command.response.should be == ProtocolError.new.setup(:item_not_found, "Could not find a component with ID #{comp_id} for call #{subject.id}", subject.id, comp_id)
929
+ expect(subsequent_command.response).to eq(ProtocolError.new.setup(:item_not_found, "Could not find a component with ID #{comp_id} for call #{subject.id}", subject.id, comp_id))
915
930
  end
916
931
  end
917
932
 
918
933
  context "for an unknown component ID" do
919
934
  it 'sends an error in response to the command' do
920
935
  subject.execute_command command
921
- command.response.should be == ProtocolError.new.setup(:item_not_found, "Could not find a component with ID #{component_id} for call #{subject.id}", subject.id, component_id)
936
+ expect(command.response).to eq(ProtocolError.new.setup(:item_not_found, "Could not find a component with ID #{component_id} for call #{subject.id}", subject.id, component_id))
922
937
  end
923
938
  end
924
939
  end
@@ -930,7 +945,7 @@ module Punchblock
930
945
 
931
946
  it 'sends an error in response to the command' do
932
947
  subject.execute_command command
933
- command.response.should be == ProtocolError.new.setup('command-not-acceptable', "Did not understand command for call #{subject.id}", subject.id)
948
+ expect(command.response).to eq(ProtocolError.new.setup('command-not-acceptable', "Did not understand command for call #{subject.id}", subject.id))
934
949
  end
935
950
  end
936
951
 
@@ -942,7 +957,7 @@ module Punchblock
942
957
  end
943
958
 
944
959
  it "executes the proper uuid_bridge command" do
945
- subject.wrapped_object.should_receive(:uuid_foo).once.with :bridge, other_call_id
960
+ expect(subject.wrapped_object).to receive(:uuid_foo).once.with :bridge, other_call_id
946
961
  subject.execute_command command
947
962
  expect { command.response 1 }.to raise_exception(Timeout::Error)
948
963
  end
@@ -961,7 +976,7 @@ module Punchblock
961
976
 
962
977
  it "should set the command response to true" do
963
978
  subject.handle_es_event bridge_event
964
- command.response.should be_true
979
+ expect(command.response).to be_true
965
980
  end
966
981
  end
967
982
  end
@@ -974,7 +989,7 @@ module Punchblock
974
989
  end
975
990
 
976
991
  it "executes the unjoin via transfer to park" do
977
- subject.wrapped_object.should_receive(:uuid_foo).once.with :transfer, '-both park inline'
992
+ expect(subject.wrapped_object).to receive(:uuid_foo).once.with :transfer, '-both park inline'
978
993
  subject.execute_command command
979
994
  expect { command.response 1 }.to raise_exception(Timeout::Error)
980
995
  end
@@ -993,7 +1008,7 @@ module Punchblock
993
1008
 
994
1009
  it "should set the command response to true" do
995
1010
  subject.handle_es_event unbridge_event
996
- command.response.should be_true
1011
+ expect(command.response).to be_true
997
1012
  end
998
1013
  end
999
1014
  end