adhearsion 2.3.5 → 2.4.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.md +14 -0
  4. data/Gemfile +2 -0
  5. data/README.markdown +21 -2
  6. data/adhearsion.gemspec +5 -4
  7. data/features/cli_plugin.feature +41 -0
  8. data/features/cli_start.feature +12 -4
  9. data/features/step_definitions/cli_steps.rb +12 -0
  10. data/features/support/env.rb +1 -1
  11. data/features/support/utils.rb +0 -1
  12. data/lib/adhearsion.rb +4 -1
  13. data/lib/adhearsion/call.rb +92 -22
  14. data/lib/adhearsion/call_controller.rb +19 -15
  15. data/lib/adhearsion/call_controller/dial.rb +157 -25
  16. data/lib/adhearsion/call_controller/menu_dsl/menu_builder.rb +8 -0
  17. data/lib/adhearsion/call_controller/output/async_player.rb +1 -1
  18. data/lib/adhearsion/call_controller/output/formatter.rb +1 -1
  19. data/lib/adhearsion/call_controller/output/player.rb +1 -1
  20. data/lib/adhearsion/calls.rb +2 -0
  21. data/lib/adhearsion/cli_commands.rb +3 -163
  22. data/lib/adhearsion/cli_commands/ahn_command.rb +141 -0
  23. data/lib/adhearsion/cli_commands/plugin_command.rb +74 -0
  24. data/lib/adhearsion/cli_commands/thor_errors.rb +36 -0
  25. data/lib/adhearsion/console.rb +14 -6
  26. data/lib/adhearsion/generators/app/templates/spec/call_controllers/simon_game_spec.rb +36 -36
  27. data/lib/adhearsion/generators/controller/templates/spec/controller_spec.rb +1 -1
  28. data/lib/adhearsion/generators/plugin/templates/plugin-template.gemspec.tt +0 -1
  29. data/lib/adhearsion/generators/plugin/templates/spec/plugin-template/controller_methods_spec.rb.tt +1 -1
  30. data/lib/adhearsion/generators/plugin/templates/spec/spec_helper.rb.tt +0 -1
  31. data/lib/adhearsion/logging.rb +5 -1
  32. data/lib/adhearsion/outbound_call.rb +16 -0
  33. data/lib/adhearsion/punchblock_plugin.rb +0 -2
  34. data/lib/adhearsion/punchblock_plugin/initializer.rb +7 -12
  35. data/lib/adhearsion/version.rb +1 -1
  36. data/spec/adhearsion/call_controller/dial_spec.rb +785 -32
  37. data/spec/adhearsion/call_controller/menu_dsl/menu_builder_spec.rb +10 -0
  38. data/spec/adhearsion/call_controller/output/async_player_spec.rb +1 -1
  39. data/spec/adhearsion/call_controller/output/player_spec.rb +1 -1
  40. data/spec/adhearsion/call_controller/output_spec.rb +3 -3
  41. data/spec/adhearsion/call_controller/record_spec.rb +1 -1
  42. data/spec/adhearsion/call_controller_spec.rb +13 -9
  43. data/spec/adhearsion/call_spec.rb +216 -51
  44. data/spec/adhearsion/calls_spec.rb +1 -1
  45. data/spec/adhearsion/console_spec.rb +20 -9
  46. data/spec/adhearsion/outbound_call_spec.rb +40 -6
  47. data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +9 -21
  48. data/spec/adhearsion/punchblock_plugin_spec.rb +1 -1
  49. data/spec/adhearsion/router_spec.rb +1 -1
  50. data/spec/spec_helper.rb +11 -15
  51. data/spec/support/call_controller_test_helpers.rb +2 -2
  52. data/spec/support/punchblock_mocks.rb +2 -2
  53. metadata +41 -16
@@ -16,6 +16,16 @@ module Adhearsion
16
16
  foo :bar
17
17
  end
18
18
  end
