adhearsion 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +3 -0
- data/LICENSE +1 -1
- data/README.markdown +2 -2
- data/adhearsion.gemspec +0 -1
- data/lib/adhearsion/punchblock_plugin/initializer.rb +1 -1
- data/lib/adhearsion/version.rb +1 -1
- data/spec/adhearsion/call_controller/dial_spec.rb +56 -57
- data/spec/adhearsion/call_controller/input_spec.rb +11 -16
- data/spec/adhearsion/call_controller/menu_dsl/menu_builder_spec.rb +6 -6
- data/spec/adhearsion/call_controller/menu_dsl/menu_spec.rb +10 -10
- data/spec/adhearsion/call_controller/output/async_player_spec.rb +3 -3
- data/spec/adhearsion/call_controller/output/player_spec.rb +1 -1
- data/spec/adhearsion/call_controller/output_spec.rb +2 -7
- data/spec/adhearsion/call_controller/record_spec.rb +11 -18
- data/spec/adhearsion/call_controller_spec.rb +35 -35
- data/spec/adhearsion/call_spec.rb +49 -35
- data/spec/adhearsion/calls_spec.rb +2 -2
- data/spec/adhearsion/console_spec.rb +22 -23
- data/spec/adhearsion/events_spec.rb +3 -3
- data/spec/adhearsion/initializer_spec.rb +33 -35
- data/spec/adhearsion/logging_spec.rb +3 -3
- data/spec/adhearsion/outbound_call_spec.rb +21 -19
- data/spec/adhearsion/plugin_spec.rb +9 -11
- data/spec/adhearsion/process_spec.rb +15 -14
- data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +37 -42
- data/spec/adhearsion/punchblock_plugin_spec.rb +2 -2
- data/spec/adhearsion/router/evented_route_spec.rb +1 -1
- data/spec/adhearsion/router/openended_route_spec.rb +5 -5
- data/spec/adhearsion/router/route_spec.rb +9 -9
- data/spec/adhearsion/router/unaccepting_route_spec.rb +6 -6
- data/spec/adhearsion/router_spec.rb +8 -8
- data/spec/adhearsion/statistics_spec.rb +1 -1
- data/spec/adhearsion_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -2
- data/spec/support/call_controller_test_helpers.rb +11 -8
- data/spec/support/initializer_stubs.rb +1 -1
- data/spec/support/punchblock_mocks.rb +3 -2
- metadata +2 -16
@@ -11,6 +11,10 @@ describe Adhearsion::Plugin do
|
|
11
11
|
defined?(FooBar) and Object.send(:remove_const, :"FooBar")
|
12
12
|
end
|
13
13
|
|
14
|
+
before do
|
15
|
+
Adhearsion::PunchblockPlugin::Initializer.stub :start => true
|
16
|
+
end
|
17
|
+
|
14
18
|
describe "inheritance" do
|
15
19
|
after do
|
16
20
|
defined?(FooBar) and Object.send(:remove_const, :"FooBar")
|
@@ -139,7 +143,6 @@ describe Adhearsion::Plugin do
|
|
139
143
|
|
140
144
|
# 1 => Punchblock. Must be empty once punchblock initializer is an external Plugin
|
141
145
|
Adhearsion::Plugin.initializers.should have(1).initializers
|
142
|
-
flexmock(Adhearsion::PunchblockPlugin::Initializer).should_receive(:start).and_return true
|
143
146
|
Adhearsion::Plugin.init_plugins
|
144
147
|
end
|
145
148
|
|
@@ -152,9 +155,8 @@ describe Adhearsion::Plugin do
|
|
152
155
|
end
|
153
156
|
end
|
154
157
|
|
155
|
-
|
158
|
+
FooBar.should_receive(:log).once
|
156
159
|
Adhearsion::Plugin.initializers.length.should be 1
|
157
|
-
flexmock(Adhearsion::PunchblockPlugin::Initializer).should_receive(:start).and_return true
|
158
160
|
Adhearsion::Plugin.init_plugins
|
159
161
|
end
|
160
162
|
|
@@ -179,8 +181,7 @@ describe Adhearsion::Plugin do
|
|
179
181
|
end
|
180
182
|
end
|
181
183
|
|
182
|
-
|
183
|
-
flexmock(Adhearsion::PunchblockPlugin::Initializer).should_receive(:start).and_return true
|
184
|
+
FooBar.should_receive(:log).exactly(3).times
|
184
185
|
Adhearsion::Plugin.init_plugins
|
185
186
|
end
|
186
187
|
|
@@ -238,7 +239,6 @@ describe Adhearsion::Plugin do
|
|
238
239
|
|
239
240
|
# May become 1 if Punchblock defines a runner.
|
240
241
|
Adhearsion::Plugin.runners.should have(0).runners
|
241
|
-
flexmock(Adhearsion::PunchblockPlugin::Initializer).should_receive(:start).and_return true
|
242
242
|
Adhearsion::Plugin.run_plugins
|
243
243
|
end
|
244
244
|
|
@@ -251,9 +251,8 @@ describe Adhearsion::Plugin do
|
|
251
251
|
end
|
252
252
|
end
|
253
253
|
|
254
|
-
|
254
|
+
FooBar.should_receive(:log).once
|
255
255
|
Adhearsion::Plugin.runners.length.should be 1
|
256
|
-
flexmock(Adhearsion::PunchblockPlugin::Initializer).should_receive(:start).and_return true
|
257
256
|
Adhearsion::Plugin.run_plugins
|
258
257
|
end
|
259
258
|
|
@@ -278,8 +277,7 @@ describe Adhearsion::Plugin do
|
|
278
277
|
end
|
279
278
|
end
|
280
279
|
|
281
|
-
|
282
|
-
flexmock(Adhearsion::PunchblockPlugin::Initializer).should_receive(:start).and_return true
|
280
|
+
FooBar.should_receive(:log).exactly(3).times
|
283
281
|
Adhearsion::Plugin.run_plugins
|
284
282
|
end
|
285
283
|
|
@@ -375,7 +373,7 @@ describe Adhearsion::Plugin do
|
|
375
373
|
def self.foo
|
376
374
|
end
|
377
375
|
end
|
378
|
-
|
376
|
+
FooBar.should_receive(:foo).once
|
379
377
|
Adhearsion::Plugin.load_tasks
|
380
378
|
end
|
381
379
|
|
@@ -13,8 +13,8 @@ module Adhearsion
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should trigger :stop_requested events on #shutdown' do
|
16
|
-
|
17
|
-
|
16
|
+
Events.should_receive(:trigger_immediately).once.with(:stop_requested).ordered
|
17
|
+
Events.should_receive(:trigger_immediately).once.with(:shutdown).ordered
|
18
18
|
Adhearsion::Process.booted
|
19
19
|
Adhearsion::Process.shutdown
|
20
20
|
sleep 0.2
|
@@ -25,11 +25,11 @@ module Adhearsion
|
|
25
25
|
calls = ThreadSafeArray.new
|
26
26
|
3.times do
|
27
27
|
fake_call = Object.new
|
28
|
-
|
28
|
+
fake_call.should_receive(:hangup).once
|
29
29
|
calls << fake_call
|
30
30
|
end
|
31
|
-
|
32
|
-
|
31
|
+
Adhearsion.should_receive(:active_calls).and_return calls
|
32
|
+
Adhearsion::Process.instance.should_receive(:final_shutdown).once
|
33
33
|
calls = []
|
34
34
|
3.times do
|
35
35
|
calls << Thread.new do
|
@@ -42,15 +42,16 @@ module Adhearsion
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should terminate the process immediately on #force_stop' do
|
45
|
-
|
45
|
+
::Process.should_receive(:exit).with(1).once.and_return true
|
46
46
|
Adhearsion::Process.force_stop
|
47
47
|
end
|
48
48
|
|
49
49
|
describe "#final_shutdown" do
|
50
50
|
it "should hang up active calls" do
|
51
51
|
3.times do
|
52
|
-
fake_call =
|
53
|
-
|
52
|
+
fake_call = Call.new
|
53
|
+
fake_call.stub :id => random_call_id
|
54
|
+
fake_call.should_receive(:hangup).once
|
54
55
|
Adhearsion.active_calls << fake_call
|
55
56
|
end
|
56
57
|
|
@@ -62,9 +63,9 @@ module Adhearsion
|
|
62
63
|
it "should trigger shutdown handlers synchronously" do
|
63
64
|
foo = lambda { |b| b }
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
foo.should_receive(:[]).once.with(:a).ordered
|
67
|
+
foo.should_receive(:[]).once.with(:b).ordered
|
68
|
+
foo.should_receive(:[]).once.with(:c).ordered
|
68
69
|
|
69
70
|
Events.shutdown { sleep 2; foo[:a] }
|
70
71
|
Events.shutdown { sleep 1; foo[:b] }
|
@@ -74,7 +75,7 @@ module Adhearsion
|
|
74
75
|
end
|
75
76
|
|
76
77
|
it "should stop the console" do
|
77
|
-
|
78
|
+
Console.should_receive(:stop).once
|
78
79
|
Adhearsion::Process.final_shutdown
|
79
80
|
end
|
80
81
|
end
|
@@ -88,13 +89,13 @@ module Adhearsion
|
|
88
89
|
Adhearsion::Process.state_name.should be :rejecting
|
89
90
|
Adhearsion::Process.shutdown
|
90
91
|
Adhearsion::Process.state_name.should be :stopped
|
91
|
-
|
92
|
+
Adhearsion::Process.instance.should_receive(:die_now!).once
|
92
93
|
Adhearsion::Process.shutdown
|
93
94
|
sleep 0.2
|
94
95
|
end
|
95
96
|
|
96
97
|
it 'should forcibly kill the Adhearsion process on :force_stop' do
|
97
|
-
|
98
|
+
::Process.should_receive(:exit).once.with(1)
|
98
99
|
Adhearsion::Process.force_stop
|
99
100
|
end
|
100
101
|
end
|
@@ -26,7 +26,7 @@ module Adhearsion
|
|
26
26
|
|
27
27
|
def initialize_punchblock(options = {})
|
28
28
|
reset_default_config
|
29
|
-
|
29
|
+
Initializer.stub(:connect)
|
30
30
|
Adhearsion.config.punchblock do |config|
|
31
31
|
config.platform = options[:platform] if options.has_key?(:platform)
|
32
32
|
config.username = options[:username] if options.has_key?(:username)
|
@@ -47,16 +47,19 @@ module Adhearsion
|
|
47
47
|
Adhearsion.config[:punchblock]
|
48
48
|
end
|
49
49
|
|
50
|
+
let(:call_id) { rand }
|
51
|
+
let(:offer) { Punchblock::Event::Offer.new :target_call_id => call_id }
|
52
|
+
let(:mock_call) { Call.new }
|
53
|
+
let(:mock_client) { mock 'Client' }
|
54
|
+
|
50
55
|
before do
|
56
|
+
mock_call.stub :id => call_id
|
57
|
+
mock_client.stub :event_handler= => true
|
51
58
|
Events.refresh!
|
52
|
-
|
53
|
-
|
59
|
+
Adhearsion::Process.stub :fqdn => 'hostname'
|
60
|
+
::Process.stub :pid => 1234
|
54
61
|
end
|
55
62
|
|
56
|
-
let(:call_id) { rand }
|
57
|
-
let(:offer) { Punchblock::Event::Offer.new :target_call_id => call_id }
|
58
|
-
let(:mock_call) { flexmock Call.new, :id => call_id }
|
59
|
-
|
60
63
|
describe "starts the client with the default values" do
|
61
64
|
subject { initialize_punchblock }
|
62
65
|
|
@@ -108,28 +111,24 @@ module Adhearsion
|
|
108
111
|
it "starts the client with the correct resource" do
|
109
112
|
username = "usera@127.0.0.1/hostname-1234"
|
110
113
|
|
111
|
-
|
112
|
-
flexmock 'Client', :event_handler= => true
|
113
|
-
end
|
114
|
+
Punchblock::Connection::XMPP.should_receive(:new).once.with(hash_including :username => username).and_return mock_client
|
114
115
|
initialize_punchblock
|
115
116
|
end
|
116
117
|
|
117
118
|
it "starts the client with any overridden settings" do
|
118
119
|
overrides = {:username => 'userb@127.0.0.1/foo', :password => '123', :host => 'foo.bar.com', :port => 200, :connection_timeout => 20, :root_domain => 'foo.com', :calls_domain => 'call.foo.com', :mixers_domain => 'mixer.foo.com', :media_engine => :swift, :default_voice => :hal}
|
119
120
|
|
120
|
-
|
121
|
-
flexmock 'Client', :event_handler= => true
|
122
|
-
end
|
121
|
+
Punchblock::Connection::XMPP.should_receive(:new).once.with(overrides).and_return mock_client
|
123
122
|
initialize_punchblock overrides
|
124
123
|
end
|
125
124
|
|
126
125
|
describe "#connect" do
|
127
126
|
it 'should block until the connection is established' do
|
128
127
|
reset_default_config
|
129
|
-
mock_connection =
|
128
|
+
mock_connection = mock :mock_connection
|
130
129
|
mock_connection.should_receive(:register_event_handler).once
|
131
|
-
|
132
|
-
|
130
|
+
Punchblock::Client.should_receive(:new).once.and_return mock_connection
|
131
|
+
mock_connection.should_receive(:run).once
|
133
132
|
t = Thread.new { Initializer.init; Initializer.run }
|
134
133
|
t.join 5
|
135
134
|
t.status.should be == "sleep"
|
@@ -139,14 +138,12 @@ module Adhearsion
|
|
139
138
|
end
|
140
139
|
|
141
140
|
describe '#connect_to_server' do
|
142
|
-
let(:mock_client) { flexmock :client }
|
143
|
-
|
144
141
|
before :each do
|
145
142
|
Adhearsion::Process.reset
|
146
143
|
Initializer.config = reset_default_config
|
147
144
|
Initializer.config.reconnect_attempts = 1
|
148
|
-
|
149
|
-
|
145
|
+
Adhearsion::Logging.get_logger(Initializer).should_receive(:fatal).at_most(:once)
|
146
|
+
Initializer.stub(:client).and_return mock_client
|
150
147
|
end
|
151
148
|
|
152
149
|
after :each do
|
@@ -156,27 +153,27 @@ module Adhearsion
|
|
156
153
|
it 'should reset the Adhearsion process state to "booting"' do
|
157
154
|
Adhearsion::Process.booted
|
158
155
|
Adhearsion::Process.state_name.should be == :running
|
159
|
-
mock_client.
|
160
|
-
|
156
|
+
mock_client.stub(:run).and_raise Punchblock::DisconnectedError
|
157
|
+
Adhearsion::Process.should_receive(:reset).at_least(:once)
|
161
158
|
Initializer.connect_to_server
|
162
159
|
end
|
163
160
|
|
164
161
|
it 'should retry the connection the specified number of times' do
|
165
162
|
Initializer.config.reconnect_attempts = 3
|
166
|
-
mock_client.
|
163
|
+
mock_client.stub(:run).and_raise Punchblock::DisconnectedError
|
167
164
|
Initializer.connect_to_server
|
168
165
|
Initializer.attempts.should be == 3
|
169
166
|
end
|
170
167
|
|
171
168
|
it 'should preserve a Punchblock::ProtocolError exception and give up' do
|
172
|
-
mock_client.
|
169
|
+
mock_client.stub(:run).and_raise Punchblock::ProtocolError
|
173
170
|
expect { Initializer.connect_to_server }.to raise_error Punchblock::ProtocolError
|
174
171
|
end
|
175
172
|
|
176
173
|
it 'should not attempt to reconnect if Adhearsion is shutting down' do
|
177
174
|
Adhearsion::Process.booted
|
178
175
|
Adhearsion::Process.shutdown
|
179
|
-
mock_client.
|
176
|
+
mock_client.stub(:run).and_raise Punchblock::DisconnectedError
|
180
177
|
Initializer.should_not raise_error Punchblock::DisconnectedError
|
181
178
|
end
|
182
179
|
end
|
@@ -185,9 +182,7 @@ module Adhearsion
|
|
185
182
|
let(:overrides) { {:username => 'test', :password => '123', :host => 'foo.bar.com', :port => 200, :connection_timeout => 20, :root_domain => 'foo.com', :calls_domain => 'call.foo.com', :mixers_domain => 'mixer.foo.com', :media_engine => :swift, :default_voice => :hal} }
|
186
183
|
|
187
184
|
it 'should start an Asterisk PB connection' do
|
188
|
-
|
189
|
-
flexmock 'Client', :event_handler= => true
|
190
|
-
end
|
185
|
+
Punchblock::Connection::Asterisk.should_receive(:new).once.with(overrides).and_return mock_client
|
191
186
|
initialize_punchblock overrides.merge(:platform => :asterisk)
|
192
187
|
end
|
193
188
|
end
|
@@ -196,15 +191,13 @@ module Adhearsion
|
|
196
191
|
let(:overrides) { {:username => 'test', :password => '123', :host => 'foo.bar.com', :port => 200, :connection_timeout => 20, :root_domain => 'foo.com', :calls_domain => 'call.foo.com', :mixers_domain => 'mixer.foo.com', :media_engine => :swift, :default_voice => :hal} }
|
197
192
|
|
198
193
|
it 'should start an Asterisk PB connection' do
|
199
|
-
|
200
|
-
flexmock 'Client', :event_handler= => true
|
201
|
-
end
|
194
|
+
Punchblock::Connection::Freeswitch.should_receive(:new).once.with(overrides).and_return mock_client
|
202
195
|
initialize_punchblock overrides.merge(:platform => :freeswitch)
|
203
196
|
end
|
204
197
|
end
|
205
198
|
|
206
199
|
it 'should place events from Punchblock into the event handler' do
|
207
|
-
|
200
|
+
Events.instance.should_receive(:trigger).once.with(:punchblock, offer)
|
208
201
|
initialize_punchblock
|
209
202
|
Initializer.client.handle_event offer
|
210
203
|
end
|
@@ -212,8 +205,8 @@ module Adhearsion
|
|
212
205
|
describe "dispatching an offer" do
|
213
206
|
before do
|
214
207
|
initialize_punchblock
|
215
|
-
|
216
|
-
|
208
|
+
Adhearsion::Process.should_receive(:state_name).once.and_return process_state
|
209
|
+
Adhearsion.active_calls.should_receive(:from_offer).once.and_return mock_call
|
217
210
|
end
|
218
211
|
|
219
212
|
context "when the Adhearsion::Process is :booting" do
|
@@ -232,7 +225,7 @@ module Adhearsion
|
|
232
225
|
Adhearsion.router do
|
233
226
|
route 'foobar', Class.new
|
234
227
|
end
|
235
|
-
|
228
|
+
Adhearsion.router.should_receive(:handle).once.with mock_call
|
236
229
|
end
|
237
230
|
end
|
238
231
|
end
|
@@ -257,8 +250,10 @@ module Adhearsion
|
|
257
250
|
end
|
258
251
|
|
259
252
|
describe "dispatching a component event" do
|
260
|
-
let(:component) {
|
261
|
-
let(:mock_event) {
|
253
|
+
let(:component) { mock 'ComponentNode' }
|
254
|
+
let(:mock_event) { mock 'Event' }
|
255
|
+
|
256
|
+
before { mock_event.stub target_call_id: call_id, source: component }
|
262
257
|
|
263
258
|
before do
|
264
259
|
initialize_punchblock
|
@@ -271,7 +266,9 @@ module Adhearsion
|
|
271
266
|
end
|
272
267
|
|
273
268
|
describe "dispatching a call event" do
|
274
|
-
let(:mock_event) {
|
269
|
+
let(:mock_event) { mock 'Event' }
|
270
|
+
|
271
|
+
before { mock_event.stub target_call_id: call_id }
|
275
272
|
|
276
273
|
describe "with an active call" do
|
277
274
|
before do
|
@@ -280,16 +277,14 @@ module Adhearsion
|
|
280
277
|
end
|
281
278
|
|
282
279
|
it "should place the event in the call's inbox" do
|
283
|
-
mock_call.should_receive(:deliver_message
|
280
|
+
mock_call.async.should_receive(:deliver_message).once.with(mock_event)
|
284
281
|
Initializer.dispatch_call_event mock_event
|
285
282
|
end
|
286
283
|
end
|
287
284
|
|
288
285
|
describe "with an inactive call" do
|
289
|
-
let(:mock_event) { flexmock 'Event', :target_call_id => call_id }
|
290
|
-
|
291
286
|
it "should log an error" do
|
292
|
-
|
287
|
+
Adhearsion::Logging.get_logger(Initializer).should_receive(:error).once.with("Event received for inactive call #{call_id}: #{mock_event.inspect}")
|
293
288
|
Initializer.dispatch_call_event mock_event
|
294
289
|
end
|
295
290
|
end
|
@@ -13,13 +13,13 @@ module Adhearsion
|
|
13
13
|
describe '#execute_component' do
|
14
14
|
let(:message) { Punchblock::Command::Accept.new }
|
15
15
|
let(:response) { :foo }
|
16
|
-
let(:mock_client) {
|
16
|
+
let(:mock_client) { mock 'Client' }
|
17
17
|
|
18
18
|
let(:execute_expectation) { PunchblockPlugin.client.should_receive(:execute_command).once }
|
19
19
|
|
20
20
|
before do
|
21
21
|
PunchblockPlugin::Initializer.client = mock_client
|
22
|
-
|
22
|
+
message.stub :execute! => true
|
23
23
|
message.response = response
|
24
24
|
execute_expectation
|
25
25
|
end
|
@@ -18,25 +18,25 @@ module Adhearsion
|
|
18
18
|
|
19
19
|
let(:latch) { CountDownLatch.new 1 }
|
20
20
|
|
21
|
-
before {
|
21
|
+
before { call.wrapped_object.stub :write_and_await_response }
|
22
22
|
|
23
23
|
context "via a call controller" do
|
24
24
|
let(:controller) { CallController }
|
25
25
|
subject(:route) { Route.new 'foobar', controller }
|
26
26
|
|
27
27
|
it "should accept the call" do
|
28
|
-
|
28
|
+
call.should_receive(:accept).once
|
29
29
|
route.dispatch call, lambda { latch.countdown! }
|
30
30
|
latch.wait(2).should be true
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should instruct the call to use an instance of the controller" do
|
34
|
-
|
34
|
+
call.should_receive(:execute_controller).once.with kind_of(controller), kind_of(Proc)
|
35
35
|
route.dispatch call
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should not hangup the call after all controllers have executed" do
|
39
|
-
|
39
|
+
call.should_receive(:hangup).never
|
40
40
|
route.dispatch call, lambda { latch.countdown! }
|
41
41
|
latch.wait(2).should be true
|
42
42
|
end
|
@@ -50,7 +50,7 @@ module Adhearsion
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should instruct the call to use a CallController with the correct block" do
|
53
|
-
|
53
|
+
call.should_receive(:execute_controller).once.with(kind_of(CallController), kind_of(Proc)).and_return do |controller|
|
54
54
|
controller.block.call.should be == :foobar
|
55
55
|
end
|
56
56
|
route.dispatch call
|
@@ -109,32 +109,32 @@ module Adhearsion
|
|
109
109
|
|
110
110
|
let(:latch) { CountDownLatch.new 1 }
|
111
111
|
|
112
|
-
before {
|
112
|
+
before { call.wrapped_object.should_receive :write_and_await_response }
|
113
113
|
|
114
114
|
context "via a call controller" do
|
115
115
|
let(:controller) { CallController }
|
116
116
|
let(:route) { Route.new 'foobar', controller }
|
117
117
|
|
118
118
|
it "should immediately fire the :call_routed event giving the call and route" do
|
119
|
-
|
120
|
-
|
119
|
+
Adhearsion::Events.should_receive(:trigger_immediately).once.with(:call_routed, call: call, route: route)
|
120
|
+
call.should_receive(:hangup).once
|
121
121
|
route.dispatch call, lambda { latch.countdown! }
|
122
122
|
latch.wait(2).should be true
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should accept the call" do
|
126
|
-
|
126
|
+
call.should_receive(:accept).once
|
127
127
|
route.dispatch call, lambda { latch.countdown! }
|
128
128
|
latch.wait(2).should be true
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should instruct the call to use an instance of the controller" do
|
132
|
-
|
132
|
+
call.should_receive(:execute_controller).once.with kind_of(controller), kind_of(Proc)
|
133
133
|
route.dispatch call
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should hangup the call after all controllers have executed" do
|
137
|
-
|
137
|
+
call.should_receive(:hangup).once
|
138
138
|
route.dispatch call, lambda { latch.countdown! }
|
139
139
|
latch.wait(2).should be true
|
140
140
|
end
|
@@ -143,14 +143,14 @@ module Adhearsion
|
|
143
143
|
before { call[:ahn_prevent_hangup] = true }
|
144
144
|
|
145
145
|
it "should not hangup the call after controller execution" do
|
146
|
-
|
146
|
+
call.should_receive(:hangup).never
|
147
147
|
route.dispatch call, lambda { latch.countdown! }
|
148
148
|
latch.wait(2).should be true
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
152
|
context "if hangup raises a Call::Hangup" do
|
153
|
-
before {
|
153
|
+
before { call.should_receive(:hangup).once.and_raise Call::Hangup }
|
154
154
|
|
155
155
|
it "should not raise an exception" do
|
156
156
|
lambda do
|
@@ -169,7 +169,7 @@ module Adhearsion
|
|
169
169
|
end
|
170
170
|
|
171
171
|
it "should instruct the call to use a CallController with the correct block" do
|
172
|
-
|
172
|
+
call.should_receive(:execute_controller).once.with(kind_of(CallController), kind_of(Proc)).and_return do |controller|
|
173
173
|
controller.block.call.should be == :foobar
|
174
174
|
end
|
175
175
|
route.dispatch call
|