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
|
@@ -29,7 +29,7 @@ module Punchblock
|
|
|
29
29
|
let(:response) { double 'Response' }
|
|
30
30
|
|
|
31
31
|
it 'should execute the handler' do
|
|
32
|
-
response.
|
|
32
|
+
expect(response).to receive(:call).once.with es_event
|
|
33
33
|
subject.register_handler :es, :event_name => 'CHANNEL_EXECUTE' do |event|
|
|
34
34
|
response.call event
|
|
35
35
|
end
|
|
@@ -51,7 +51,7 @@ module Punchblock
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it "should send the event to the connection" do
|
|
54
|
-
connection.
|
|
54
|
+
expect(connection).to receive(:handle_event).once.with expected_event
|
|
55
55
|
subject.send_event event
|
|
56
56
|
end
|
|
57
57
|
end
|
|
@@ -65,28 +65,28 @@ module Punchblock
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it "should send a complete event with the specified reason" do
|
|
68
|
-
subject.wrapped_object.
|
|
68
|
+
expect(subject.wrapped_object).to receive(:send_event).once.with expected_event
|
|
69
69
|
subject.send_complete_event reason
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
it "should cause the actor to be shut down" do
|
|
73
|
-
subject.wrapped_object.
|
|
73
|
+
allow(subject.wrapped_object).to receive(:send_event).and_return true
|
|
74
74
|
subject.send_complete_event reason
|
|
75
75
|
sleep 0.2
|
|
76
|
-
subject.
|
|
76
|
+
expect(subject.alive?).to be false
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
describe "#call_ended" do
|
|
81
81
|
it "should send a complete event with the call hangup reason" do
|
|
82
|
-
subject.wrapped_object.
|
|
82
|
+
expect(subject.wrapped_object).to receive(:send_complete_event).once.with Punchblock::Event::Complete::Hangup.new
|
|
83
83
|
subject.call_ended
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
describe "#application" do
|
|
88
88
|
it "should execute a FS application on the current call" do
|
|
89
|
-
call.
|
|
89
|
+
expect(call).to receive(:application).once.with('appname', "%[punchblock_component_id=#{subject.id}]options")
|
|
90
90
|
subject.application 'appname', 'options'
|
|
91
91
|
end
|
|
92
92
|
end
|
|
@@ -103,7 +103,7 @@ module Punchblock
|
|
|
103
103
|
|
|
104
104
|
it 'sends an error in response to the command' do
|
|
105
105
|
subject.execute_command component_command
|
|
106
|
-
component_command.response.
|
|
106
|
+
expect(component_command.response).to eq(ProtocolError.new.setup('command-not-acceptable', "Did not understand command for component #{subject.id}", call.id, subject.id))
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
end
|
|
@@ -10,19 +10,26 @@ module Punchblock
|
|
|
10
10
|
let(:translator) { described_class.new connection }
|
|
11
11
|
let(:stream) { double 'RubyFS::Stream' }
|
|
12
12
|
|
|
13
|
-
before { connection.
|
|
13
|
+
before { expect(connection).to receive(:stream).at_most(:once).and_return stream }
|
|
14
14
|
|
|
15
15
|
subject { translator }
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
describe '#connection' do
|
|
18
|
+
subject { super().connection }
|
|
19
|
+
it { should be connection }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe '#stream' do
|
|
23
|
+
subject { super().stream }
|
|
24
|
+
it { should be stream }
|
|
25
|
+
end
|
|
19
26
|
|
|
20
27
|
describe '#terminate' do
|
|
21
28
|
it "terminates all calls" do
|
|
22
29
|
call = described_class::Call.new 'foo', subject
|
|
23
30
|
subject.register_call call
|
|
24
31
|
subject.terminate
|
|
25
|
-
call.
|
|
32
|
+
expect(call.alive?).to be false
|
|
26
33
|
end
|
|
27
34
|
end
|
|
28
35
|
|
|
@@ -32,10 +39,10 @@ module Punchblock
|
|
|
32
39
|
let(:call_id) { 'abc123' }
|
|
33
40
|
|
|
34
41
|
it 'executes the call command' do
|
|
35
|
-
subject.wrapped_object.
|
|
36
|
-
c.
|
|
37
|
-
c.target_call_id.
|
|
38
|
-
|
|
42
|
+
expect(subject.wrapped_object).to receive(:execute_call_command).with { |c|
|
|
43
|
+
expect(c).to be command
|
|
44
|
+
expect(c.target_call_id).to eq(call_id)
|
|
45
|
+
}
|
|
39
46
|
subject.execute_command command, :call_id => call_id
|
|
40
47
|
end
|
|
41
48
|
end
|
|
@@ -45,10 +52,10 @@ module Punchblock
|
|
|
45
52
|
let(:component_id) { '123abc' }
|
|
46
53
|
|
|
47
54
|
it 'executes the component command' do
|
|
48
|
-
subject.wrapped_object.
|
|
49
|
-
c.
|
|
50
|
-
c.component_id.
|
|
51
|
-
|
|
55
|
+
expect(subject.wrapped_object).to receive(:execute_component_command).with { |c|
|
|
56
|
+
expect(c).to be command
|
|
57
|
+
expect(c.component_id).to eq(component_id)
|
|
58
|
+
}
|
|
52
59
|
subject.execute_command command, :component_id => component_id
|
|
53
60
|
end
|
|
54
61
|
end
|
|
@@ -57,7 +64,7 @@ module Punchblock
|
|
|
57
64
|
let(:command) { Command::Dial.new }
|
|
58
65
|
|
|
59
66
|
it 'executes the command directly' do
|
|
60
|
-
subject.wrapped_object.
|
|
67
|
+
expect(subject.wrapped_object).to receive(:execute_global_command).with command
|
|
61
68
|
subject.execute_command command
|
|
62
69
|
end
|
|
63
70
|
end
|
|
@@ -72,7 +79,7 @@ module Punchblock
|
|
|
72
79
|
end
|
|
73
80
|
|
|
74
81
|
it 'should make the call accessible by ID' do
|
|
75
|
-
subject.call_with_id(call_id).
|
|
82
|
+
expect(subject.call_with_id(call_id)).to be call
|
|
76
83
|
end
|
|
77
84
|
end
|
|
78
85
|
|
|
@@ -85,9 +92,9 @@ module Punchblock
|
|
|
85
92
|
end
|
|
86
93
|
|
|
87
94
|
it 'should make the call inaccessible by ID' do
|
|
88
|
-
subject.call_with_id(call_id).
|
|
95
|
+
expect(subject.call_with_id(call_id)).to be call
|
|
89
96
|
subject.deregister_call call_id
|
|
90
|
-
subject.call_with_id(call_id).
|
|
97
|
+
expect(subject.call_with_id(call_id)).to be_nil
|
|
91
98
|
end
|
|
92
99
|
end
|
|
93
100
|
|
|
@@ -97,7 +104,7 @@ module Punchblock
|
|
|
97
104
|
|
|
98
105
|
it 'should make the component accessible by ID' do
|
|
99
106
|
subject.register_component component
|
|
100
|
-
subject.component_with_id(component_id).
|
|
107
|
+
expect(subject.component_with_id(component_id)).to be component
|
|
101
108
|
end
|
|
102
109
|
end
|
|
103
110
|
|
|
@@ -110,12 +117,12 @@ module Punchblock
|
|
|
110
117
|
|
|
111
118
|
before do
|
|
112
119
|
command.request!
|
|
113
|
-
call.
|
|
120
|
+
allow(call).to receive(:id).and_return call_id
|
|
114
121
|
subject.register_call call
|
|
115
122
|
end
|
|
116
123
|
|
|
117
124
|
it 'sends the command to the call for execution' do
|
|
118
|
-
call.async.
|
|
125
|
+
expect(call.async).to receive(:execute_command).once.with command
|
|
119
126
|
subject.execute_call_command command
|
|
120
127
|
end
|
|
121
128
|
end
|
|
@@ -141,16 +148,16 @@ module Punchblock
|
|
|
141
148
|
raise 'Woops, I died'
|
|
142
149
|
end
|
|
143
150
|
|
|
144
|
-
connection.
|
|
151
|
+
expect(connection).to receive(:handle_event).once.with end_error_event
|
|
145
152
|
|
|
146
|
-
|
|
153
|
+
expect { call.oops }.to raise_error(/Woops, I died/)
|
|
147
154
|
sleep 0.1
|
|
148
|
-
call.
|
|
149
|
-
subject.call_with_id(call_id).
|
|
155
|
+
expect(call.alive?).to be false
|
|
156
|
+
expect(subject.call_with_id(call_id)).to be_nil
|
|
150
157
|
|
|
151
158
|
command.request!
|
|
152
159
|
subject.execute_call_command command
|
|
153
|
-
command.response.
|
|
160
|
+
expect(command.response).to eq(ProtocolError.new.setup(:item_not_found, "Could not find a call with ID #{call_id}", call_id))
|
|
154
161
|
end
|
|
155
162
|
end
|
|
156
163
|
|
|
@@ -163,7 +170,7 @@ module Punchblock
|
|
|
163
170
|
let(:call_id) { call.id }
|
|
164
171
|
|
|
165
172
|
before do
|
|
166
|
-
connection.
|
|
173
|
+
allow(connection).to receive :handle_event
|
|
167
174
|
subject.handle_es_event es_event
|
|
168
175
|
call_id
|
|
169
176
|
end
|
|
@@ -173,16 +180,16 @@ module Punchblock
|
|
|
173
180
|
raise 'Woops, I died'
|
|
174
181
|
end
|
|
175
182
|
|
|
176
|
-
connection.
|
|
183
|
+
expect(connection).to receive(:handle_event).once.with end_error_event
|
|
177
184
|
|
|
178
|
-
|
|
185
|
+
expect { call.oops }.to raise_error(/Woops, I died/)
|
|
179
186
|
sleep 0.1
|
|
180
|
-
call.
|
|
181
|
-
subject.call_with_id(call_id).
|
|
187
|
+
expect(call.alive?).to be false
|
|
188
|
+
expect(subject.call_with_id(call_id)).to be_nil
|
|
182
189
|
|
|
183
190
|
command.request!
|
|
184
191
|
subject.execute_call_command command
|
|
185
|
-
command.response.
|
|
192
|
+
expect(command.response).to eq(ProtocolError.new.setup(:item_not_found, "Could not find a call with ID #{call_id}", call_id))
|
|
186
193
|
end
|
|
187
194
|
end
|
|
188
195
|
|
|
@@ -190,7 +197,7 @@ module Punchblock
|
|
|
190
197
|
it 'sends an error in response to the command' do
|
|
191
198
|
command.request!
|
|
192
199
|
subject.execute_call_command command
|
|
193
|
-
command.response.
|
|
200
|
+
expect(command.response).to eq(ProtocolError.new.setup(:item_not_found, "Could not find a call with ID #{call_id}", call_id, nil))
|
|
194
201
|
end
|
|
195
202
|
end
|
|
196
203
|
end
|
|
@@ -212,7 +219,7 @@ module Punchblock
|
|
|
212
219
|
end
|
|
213
220
|
|
|
214
221
|
it 'sends the command to the component for execution' do
|
|
215
|
-
component.async.
|
|
222
|
+
expect(component.async).to receive(:execute_command).once.with command
|
|
216
223
|
subject.execute_component_command command
|
|
217
224
|
end
|
|
218
225
|
end
|
|
@@ -220,7 +227,7 @@ module Punchblock
|
|
|
220
227
|
context "with an unknown component ID" do
|
|
221
228
|
it 'sends an error in response to the command' do
|
|
222
229
|
subject.execute_component_command command
|
|
223
|
-
command.response.
|
|
230
|
+
expect(command.response).to eq(ProtocolError.new.setup(:item_not_found, "Could not find a component with ID #{component.id}", nil, component.id))
|
|
224
231
|
end
|
|
225
232
|
end
|
|
226
233
|
end
|
|
@@ -235,7 +242,7 @@ module Punchblock
|
|
|
235
242
|
|
|
236
243
|
before do
|
|
237
244
|
id
|
|
238
|
-
Punchblock.
|
|
245
|
+
expect(Punchblock).to receive(:new_uuid).once.and_return id
|
|
239
246
|
command.request!
|
|
240
247
|
stream.as_null_object
|
|
241
248
|
end
|
|
@@ -243,15 +250,15 @@ module Punchblock
|
|
|
243
250
|
it 'should be able to look up the call by ID' do
|
|
244
251
|
subject.execute_global_command command
|
|
245
252
|
call = subject.call_with_id id
|
|
246
|
-
call.
|
|
247
|
-
call.translator.
|
|
248
|
-
call.stream.
|
|
253
|
+
expect(call).to be_a Freeswitch::Call
|
|
254
|
+
expect(call.translator).to be subject
|
|
255
|
+
expect(call.stream).to be stream
|
|
249
256
|
end
|
|
250
257
|
|
|
251
258
|
it 'should instruct the call to send a dial' do
|
|
252
259
|
mock_call = double('Freeswitch::Call').as_null_object
|
|
253
|
-
Freeswitch::Call.
|
|
254
|
-
mock_call.async.
|
|
260
|
+
expect(Freeswitch::Call).to receive(:new_link).once.and_return mock_call
|
|
261
|
+
expect(mock_call.async).to receive(:dial).once.with command
|
|
255
262
|
subject.execute_global_command command
|
|
256
263
|
end
|
|
257
264
|
end
|
|
@@ -263,7 +270,7 @@ module Punchblock
|
|
|
263
270
|
|
|
264
271
|
it 'sends an error in response to the command' do
|
|
265
272
|
subject.execute_command command
|
|
266
|
-
command.response.
|
|
273
|
+
expect(command.response).to eq(ProtocolError.new.setup('command-not-acceptable', "Did not understand command"))
|
|
267
274
|
end
|
|
268
275
|
end
|
|
269
276
|
end
|
|
@@ -271,13 +278,13 @@ module Punchblock
|
|
|
271
278
|
describe '#handle_pb_event' do
|
|
272
279
|
it 'should forward the event to the connection' do
|
|
273
280
|
event = double 'Punchblock::Event'
|
|
274
|
-
subject.connection.
|
|
281
|
+
expect(subject.connection).to receive(:handle_event).once.with event
|
|
275
282
|
subject.handle_pb_event event
|
|
276
283
|
end
|
|
277
284
|
end
|
|
278
285
|
|
|
279
286
|
describe '#handle_es_event' do
|
|
280
|
-
before { subject.wrapped_object.
|
|
287
|
+
before { allow(subject.wrapped_object).to receive :handle_pb_event }
|
|
281
288
|
|
|
282
289
|
let(:unique_id) { "3f0e1e18-c056-11e1-b099-fffeda3ce54f" }
|
|
283
290
|
|
|
@@ -423,10 +430,10 @@ module Punchblock
|
|
|
423
430
|
it 'should be able to look up the call by ID' do
|
|
424
431
|
subject.handle_es_event es_event
|
|
425
432
|
call = subject.call_with_id unique_id
|
|
426
|
-
call.
|
|
427
|
-
call.translator.
|
|
428
|
-
call.stream.
|
|
429
|
-
call.es_env.
|
|
433
|
+
expect(call).to be_a Freeswitch::Call
|
|
434
|
+
expect(call.translator).to be subject
|
|
435
|
+
expect(call.stream).to be stream
|
|
436
|
+
expect(call.es_env).to eq({
|
|
430
437
|
:variable_direction => "inbound",
|
|
431
438
|
:variable_uuid => "3f0e1e18-c056-11e1-b099-fffeda3ce54f",
|
|
432
439
|
:variable_session_id => "1",
|
|
@@ -499,14 +506,14 @@ module Punchblock
|
|
|
499
506
|
:variable_rfc2822_date => "Wed, 27 Jun 2012 13:47:25 +0100",
|
|
500
507
|
:variable_export_vars => "RFC2822_DATE",
|
|
501
508
|
:variable_current_application => "park"
|
|
502
|
-
}
|
|
509
|
+
})
|
|
503
510
|
end
|
|
504
511
|
|
|
505
512
|
describe "with a RubyFS::Stream::Connected" do
|
|
506
513
|
let(:es_event) { RubyFS::Stream::Connected.new }
|
|
507
514
|
|
|
508
515
|
it "should send a Punchblock::Connection::Connected event" do
|
|
509
|
-
subject.wrapped_object.
|
|
516
|
+
expect(subject.wrapped_object).to receive(:handle_pb_event).once.with(Punchblock::Connection::Connected.new)
|
|
510
517
|
subject.handle_es_event es_event
|
|
511
518
|
end
|
|
512
519
|
end
|
|
@@ -522,9 +529,9 @@ module Punchblock
|
|
|
522
529
|
describe 'with a CHANNEL_PARK event' do
|
|
523
530
|
it 'should instruct the call to send an offer' do
|
|
524
531
|
mock_call = double('Freeswitch::Call').as_null_object
|
|
525
|
-
Freeswitch::Call.
|
|
526
|
-
subject.wrapped_object.
|
|
527
|
-
mock_call.async.
|
|
532
|
+
expect(Freeswitch::Call).to receive(:new).once.and_return mock_call
|
|
533
|
+
expect(subject.wrapped_object).to receive(:link)
|
|
534
|
+
expect(mock_call.async).to receive(:send_offer).once
|
|
528
535
|
subject.handle_es_event es_event
|
|
529
536
|
end
|
|
530
537
|
|
|
@@ -536,7 +543,7 @@ module Punchblock
|
|
|
536
543
|
end
|
|
537
544
|
|
|
538
545
|
it "should not create a new call" do
|
|
539
|
-
Freeswitch::Call.
|
|
546
|
+
expect(Freeswitch::Call).to receive(:new).never
|
|
540
547
|
subject.handle_es_event es_event
|
|
541
548
|
end
|
|
542
549
|
end
|
|
@@ -561,12 +568,12 @@ module Punchblock
|
|
|
561
568
|
end
|
|
562
569
|
|
|
563
570
|
it "is delivered to the bridging leg" do
|
|
564
|
-
call_a.async.
|
|
571
|
+
expect(call_a.async).to receive(:handle_es_event).once.with es_event
|
|
565
572
|
subject.handle_es_event es_event
|
|
566
573
|
end
|
|
567
574
|
|
|
568
575
|
it "is delivered to the other leg" do
|
|
569
|
-
call_b.async.
|
|
576
|
+
expect(call_b.async).to receive(:handle_es_event).once.with es_event
|
|
570
577
|
subject.handle_es_event es_event
|
|
571
578
|
end
|
|
572
579
|
end
|
|
@@ -591,12 +598,12 @@ module Punchblock
|
|
|
591
598
|
end
|
|
592
599
|
|
|
593
600
|
it "is delivered to the bridging leg" do
|
|
594
|
-
call_a.async.
|
|
601
|
+
expect(call_a.async).to receive(:handle_es_event).once.with es_event
|
|
595
602
|
subject.handle_es_event es_event
|
|
596
603
|
end
|
|
597
604
|
|
|
598
605
|
it "is delivered to the other leg" do
|
|
599
|
-
call_b.async.
|
|
606
|
+
expect(call_b.async).to receive(:handle_es_event).once.with es_event
|
|
600
607
|
subject.handle_es_event es_event
|
|
601
608
|
end
|
|
602
609
|
end
|
|
@@ -619,8 +626,8 @@ module Punchblock
|
|
|
619
626
|
end
|
|
620
627
|
|
|
621
628
|
it "is delivered only to the primary leg" do
|
|
622
|
-
call_a.async.
|
|
623
|
-
call_b.async.
|
|
629
|
+
expect(call_a.async).to receive(:handle_es_event).once.with es_event
|
|
630
|
+
expect(call_b.async).to receive(:handle_es_event).never
|
|
624
631
|
subject.handle_es_event es_event
|
|
625
632
|
end
|
|
626
633
|
end
|
|
@@ -635,7 +642,7 @@ module Punchblock
|
|
|
635
642
|
end
|
|
636
643
|
|
|
637
644
|
it 'sends the ES event to the call' do
|
|
638
|
-
call.async.
|
|
645
|
+
expect(call.async).to receive(:handle_es_event).once.with es_event
|
|
639
646
|
subject.handle_es_event es_event
|
|
640
647
|
end
|
|
641
648
|
end
|
|
@@ -3,23 +3,47 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
describe Punchblock::URIList do
|
|
6
|
-
|
|
6
|
+
describe '#size' do
|
|
7
|
+
subject { super().size }
|
|
8
|
+
it { should == 0 }
|
|
9
|
+
end
|
|
7
10
|
|
|
8
11
|
context "created with a set of entries" do
|
|
9
12
|
subject { described_class.new 'http://example.com/hello.mp3', 'http://example.com/goodbye.mp3' }
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
describe '#size' do
|
|
15
|
+
subject { super().size }
|
|
16
|
+
it { should == 2 }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe '#to_ary' do
|
|
20
|
+
subject { super().to_ary }
|
|
21
|
+
it { should == ['http://example.com/hello.mp3', 'http://example.com/goodbye.mp3'] }
|
|
22
|
+
end
|
|
13
23
|
|
|
14
|
-
|
|
24
|
+
describe '#to_s' do
|
|
25
|
+
subject { super().to_s }
|
|
26
|
+
it { should == "http://example.com/hello.mp3\nhttp://example.com/goodbye.mp3" }
|
|
27
|
+
end
|
|
15
28
|
end
|
|
16
29
|
|
|
17
30
|
context "created with an array of entries" do
|
|
18
31
|
subject { described_class.new ['http://example.com/hello.mp3', 'http://example.com/goodbye.mp3'] }
|
|
19
32
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
33
|
+
describe '#size' do
|
|
34
|
+
subject { super().size }
|
|
35
|
+
it { should == 2 }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe '#to_ary' do
|
|
39
|
+
subject { super().to_ary }
|
|
40
|
+
it { should == ['http://example.com/hello.mp3', 'http://example.com/goodbye.mp3'] }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe '#to_s' do
|
|
44
|
+
subject { super().to_s }
|
|
45
|
+
it { should == "http://example.com/hello.mp3\nhttp://example.com/goodbye.mp3" }
|
|
46
|
+
end
|
|
23
47
|
end
|
|
24
48
|
|
|
25
49
|
context "imported from a string" do
|
|
@@ -32,9 +56,20 @@ describe Punchblock::URIList do
|
|
|
32
56
|
|
|
33
57
|
subject { described_class.import string }
|
|
34
58
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
59
|
+
describe '#size' do
|
|
60
|
+
subject { super().size }
|
|
61
|
+
it { should == 2 }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe '#to_ary' do
|
|
65
|
+
subject { super().to_ary }
|
|
66
|
+
it { should == ['http://example.com/hello.mp3', 'http://example.com/goodbye.mp3'] }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe '#to_s' do
|
|
70
|
+
subject { super().to_s }
|
|
71
|
+
it { should == "http://example.com/hello.mp3\nhttp://example.com/goodbye.mp3" }
|
|
72
|
+
end
|
|
38
73
|
end
|
|
39
74
|
|
|
40
75
|
describe "comparisons" do
|