19
+
20
+ let(:foo) { :bar }
21
+
22
+ it "makes the block context available" do
23
+ doo = nil
24
+ subject.build do
25
+ doo = foo
26
+ end
27
+ doo.should == :bar
28
+ end
19
29
  end#build
20
30
 
21
31
  describe "#match" do
@@ -57,7 +57,7 @@ module Adhearsion
57
57
  let(:ssml) { RubySpeech::SSML.draw { string "BOO" } }
58
58
 
59
59
  it 'executes an Output with the correct ssml' do
60
- component = Punchblock::Component::Output.new :ssml => ssml.to_s
60
+ component = Punchblock::Component::Output.new :ssml => ssml
61
61
  expect_message_waiting_for_response component
62
62
  subject.play_ssml ssml
63
63
  end
@@ -61,7 +61,7 @@ module Adhearsion
61
61
  let(:ssml) { RubySpeech::SSML.draw { string "BOO" } }
62
62
 
63
63
  it 'executes an Output with the correct ssml' do
64
- expect_component_execution Punchblock::Component::Output.new(:ssml => ssml.to_s)
64
+ expect_component_execution Punchblock::Component::Output.new(:ssml => ssml)
65
65
  subject.play_ssml ssml
66
66
  end
67
67
  end
@@ -700,7 +700,7 @@ module Adhearsion
700
700
  controller.stub(:write_and_await_response)
701
701
 
702
702
  expect_component_complete_event
703
- expect_component_execution Punchblock::Component::Output.new(:ssml => ssml.to_s)
703
+ expect_component_execution Punchblock::Component::Output.new(:ssml => ssml)
704
704
  subject.stream_file prompt, allowed_digits
705
705
  end
706
706
 
@@ -712,7 +712,7 @@ module Adhearsion
712
712
  controller.should_receive(:write_and_await_response).once.with(kind_of(Punchblock::Component::Output))
713
713
 
714
714
  Punchblock::Component::Output.any_instance.should_receive(:stop!)
715
- Punchblock::Component::Output.any_instance.should_receive(:complete_event).and_return mock('complete', reason: mock('Reason'))
715
+ Punchblock::Component::Output.any_instance.should_receive(:complete_event).and_return double('complete', reason: double('Reason'))
716
716
  expect_input_component_complete_event 'dtmf-5'
717
717
 
718
718
  subject.stream_file(prompt, allowed_digits).should be == '5'
@@ -724,7 +724,7 @@ module Adhearsion
724
724
  controller.stub(:write_and_await_response)
725
725
 
726
726
  expect_component_complete_event
727
- expect_component_execution Punchblock::Component::Output.new({:ssml => ssml.to_s}.merge(extra_options))
727
+ expect_component_execution Punchblock::Component::Output.new({:ssml => ssml}.merge(extra_options))
728
728
  subject.stream_file prompt, allowed_digits, extra_options
729
729
  end
730
730
  end
@@ -139,7 +139,7 @@ module Adhearsion
139
139
  let(:complete_event) { Punchblock::Event::Complete.new }
140
140
 
141
141
  it "should execute those handlers when recording completes" do
142
- foo = mock 'foo'
142
+ foo = double 'foo'
143
143
  foo.should_receive(:call).once.with kind_of(Punchblock::Event::Complete)
144
144
  subject.handle_record_completion { |e| foo.call e }
145
145
  subject.record_component.trigger_event_handler complete_event
@@ -215,7 +215,6 @@ module Adhearsion
215
215
  end
216
216
 
217
217
  [ :answer,
218
- :reject,
219
218
  :mute,
220
219
  :unmute].each do |method_name|
221
220
  describe "##{method_name}" do
@@ -227,11 +226,16 @@ module Adhearsion
227
226
  end
228
227
  end
229
228
 
230
- describe "#hangup" do
231
- it "delegates to the call, blocking first until it is allowed to execute" do
232
- subject.should_receive(:block_until_resumed).once.ordered
233
- subject.call.should_receive(:hangup).once.ordered
234
- lambda { subject.send :hangup }.should raise_error Call::Hangup
229
+ [
230
+ :hangup,
231
+ :reject
232
+ ].each do |method_name|
233
+ describe "##{method_name}" do
234
+ it "delegates to the call, blocking first until it is allowed to execute, and raises Call::Hangup" do
235
+ subject.should_receive(:block_until_resumed).once.ordered
236
+ subject.call.should_receive(method_name).once.ordered
237
+ lambda { subject.send method_name }.should raise_error Call::Hangup
238
+ end
235
239
  end
236
240
  end
237
241
 
@@ -245,9 +249,9 @@ module Adhearsion
245
249
  latch.countdown!
246
250
  end
247
251
  latch.wait(1).should be false
248
- subject.call << Punchblock::Event::Joined.new(:call_id => 'call1')
252
+ subject.call << Punchblock::Event::Joined.new(call_uri: 'call1')
249
253
  latch.wait(1).should be false
250
- subject.call << Punchblock::Event::Unjoined.new(:call_id => 'call1')
254
+ subject.call << Punchblock::Event::Unjoined.new(call_uri: 'call1')
251
255
  latch.wait(1).should be true
252
256
  end
253
257
 
@@ -278,7 +282,7 @@ module Adhearsion
278
282
  latch.countdown!
279
283
  end
280
284
  latch.wait(1).should be false
281
- subject.call << Punchblock::Event::Joined.new(:call_id => 'call1')
285
+ subject.call << Punchblock::Event::Joined.new(call_uri: 'call1')
282
286
  latch.wait(1).should be true
283
287
  end
284
288
 
@@ -10,17 +10,21 @@ end
10
10
 
11
11
  module Adhearsion
12
12
  describe Call do
13
- let(:mock_client) { mock('Client').as_null_object }
13
+ let(:mock_client) { double('Client').as_null_object }
14
14
 
15
- let(:call_id) { rand }
15
+ let(:call_id) { rand.to_s }
16
+ let(:domain) { 'rayo.net' }
16
17
  let(:headers) { nil }
17
18
  let(:to) { 'sip:you@there.com' }
18
19
  let(:from) { 'sip:me@here.com' }
20
+ let(:transport) { 'footransport' }
19
21
  let :offer do
20
- Punchblock::Event::Offer.new :target_call_id => call_id,
21
- :to => to,
22
- :from => from,
23
- :headers => headers
22
+ Punchblock::Event::Offer.new target_call_id: call_id,
23
+ domain: domain,
24
+ transport: transport,
25
+ to: to,
26
+ from: from,
27
+ headers: headers
24
28
  end
25
29
 
26
30
  subject { Adhearsion::Call.new offer }
@@ -41,14 +45,46 @@ module Adhearsion
41
45
  its(:commands) { should be_empty }
42
46
 
43
47
  its(:id) { should be == call_id }
48
+ its(:domain) { should be == domain }
49
+ its(:uri) { should be == "footransport:#{call_id}@#{domain}" }
44
50
  its(:to) { should be == to }
45
51
  its(:from) { should be == from }
46
52
 
53
+ context "when the ID is nil" do
54
+ let(:call_id) { nil }
55
+
56
+ its(:uri) { should be == nil }
57
+ end
58
+
59
+ context "when the domain is nil" do
60
+ let(:domain) { nil }
61
+
62
+ its(:uri) { should be == "footransport:#{call_id}" }
63
+ end
64
+
65
+ context "when the transport is nil" do
66
+ let(:transport) { nil }
67
+
68
+ its(:uri) { should be == "#{call_id}@#{domain}" }
69
+ end
70
+
71
+ it "should mark its start time" do
72
+ base_time = Time.local(2008, 9, 1, 12, 0, 0)
73
+ Timecop.freeze base_time
74
+ subject.start_time.should == base_time
75
+ end
76
+
77
+ describe "#commands" do
78
+ it "should use a duplicating accessor for the command registry" do
79
+ subject.commands.should_not be subject.commands
80
+ end
81
+ end
82
+
47
83
  describe "its variables" do
48
84
  context "with an offer" do
49
85
  context "with headers" do
50
- let(:headers) { {:x_foo => 'bar'} }
51
- its(:variables) { should be == headers }
86
+ let(:headers) { {'X-foo' => 'bar'} }
87
+ its(:variables) { should be == {'x_foo' => 'bar'} }
52
88
 
53
89
  it "should be made available via []" do
54
90
  subject[:x_foo].should be == 'bar'
@@ -60,20 +96,29 @@ module Adhearsion
60
96
  end
61
97
 
62
98
  context "when receiving an event with headers" do
63
- let(:event) { Punchblock::Event::End.new :headers => {:x_bar => 'foo'} }
99
+ let(:event) { Punchblock::Event::End.new :headers => {'X-bar' => 'foo'} }
64
100
 
65
101
  it "should merge later headers" do
66
102
  subject << event
67
- subject.variables.should be == {:x_foo => 'bar', :x_bar => 'foo'}
103
+ subject.variables.should be == {'x_foo' => 'bar', 'x_bar' => 'foo'}
104
+ end
105
+
106
+ context "with have symbol names" do
107
+ let(:event) { Punchblock::Event::End.new :headers => {:x_bar => 'foo'} }
108
+
109
+ it "should merge later headers" do
110
+ subject << event
111
+ subject.variables.should be == {'x_foo' => 'bar', 'x_bar' => 'foo'}
112
+ end
68
113
  end
69
114
  end
70
115
 
71
116
  context "when sending a command with headers" do
72
- let(:command) { Punchblock::Command::Accept.new :headers => {:x_bar => 'foo'} }
117
+ let(:command) { Punchblock::Command::Accept.new :headers => {'X-bar' => 'foo'} }
73
118
 
74
119
  it "should merge later headers" do
75
120
  subject.write_command command
76
- subject.variables.should be == {:x_foo => 'bar', :x_bar => 'foo'}
121
+ subject.variables.should be == {'x_foo' => 'bar', 'x_bar' => 'foo'}
77
122
  end
78
123
  end
79
124
  end
@@ -97,26 +142,41 @@ module Adhearsion
97
142
  end
98
143
 
99
144
  it 'allows the registration of event handlers which are called when messages are delivered' do
100
- event = mock 'Event'
145
+ event = double 'Event'
101
146
  event.should_receive(:foo?).and_return true
102
- response = mock 'Response'
147
+ response = double 'Response'
103
148
  response.should_receive(:call).once
104
149
  subject.register_event_handler(:foo?) { response.call }
105
150
  subject << event
106
151
  end
107
152
 
108
153
  describe "event handlers" do
109
- let(:response) { mock 'Response' }
154
+ before { pending }
155
+ let(:response) { double 'Response' }
110
156
 
111
157
  describe "for joined events" do
112
158
  context "joined to another call" do
113
159
  let :event do
114
- Punchblock::Event::Joined.new :call_id => 'foobar'
160
+ Punchblock::Event::Joined.new call_uri: 'xmpp:foobar@rayo.net'
115
161
  end
116
162
 
117
163
  it "should trigger any on_joined callbacks set for the matching call ID" do
118
164
  response.should_receive(:call).once.with(event)
119
- subject.on_joined(:call_id => 'foobar') { |event| response.call event }
165
+ subject.on_joined(:call_uri => 'xmpp:foobar@rayo.net') { |event| response.call event }
166
+ subject << event
167
+ end
168
+
169
+ it "should trigger any on_joined callbacks set for the matching call ID as a string" do
170
+ response.should_receive(:call).once.with(event)
171
+ subject.on_joined('foobar') { |event| response.call event }
172
+ subject << event
173
+ end
174
+
175
+ it "should trigger any on_joined callbacks set for the matching call" do
176
+ response.should_receive(:call).once.with(event)
177
+ call = Call.new
178
+ call.wrapped_object.stub id: 'foobar', domain: 'rayo.net'
179
+ subject.on_joined(call) { |event| response.call event }
120
180
  subject << event
121
181
  end
122
182
 
@@ -155,18 +215,32 @@ module Adhearsion
155
215
  subject.on_joined(:call_id => 'foobar') { |event| response.call event }
156
216
  subject << event
157
217
  end
218
+
219
+ it "should not trigger any on_joined callbacks set for the matching call ID as a string" do
220
+ response.should_receive(:call).never
221
+ subject.on_joined('foobar') { |event| response.call event }
222
+ subject << event
223
+ end
224
+
225
+ it "should not trigger any on_joined callbacks set for the matching call" do
226
+ response.should_receive(:call).never
227
+ call = Call.new
228
+ call.stub :id => 'foobar'
229
+ subject.on_joined(call) { |event| response.call event }
230
+ subject << event
231
+ end
158
232
  end
159
233
  end
160
234
 
161
235
  describe "for unjoined events" do
162
236
  context "unjoined from another call" do
163
237
  let :event do
164
- Punchblock::Event::Unjoined.new :call_id => 'foobar'
238
+ Punchblock::Event::Unjoined.new call_uri: 'xmpp:foobar@rayo.net'
165
239
  end
166
240
 
167
241
  it "should trigger any on_unjoined callbacks set for the matching call ID" do
168
242
  response.should_receive(:call).once.with(event)
169
- subject.on_unjoined(:call_id => 'foobar') { |event| response.call event }
243
+ subject.on_unjoined(:call_uri => 'xmpp:foobar@rayo.net') { |event| response.call event }
170
244
  subject << event
171
245
  end
172
246
 
@@ -179,7 +253,7 @@ module Adhearsion
179
253
  it "should trigger any on_unjoined callbacks set for the matching call" do
180
254
  response.should_receive(:call).once.with(event)
181
255
  call = Call.new
182
- call.stub :id => 'foobar'
256
+ call.wrapped_object.stub id: 'foobar', domain: 'rayo.net'
183
257
  subject.on_unjoined(call) { |event| response.call event }
184
258
  subject << event
185
259
  end
@@ -278,11 +352,11 @@ module Adhearsion
278
352
  before { other_call.stub :id => other_call_id }
279
353
 
280
354
  let :joined_event do
281
- Punchblock::Event::Joined.new :call_id => other_call_id
355
+ Punchblock::Event::Joined.new call_uri: other_call_id
282
356
  end
283
357
 
284
358
  let :unjoined_event do
285
- Punchblock::Event::Unjoined.new :call_id => other_call_id
359
+ Punchblock::Event::Unjoined.new call_uri: other_call_id
286
360
  end
287
361
 
288
362
  context "when we know about the joined call" do
@@ -332,9 +406,41 @@ module Adhearsion
332
406
  subject.end_reason.should be == :hangup
333
407
  end
334
408
 
409
+ it "should set the end time" do
410
+ finish_time = Time.local(2008, 9, 1, 12, 1, 3)
411
+ Timecop.freeze finish_time
412
+ subject.end_time.should == nil
413
+ subject << end_event
414
+ subject.end_time.should == finish_time
415
+ end
416
+
417
+ it "should set the call duration" do
418
+ start_time = Time.local(2008, 9, 1, 12, 0, 0)
419
+ Timecop.freeze start_time
420
+ subject
421
+
422
+ mid_point_time = Time.local(2008, 9, 1, 12, 0, 37)
423
+ Timecop.freeze mid_point_time
424
+
425
+ subject.duration.should == 37.0
426
+
427
+ finish_time = Time.local(2008, 9, 1, 12, 1, 3)
428
+ Timecop.freeze finish_time
429
+
430
+ subject << end_event
431
+
432
+ future_time = Time.local(2008, 9, 1, 12, 2, 3)
433
+ Timecop.freeze finish_time
434
+
435
+ subject.duration.should == 63.0
436
+ end
437
+
335
438
  it "should instruct the command registry to terminate" do
336
- subject.commands.should_receive(:terminate).once
439
+ command = Punchblock::Command::Answer.new
440
+ command.request!
441
+ subject.future.write_and_await_response command
337
442
  subject << end_event
443
+ command.response(1).should be_a Call::Hangup
338
444
  end
339
445
 
340
446
  it "removes itself from the active calls" do
@@ -357,6 +463,33 @@ module Adhearsion
357
463
  end
358
464
  end
359
465
 
466
+ describe "#wait_for_end" do
467
+ let :end_event do
468
+ Punchblock::Event::End.new reason: :hangup
469
+ end
470
+
471
+ context "when the call has already ended" do
472
+ before { subject << end_event }
473
+
474
+ it "should return the end reason" do
475
+ subject.wait_for_end.should == :hangup
476
+ end
477
+ end
478
+
479
+ context "when the call has not yet ended" do
480
+ it "should block until the call ends and return the end reason" do
481
+ fut = subject.future.wait_for_end
482
+
483
+ sleep 0.5
484
+ fut.should_not be_ready
485
+
486
+ subject << end_event
487
+
488
+ fut.value.should == :hangup
489
+ end
490
+ end
491
+ end
492
+
360
493
  describe "tagging a call" do
361
494
  it 'with a single Symbol' do
362
495
  lambda {
@@ -405,11 +538,11 @@ module Adhearsion
405
538
  end
406
539
 
407
540
  describe "#write_command" do
408
- let(:mock_command) { mock('Command') }
541
+ let(:mock_command) { double('Command') }
409
542
 
410
543
  it "should asynchronously write the command to the Punchblock connection" do
411
544
  subject.wrapped_object.should_receive(:client).once.and_return mock_client
412
- mock_client.should_receive(:execute_command).once.with(mock_command, :call_id => subject.id, :async => true).and_return true
545
+ mock_client.should_receive(:execute_command).once.with(mock_command, call_id: call_id, domain: domain, async: true).and_return true
413
546
  subject.write_command mock_command
414
547
  end
415
548
 
@@ -446,9 +579,9 @@ module Adhearsion
446
579
  subject.write_and_await_response message
447
580
  end
448
581
 
449
- it "adds the command to the registry" do
582
+ it "removes the command from the registry after execution" do
450
583
  subject.write_and_await_response message
451
- subject.commands.should_not be_empty
584
+ subject.commands.should be_empty
452
585
  end
453
586
 
454
587
  it "blocks until a response is received" do
@@ -463,6 +596,26 @@ module Adhearsion
463
596
  (Time.now - starting_time).should >= 0.5
464
597
  end
465
598
 
599
+ context "while waiting for a response" do
600
+ let(:slow_command) { Punchblock::Command::Dial.new }
601
+
602
+ before { slow_command.request! }
603
+
604
+ it "does not block the whole actor while waiting for a response" do
605
+ fut = subject.future.write_and_await_response slow_command
606
+ subject.id.should == call_id
607
+ slow_command.response = response
608
+ fut.value
609
+ end
610
+
611
+ it "adds the command to the registry" do
612
+ subject.future.write_and_await_response slow_command
613
+ sleep 0.2
614
+ subject.commands.should_not be_empty
615
+ subject.commands.first.should be slow_command
616
+ end
617
+ end
618
+
466
619
  describe "with a successful response" do
467
620
  it "returns the executed command" do
468
621
  subject.write_and_await_response(message).should be message
@@ -572,7 +725,7 @@ module Adhearsion
572
725
  describe "with no headers" do
573
726
  it 'should send a Reject message' do
574
727
  expect_message_waiting_for_response do |c|
575
- c.is_a?(Punchblock::Command::Reject) && c.headers_hash == {}
728
+ c.is_a?(Punchblock::Command::Reject) && c.headers == {}
576
729
  end
577
730
  subject.reject
578
731
  end
@@ -582,7 +735,7 @@ module Adhearsion
582
735
  it 'should send a Hangup message with the correct headers' do
583
736
  headers = {:foo => 'bar'}
584
737
  expect_message_waiting_for_response do |c|
585
- c.is_a?(Punchblock::Command::Reject) && c.headers_hash == headers
738
+ c.is_a?(Punchblock::Command::Reject) && c.headers == headers
586
739
  end
587
740
  subject.reject nil, headers
588
741
  end
@@ -640,18 +793,20 @@ module Adhearsion
640
793
 
641
794
  context "with a call" do
642
795
  let(:call_id) { rand.to_s }
796
+ let(:domain) { 'rayo.net' }
797
+ let(:uri) { "footransport:#{call_id}@#{domain}" }
643
798
  let(:target) { described_class.new }
644
799
 
645
- before { target.stub id: call_id }
800
+ before { target.wrapped_object.stub uri: uri }
646
801
 
647
802
  it "should send a join command joining to the provided call ID" do
648
- expect_join_with_options :call_id => call_id
803
+ expect_join_with_options call_uri: uri
649
804
  subject.join target
650
805
  end
651
806
 
652
807
  context "and direction/media options" do
653
808
  it "should send a join command with the correct options" do
654
- expect_join_with_options :call_id => call_id, :media => :bridge, :direction => :recv
809
+ expect_join_with_options :call_id => uri, :media => :bridge, :direction => :recv
655
810
  subject.join target, :media => :bridge, :direction => :recv
656
811
  end
657
812
  end
@@ -661,30 +816,30 @@ module Adhearsion
661
816
  let(:target) { rand.to_s }
662
817
 
663
818
  it "should send a join command joining to the provided call ID" do
664
- expect_join_with_options :call_id => target
819
+ expect_join_with_options call_uri: "footransport:#{target}@#{subject.domain}"
665
820
  subject.join target
666
821
  end
667
822
 
668
823
  context "and direction/media options" do
669
824
  it "should send a join command with the correct options" do
670
- expect_join_with_options :call_id => target, :media => :bridge, :direction => :recv
825
+ expect_join_with_options :call_uri => "footransport:#{target}@#{subject.domain}", :media => :bridge, :direction => :recv
671
826
  subject.join target, :media => :bridge, :direction => :recv
672
827
  end
673
828
  end
674
829
  end
675
830
 
676
- context "with a call ID as a hash key" do
831
+ context "with a call URI as a hash key" do
677
832
  let(:call_id) { rand.to_s }
678
- let(:target) { { :call_id => call_id } }
833
+ let(:target) { { :call_uri => call_id } }
679
834
 
680
835
  it "should send a join command joining to the provided call ID" do
681
- expect_join_with_options :call_id => call_id
836
+ expect_join_with_options :call_uri => call_id
682
837
  subject.join target
683
838
  end
684
839
 
685
840
  context "and direction/media options" do
686
841
  it "should send a join command with the correct options" do
687
- expect_join_with_options :call_id => call_id, :media => :bridge, :direction => :recv
842
+ expect_join_with_options :call_uri => call_id, :media => :bridge, :direction => :recv
688
843
  subject.join target.merge({:media => :bridge, :direction => :recv})
689
844
  end
690
845
  end
@@ -710,10 +865,10 @@ module Adhearsion
710
865
  context "with a call ID and a mixer name as hash keys" do
711
866
  let(:call_id) { rand.to_s }
712
867
  let(:mixer_name) { rand.to_s }
713
- let(:target) { { :call_id => call_id, :mixer_name => mixer_name } }
868
+ let(:target) { { :call_uri => call_id, :mixer_name => mixer_name } }
714
869
 
715
870
  it "should raise an ArgumentError" do
716
- lambda { subject.join target }.should raise_error ArgumentError, /call ID and mixer name/
871
+ lambda { subject.join target }.should raise_error ArgumentError, /call URI and mixer name/
717
872
  end
718
873
  end
719
874
  end
@@ -727,12 +882,14 @@ module Adhearsion
727
882
 
728
883
  context "with a call" do
729
884
  let(:call_id) { rand.to_s }
885
+ let(:domain) { 'rayo.net' }
886
+ let(:uri) { "footransport:#{call_id}@#{domain}" }
730
887
  let(:target) { described_class.new }
731
888
 
732
- before { target.stub id: call_id }
889
+ before { target.wrapped_object.stub uri: uri }
733
890
 
734
891
  it "should send an unjoin command unjoining from the provided call ID" do
735
- expect_unjoin_with_options :call_id => call_id
892
+ expect_unjoin_with_options call_uri: "footransport:#{call_id}@#{domain}"
736
893
  subject.unjoin target
737
894
  end
738
895
  end
@@ -741,17 +898,17 @@ module Adhearsion
741
898
  let(:target) { rand.to_s }
742
899
 
743
900
  it "should send an unjoin command unjoining from the provided call ID" do
744
- expect_unjoin_with_options :call_id => target
901
+ expect_unjoin_with_options call_uri: "footransport:#{target}@#{subject.domain}"
745
902
  subject.unjoin target
746
903
  end
747
904
  end
748
905
 
749
- context "with a call ID as a hash key" do
906
+ context "with a call URI as a hash key" do
750
907
  let(:call_id) { rand.to_s }
751
- let(:target) { { :call_id => call_id } }
908
+ let(:target) { { call_uri: call_id } }
752
909
 
753
910
  it "should send an unjoin command unjoining from the provided call ID" do
754
- expect_unjoin_with_options :call_id => call_id
911
+ expect_unjoin_with_options call_uri: call_id
755
912
  subject.unjoin target
756
913
  end
757
914
  end
@@ -766,13 +923,13 @@ module Adhearsion
766
923
  end
767
924
  end
768
925
 
769
- context "with a call ID and a mixer name as hash keys" do
926
+ context "with a call URI and a mixer name as hash keys" do
770
927
  let(:call_id) { rand.to_s }
771
928
  let(:mixer_name) { rand.to_s }
772
- let(:target) { { :call_id => call_id, :mixer_name => mixer_name } }
929
+ let(:target) { { call_uri: call_id, mixer_name: mixer_name } }
773
930
 
774
931
  it "should raise an ArgumentError" do
775
- lambda { subject.unjoin target }.should raise_error ArgumentError, /call ID and mixer name/
932
+ lambda { subject.unjoin target }.should raise_error ArgumentError, /call URI and mixer name/
776
933
  end
777
934
  end
778
935
  end
@@ -846,8 +1003,8 @@ module Adhearsion
846
1003
  end
847
1004
 
848
1005
  context "with two controllers registered" do
849
- let(:controller1) { mock 'CallController1' }
850
- let(:controller2) { mock 'CallController2' }
1006
+ let(:controller1) { double 'CallController1' }
1007
+ let(:controller2) { double 'CallController2' }
851
1008
 
852
1009
  before { subject.controllers << controller1 << controller2 }
853
1010
 
@@ -869,6 +1026,14 @@ module Adhearsion
869
1026
  end
870
1027
  end
871
1028
  end
1029
+
1030
+ describe "after termination" do
1031
+ it "should delete its logger" do
1032
+ logger = subject.logger
1033
+ subject.terminate
1034
+ ::Logging::Repository.instance[logger.name].should be_nil
1035
+ end
1036
+ end
872
1037
  end
873
1038
 
874
1039
  describe Call::CommandRegistry do