punchblock 1.6.1 → 1.7.0
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.
- data/CHANGELOG.md +8 -0
- data/Guardfile +1 -1
- data/Rakefile +1 -1
- data/lib/punchblock/client.rb +5 -8
- data/lib/punchblock/client/component_registry.rb +8 -1
- data/lib/punchblock/component/component_node.rb +1 -0
- data/lib/punchblock/component/output.rb +15 -1
- data/lib/punchblock/translator/asterisk.rb +1 -1
- data/lib/punchblock/translator/asterisk/call.rb +1 -1
- data/lib/punchblock/translator/asterisk/component/output.rb +5 -1
- data/lib/punchblock/translator/freeswitch.rb +7 -1
- data/lib/punchblock/translator/freeswitch/call.rb +10 -6
- data/lib/punchblock/translator/freeswitch/component.rb +1 -1
- data/lib/punchblock/version.rb +1 -1
- data/punchblock.gemspec +1 -2
- data/spec/punchblock/client/component_registry_spec.rb +7 -0
- data/spec/punchblock/client_spec.rb +14 -12
- data/spec/punchblock/command_node_spec.rb +2 -2
- data/spec/punchblock/component/component_node_spec.rb +10 -3
- data/spec/punchblock/component/input_spec.rb +1 -1
- data/spec/punchblock/component/output_spec.rb +32 -27
- data/spec/punchblock/component/record_spec.rb +5 -5
- data/spec/punchblock/connection/asterisk_spec.rb +7 -7
- data/spec/punchblock/connection/freeswitch_spec.rb +8 -8
- data/spec/punchblock/connection/xmpp_spec.rb +9 -9
- data/spec/punchblock/translator/asterisk/call_spec.rb +65 -65
- data/spec/punchblock/translator/asterisk/component/asterisk/agi_command_spec.rb +17 -20
- data/spec/punchblock/translator/asterisk/component/asterisk/ami_action_spec.rb +13 -16
- data/spec/punchblock/translator/asterisk/component/input_spec.rb +9 -12
- data/spec/punchblock/translator/asterisk/component/output_spec.rb +62 -29
- data/spec/punchblock/translator/asterisk/component/record_spec.rb +38 -42
- data/spec/punchblock/translator/asterisk/component/stop_by_redirect_spec.rb +2 -2
- data/spec/punchblock/translator/asterisk/component_spec.rb +5 -5
- data/spec/punchblock/translator/asterisk_spec.rb +55 -55
- data/spec/punchblock/translator/freeswitch/call_spec.rb +80 -54
- data/spec/punchblock/translator/freeswitch/component/flite_output_spec.rb +7 -10
- data/spec/punchblock/translator/freeswitch/component/input_spec.rb +8 -10
- data/spec/punchblock/translator/freeswitch/component/output_spec.rb +9 -12
- data/spec/punchblock/translator/freeswitch/component/record_spec.rb +31 -34
- data/spec/punchblock/translator/freeswitch/component/tts_output_spec.rb +7 -10
- data/spec/punchblock/translator/freeswitch/component_spec.rb +6 -6
- data/spec/punchblock/translator/freeswitch_spec.rb +27 -27
- data/spec/punchblock_spec.rb +5 -6
- data/spec/spec_helper.rb +2 -3
- data/spec/support/mock_connection_with_event_handler.rb +8 -19
- metadata +5 -21
|
@@ -7,11 +7,8 @@ module Punchblock
|
|
|
7
7
|
class Freeswitch
|
|
8
8
|
module Component
|
|
9
9
|
describe Input do
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
original_command.add_event event
|
|
13
|
-
end
|
|
14
|
-
end
|
|
10
|
+
include HasMockCallbackConnection
|
|
11
|
+
|
|
15
12
|
let(:id) { Punchblock.new_uuid }
|
|
16
13
|
let(:translator) { Punchblock::Translator::Freeswitch.new connection }
|
|
17
14
|
let(:mock_stream) { mock('RubyFS::Stream') }
|
|
@@ -74,6 +71,7 @@ module Punchblock
|
|
|
74
71
|
before do
|
|
75
72
|
send_dtmf 1
|
|
76
73
|
send_dtmf 2
|
|
74
|
+
sleep 0.5
|
|
77
75
|
end
|
|
78
76
|
|
|
79
77
|
let :expected_event do
|
|
@@ -90,7 +88,7 @@ module Punchblock
|
|
|
90
88
|
end
|
|
91
89
|
|
|
92
90
|
it "should not process further dtmf events" do
|
|
93
|
-
subject.
|
|
91
|
+
subject.should_receive(:process_dtmf!).never
|
|
94
92
|
send_dtmf 3
|
|
95
93
|
end
|
|
96
94
|
end
|
|
@@ -185,7 +183,7 @@ module Punchblock
|
|
|
185
183
|
let(:original_command_opts) { { :initial_timeout => -1 } }
|
|
186
184
|
|
|
187
185
|
it "should not start a timer" do
|
|
188
|
-
subject.wrapped_object.
|
|
186
|
+
subject.wrapped_object.should_receive(:begin_initial_timer).never
|
|
189
187
|
subject.execute
|
|
190
188
|
end
|
|
191
189
|
end
|
|
@@ -194,7 +192,7 @@ module Punchblock
|
|
|
194
192
|
let(:original_command_opts) { { :initial_timeout => nil } }
|
|
195
193
|
|
|
196
194
|
it "should not start a timer" do
|
|
197
|
-
subject.wrapped_object.
|
|
195
|
+
subject.wrapped_object.should_receive(:begin_initial_timer).never
|
|
198
196
|
subject.execute
|
|
199
197
|
end
|
|
200
198
|
end
|
|
@@ -237,7 +235,7 @@ module Punchblock
|
|
|
237
235
|
let(:original_command_opts) { { :inter_digit_timeout => -1 } }
|
|
238
236
|
|
|
239
237
|
it "should not start a timer" do
|
|
240
|
-
subject.wrapped_object.
|
|
238
|
+
subject.wrapped_object.should_receive(:begin_inter_digit_timer).never
|
|
241
239
|
subject.execute
|
|
242
240
|
end
|
|
243
241
|
end
|
|
@@ -246,7 +244,7 @@ module Punchblock
|
|
|
246
244
|
let(:original_command_opts) { { :inter_digit_timeout => nil } }
|
|
247
245
|
|
|
248
246
|
it "should not start a timer" do
|
|
249
|
-
subject.wrapped_object.
|
|
247
|
+
subject.wrapped_object.should_receive(:begin_inter_digit_timer).never
|
|
250
248
|
subject.execute
|
|
251
249
|
end
|
|
252
250
|
end
|
|
@@ -7,11 +7,8 @@ module Punchblock
|
|
|
7
7
|
class Freeswitch
|
|
8
8
|
module Component
|
|
9
9
|
describe Output do
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
original_command.add_event event
|
|
13
|
-
end
|
|
14
|
-
end
|
|
10
|
+
include HasMockCallbackConnection
|
|
11
|
+
|
|
15
12
|
let(:translator) { Punchblock::Translator::Freeswitch.new connection }
|
|
16
13
|
let(:mock_call) { Punchblock::Translator::Freeswitch::Call.new 'foo', translator }
|
|
17
14
|
|
|
@@ -34,7 +31,7 @@ module Punchblock
|
|
|
34
31
|
describe '#execute' do
|
|
35
32
|
before { original_command.request! }
|
|
36
33
|
def expect_playback(filename = audio_filename)
|
|
37
|
-
subject.wrapped_object.
|
|
34
|
+
subject.wrapped_object.should_receive(:application).once.with 'playback', "file_string://#{filename}"
|
|
38
35
|
end
|
|
39
36
|
|
|
40
37
|
let(:audio_filename) { 'http://foo.com/bar.mp3' }
|
|
@@ -105,7 +102,7 @@ module Punchblock
|
|
|
105
102
|
end
|
|
106
103
|
|
|
107
104
|
it 'should send a complete event when the file finishes playback' do
|
|
108
|
-
expect_playback
|
|
105
|
+
expect_playback
|
|
109
106
|
subject.execute
|
|
110
107
|
subject.handle_es_event RubyFS::Event.new(nil, :event_name => "CHANNEL_EXECUTE_COMPLETE", :application_response => 'FILE PLAYED')
|
|
111
108
|
original_command.complete_event(0.1).reason.should be_a Punchblock::Component::Output::Complete::Success
|
|
@@ -116,7 +113,7 @@ module Punchblock
|
|
|
116
113
|
let(:complete_reason) { original_command.complete_event(0.1).reason }
|
|
117
114
|
|
|
118
115
|
it "sends a complete event with an error reason" do
|
|
119
|
-
expect_playback
|
|
116
|
+
expect_playback
|
|
120
117
|
subject.execute
|
|
121
118
|
subject.handle_es_event fs_event
|
|
122
119
|
complete_reason.should be_a Punchblock::Event::Complete::Error
|
|
@@ -143,7 +140,7 @@ module Punchblock
|
|
|
143
140
|
end
|
|
144
141
|
|
|
145
142
|
it 'should send a complete event when the files finish playback' do
|
|
146
|
-
expect_playback([audio_filename1, audio_filename2].join('!'))
|
|
143
|
+
expect_playback([audio_filename1, audio_filename2].join('!'))
|
|
147
144
|
subject.execute
|
|
148
145
|
subject.handle_es_event RubyFS::Event.new(nil, :event_name => "CHANNEL_EXECUTE_COMPLETE", :application_response => "FILE PLAYED")
|
|
149
146
|
original_command.complete_event(0.1).reason.should be_a Punchblock::Component::Output::Complete::Success
|
|
@@ -342,13 +339,13 @@ module Punchblock
|
|
|
342
339
|
end
|
|
343
340
|
|
|
344
341
|
it "sets the command response to true" do
|
|
345
|
-
subject.wrapped_object.
|
|
342
|
+
subject.wrapped_object.should_receive(:application)
|
|
346
343
|
subject.execute_command command
|
|
347
344
|
command.response(0.1).should be == true
|
|
348
345
|
end
|
|
349
346
|
|
|
350
347
|
it "sends the correct complete event" do
|
|
351
|
-
subject.wrapped_object.
|
|
348
|
+
subject.wrapped_object.should_receive(:application)
|
|
352
349
|
original_command.should_not be_complete
|
|
353
350
|
subject.execute_command command
|
|
354
351
|
reason.should be_a Punchblock::Event::Complete::Stop
|
|
@@ -356,7 +353,7 @@ module Punchblock
|
|
|
356
353
|
end
|
|
357
354
|
|
|
358
355
|
it "breaks the current dialplan application" do
|
|
359
|
-
subject.wrapped_object.
|
|
356
|
+
subject.wrapped_object.should_receive(:application).once.with 'break'
|
|
360
357
|
subject.execute_command command
|
|
361
358
|
end
|
|
362
359
|
end
|
|
@@ -7,11 +7,8 @@ module Punchblock
|
|
|
7
7
|
class Freeswitch
|
|
8
8
|
module Component
|
|
9
9
|
describe Record do
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
original_command.add_event event
|
|
13
|
-
end
|
|
14
|
-
end
|
|
10
|
+
include HasMockCallbackConnection
|
|
11
|
+
|
|
15
12
|
let(:id) { Punchblock.new_uuid }
|
|
16
13
|
let(:translator) { Punchblock::Translator::Freeswitch.new connection }
|
|
17
14
|
let(:mock_stream) { mock('RubyFS::Stream') }
|
|
@@ -25,7 +22,7 @@ module Punchblock
|
|
|
25
22
|
{}
|
|
26
23
|
end
|
|
27
24
|
|
|
28
|
-
before { mock_stream.
|
|
25
|
+
before { mock_stream.as_null_object }
|
|
29
26
|
|
|
30
27
|
subject { Record.new original_command, mock_call }
|
|
31
28
|
|
|
@@ -44,7 +41,7 @@ module Punchblock
|
|
|
44
41
|
end
|
|
45
42
|
|
|
46
43
|
it "starts a recording via uuid_record, using the component ID as the filename" do
|
|
47
|
-
mock_call.
|
|
44
|
+
mock_call.should_receive(:uuid_foo).once.with(:record, "start #{filename}")
|
|
48
45
|
subject.execute
|
|
49
46
|
end
|
|
50
47
|
|
|
@@ -65,7 +62,7 @@ module Punchblock
|
|
|
65
62
|
context "set to nil" do
|
|
66
63
|
let(:command_options) { { :start_paused => nil } }
|
|
67
64
|
it "should execute normally" do
|
|
68
|
-
mock_call.
|
|
65
|
+
mock_call.should_receive(:uuid_foo).once
|
|
69
66
|
subject.execute
|
|
70
67
|
original_command.response(0.1).should be_a Ref
|
|
71
68
|
end
|
|
@@ -74,7 +71,7 @@ module Punchblock
|
|
|
74
71
|
context "set to false" do
|
|
75
72
|
let(:command_options) { { :start_paused => false } }
|
|
76
73
|
it "should execute normally" do
|
|
77
|
-
mock_call.
|
|
74
|
+
mock_call.should_receive(:uuid_foo).once
|
|
78
75
|
subject.execute
|
|
79
76
|
original_command.response(0.1).should be_a Ref
|
|
80
77
|
end
|
|
@@ -83,7 +80,7 @@ module Punchblock
|
|
|
83
80
|
context "set to true" do
|
|
84
81
|
let(:command_options) { { :start_paused => true } }
|
|
85
82
|
it "should return an error and not execute any actions" do
|
|
86
|
-
mock_call.
|
|
83
|
+
mock_call.should_receive(:uuid_foo).never
|
|
87
84
|
subject.execute
|
|
88
85
|
error = ProtocolError.new.setup 'option error', 'A start-paused value of true is unsupported.'
|
|
89
86
|
original_command.response(0.1).should be == error
|
|
@@ -95,7 +92,7 @@ module Punchblock
|
|
|
95
92
|
context "set to nil" do
|
|
96
93
|
let(:command_options) { { :initial_timeout => nil } }
|
|
97
94
|
it "should execute normally" do
|
|
98
|
-
mock_call.
|
|
95
|
+
mock_call.should_receive(:uuid_foo).once
|
|
99
96
|
subject.execute
|
|
100
97
|
original_command.response(0.1).should be_a Ref
|
|
101
98
|
end
|
|
@@ -104,7 +101,7 @@ module Punchblock
|
|
|
104
101
|
context "set to -1" do
|
|
105
102
|
let(:command_options) { { :initial_timeout => -1 } }
|
|
106
103
|
it "should execute normally" do
|
|
107
|
-
mock_call.
|
|
104
|
+
mock_call.should_receive(:uuid_foo).once
|
|
108
105
|
subject.execute
|
|
109
106
|
original_command.response(0.1).should be_a Ref
|
|
110
107
|
end
|
|
@@ -113,7 +110,7 @@ module Punchblock
|
|
|
113
110
|
context "set to a positive number" do
|
|
114
111
|
let(:command_options) { { :initial_timeout => 10 } }
|
|
115
112
|
it "should return an error and not execute any actions" do
|
|
116
|
-
mock_call.
|
|
113
|
+
mock_call.should_receive(:uuid_foo).never
|
|
117
114
|
subject.execute
|
|
118
115
|
error = ProtocolError.new.setup 'option error', 'An initial-timeout value is unsupported.'
|
|
119
116
|
original_command.response(0.1).should be == error
|
|
@@ -125,7 +122,7 @@ module Punchblock
|
|
|
125
122
|
context "set to nil" do
|
|
126
123
|
let(:command_options) { { :final_timeout => nil } }
|
|
127
124
|
it "should execute normally" do
|
|
128
|
-
mock_call.
|
|
125
|
+
mock_call.should_receive(:uuid_foo).once
|
|
129
126
|
subject.execute
|
|
130
127
|
original_command.response(0.1).should be_a Ref
|
|
131
128
|
end
|
|
@@ -134,7 +131,7 @@ module Punchblock
|
|
|
134
131
|
context "set to -1" do
|
|
135
132
|
let(:command_options) { { :final_timeout => -1 } }
|
|
136
133
|
it "should execute normally" do
|
|
137
|
-
mock_call.
|
|
134
|
+
mock_call.should_receive(:uuid_foo).once
|
|
138
135
|
subject.execute
|
|
139
136
|
original_command.response(0.1).should be_a Ref
|
|
140
137
|
end
|
|
@@ -143,7 +140,7 @@ module Punchblock
|
|
|
143
140
|
context "set to a positive number" do
|
|
144
141
|
let(:command_options) { { :final_timeout => 10 } }
|
|
145
142
|
it "should return an error and not execute any actions" do
|
|
146
|
-
mock_call.
|
|
143
|
+
mock_call.should_receive(:send_agi_action!).never
|
|
147
144
|
subject.execute
|
|
148
145
|
error = ProtocolError.new.setup 'option error', 'A final-timeout value is unsupported.'
|
|
149
146
|
original_command.response(0.1).should be == error
|
|
@@ -155,13 +152,13 @@ module Punchblock
|
|
|
155
152
|
context "set to nil" do
|
|
156
153
|
let(:command_options) { { :format => nil } }
|
|
157
154
|
it "should execute as 'wav'" do
|
|
158
|
-
mock_call.
|
|
155
|
+
mock_call.should_receive(:uuid_foo).once.with(:record, /.wav/)
|
|
159
156
|
subject.execute
|
|
160
157
|
original_command.response(0.1).should be_a Ref
|
|
161
158
|
end
|
|
162
159
|
|
|
163
160
|
it "provides the correct filename in the recording" do
|
|
164
|
-
mock_call.
|
|
161
|
+
mock_call.should_receive(:uuid_foo)
|
|
165
162
|
subject.execute
|
|
166
163
|
record_stop_event = RubyFS::Event.new nil, {
|
|
167
164
|
:event_name => 'RECORD_STOP',
|
|
@@ -175,13 +172,13 @@ module Punchblock
|
|
|
175
172
|
context "set to 'mp3'" do
|
|
176
173
|
let(:command_options) { { :format => 'mp3' } }
|
|
177
174
|
it "should execute as 'mp3'" do
|
|
178
|
-
mock_call.
|
|
175
|
+
mock_call.should_receive(:uuid_foo).once.with(:record, /.mp3/)
|
|
179
176
|
subject.execute
|
|
180
177
|
original_command.response(0.1).should be_a Ref
|
|
181
178
|
end
|
|
182
179
|
|
|
183
180
|
it "provides the correct filename in the recording" do
|
|
184
|
-
mock_call.
|
|
181
|
+
mock_call.should_receive(:uuid_foo)
|
|
185
182
|
subject.execute
|
|
186
183
|
record_stop_event = RubyFS::Event.new nil, {
|
|
187
184
|
:event_name => 'RECORD_STOP',
|
|
@@ -197,7 +194,7 @@ module Punchblock
|
|
|
197
194
|
context "set to nil" do
|
|
198
195
|
let(:command_options) { { :start_beep => nil } }
|
|
199
196
|
it "should execute normally" do
|
|
200
|
-
mock_call.
|
|
197
|
+
mock_call.should_receive(:uuid_foo).once
|
|
201
198
|
subject.execute
|
|
202
199
|
original_command.response(0.1).should be_a Ref
|
|
203
200
|
end
|
|
@@ -206,7 +203,7 @@ module Punchblock
|
|
|
206
203
|
context "set to false" do
|
|
207
204
|
let(:command_options) { { :start_beep => false } }
|
|
208
205
|
it "should execute normally" do
|
|
209
|
-
mock_call.
|
|
206
|
+
mock_call.should_receive(:uuid_foo).once
|
|
210
207
|
subject.execute
|
|
211
208
|
original_command.response(0.1).should be_a Ref
|
|
212
209
|
end
|
|
@@ -216,7 +213,7 @@ module Punchblock
|
|
|
216
213
|
let(:command_options) { { :start_beep => true } }
|
|
217
214
|
|
|
218
215
|
it "should return an error and not execute any actions" do
|
|
219
|
-
mock_call.
|
|
216
|
+
mock_call.should_receive(:uuid_foo).never
|
|
220
217
|
subject.execute
|
|
221
218
|
error = ProtocolError.new.setup 'option error', 'A start-beep value of true is unsupported.'
|
|
222
219
|
original_command.response(0.1).should be == error
|
|
@@ -228,7 +225,7 @@ module Punchblock
|
|
|
228
225
|
context "set to nil" do
|
|
229
226
|
let(:command_options) { { :max_duration => nil } }
|
|
230
227
|
it "should execute normally" do
|
|
231
|
-
mock_call.
|
|
228
|
+
mock_call.should_receive(:uuid_foo).once.with(:record, /.wav$/)
|
|
232
229
|
subject.execute
|
|
233
230
|
original_command.response(0.1).should be_a Ref
|
|
234
231
|
end
|
|
@@ -237,7 +234,7 @@ module Punchblock
|
|
|
237
234
|
context "set to -1" do
|
|
238
235
|
let(:command_options) { { :max_duration => -1 } }
|
|
239
236
|
it "should execute normally" do
|
|
240
|
-
mock_call.
|
|
237
|
+
mock_call.should_receive(:uuid_foo).once.with(:record, /.wav$/)
|
|
241
238
|
subject.execute
|
|
242
239
|
original_command.response(0.1).should be_a Ref
|
|
243
240
|
end
|
|
@@ -259,7 +256,7 @@ module Punchblock
|
|
|
259
256
|
let(:command_options) { { :max_duration => 1000 } }
|
|
260
257
|
|
|
261
258
|
it "executes the recording with a time limit" do
|
|
262
|
-
mock_call.
|
|
259
|
+
mock_call.should_receive(:uuid_foo).once.with(:record, /.wav 1$/)
|
|
263
260
|
subject.execute
|
|
264
261
|
original_command.response(0.1).should be_a Ref
|
|
265
262
|
end
|
|
@@ -285,7 +282,7 @@ module Punchblock
|
|
|
285
282
|
let(:command) { Punchblock::Component::Stop.new }
|
|
286
283
|
|
|
287
284
|
before do
|
|
288
|
-
mock_call.
|
|
285
|
+
mock_call.should_receive :uuid_foo
|
|
289
286
|
command.request!
|
|
290
287
|
original_command.request!
|
|
291
288
|
subject.execute
|
|
@@ -300,19 +297,19 @@ module Punchblock
|
|
|
300
297
|
end
|
|
301
298
|
|
|
302
299
|
it "sets the command response to true" do
|
|
303
|
-
mock_call.
|
|
300
|
+
mock_call.should_receive :uuid_foo
|
|
304
301
|
subject.execute_command command
|
|
305
302
|
send_stop_event
|
|
306
303
|
command.response(0.1).should be == true
|
|
307
304
|
end
|
|
308
305
|
|
|
309
306
|
it "executes a uuid_record stop command" do
|
|
310
|
-
mock_call.
|
|
307
|
+
mock_call.should_receive(:uuid_foo).with(:record, "stop #{filename}")
|
|
311
308
|
subject.execute_command command
|
|
312
309
|
end
|
|
313
310
|
|
|
314
311
|
it "sends the correct complete event" do
|
|
315
|
-
mock_call.
|
|
312
|
+
mock_call.should_receive(:uuid_foo).with(:record, "stop #{filename}")
|
|
316
313
|
subject.execute_command command
|
|
317
314
|
send_stop_event
|
|
318
315
|
reason.should be_a Punchblock::Event::Complete::Stop
|
|
@@ -326,7 +323,7 @@ module Punchblock
|
|
|
326
323
|
|
|
327
324
|
before do
|
|
328
325
|
pending
|
|
329
|
-
mock_call.
|
|
326
|
+
mock_call.should_receive :uuid_foo
|
|
330
327
|
command.request!
|
|
331
328
|
original_command.request!
|
|
332
329
|
subject.execute
|
|
@@ -338,7 +335,7 @@ module Punchblock
|
|
|
338
335
|
end
|
|
339
336
|
|
|
340
337
|
it "pauses the recording via AMI" do
|
|
341
|
-
mock_call.
|
|
338
|
+
mock_call.should_receive(:uuid_foo).once.with('PauseMonitor', 'Channel' => channel)
|
|
342
339
|
subject.execute_command command
|
|
343
340
|
end
|
|
344
341
|
end
|
|
@@ -348,7 +345,7 @@ module Punchblock
|
|
|
348
345
|
|
|
349
346
|
before do
|
|
350
347
|
pending
|
|
351
|
-
mock_call.
|
|
348
|
+
mock_call.should_receive :uuid_foo
|
|
352
349
|
command.request!
|
|
353
350
|
original_command.request!
|
|
354
351
|
subject.execute
|
|
@@ -360,7 +357,7 @@ module Punchblock
|
|
|
360
357
|
end
|
|
361
358
|
|
|
362
359
|
it "resumes the recording via AMI" do
|
|
363
|
-
mock_call.
|
|
360
|
+
mock_call.should_receive(:uuid_foo).once.with('ResumeMonitor', 'Channel' => channel)
|
|
364
361
|
subject.execute_command command
|
|
365
362
|
end
|
|
366
363
|
end
|
|
@@ -7,11 +7,8 @@ module Punchblock
|
|
|
7
7
|
class Freeswitch
|
|
8
8
|
module Component
|
|
9
9
|
describe TTSOutput do
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
original_command.add_event event
|
|
13
|
-
end
|
|
14
|
-
end
|
|
10
|
+
include HasMockCallbackConnection
|
|
11
|
+
|
|
15
12
|
let(:media_engine) { :flite }
|
|
16
13
|
let(:default_voice) { :hal }
|
|
17
14
|
let(:translator) { Punchblock::Translator::Freeswitch.new connection }
|
|
@@ -40,7 +37,7 @@ module Punchblock
|
|
|
40
37
|
describe '#execute' do
|
|
41
38
|
before { original_command.request! }
|
|
42
39
|
def expect_playback(voice = default_voice)
|
|
43
|
-
subject.wrapped_object.
|
|
40
|
+
subject.wrapped_object.should_receive(:application).once.with :speak, "#{media_engine}|#{voice}|#{ssml_doc}"
|
|
44
41
|
end
|
|
45
42
|
|
|
46
43
|
let :ssml_doc do
|
|
@@ -76,7 +73,7 @@ module Punchblock
|
|
|
76
73
|
end
|
|
77
74
|
|
|
78
75
|
it 'should send a complete event when the speak finishes' do
|
|
79
|
-
expect_playback
|
|
76
|
+
expect_playback
|
|
80
77
|
execute
|
|
81
78
|
subject.handle_es_event RubyFS::Event.new(nil, :event_name => "CHANNEL_EXECUTE_COMPLETE")
|
|
82
79
|
original_command.complete_event(0.1).reason.should be_a Punchblock::Component::Output::Complete::Success
|
|
@@ -258,13 +255,13 @@ module Punchblock
|
|
|
258
255
|
end
|
|
259
256
|
|
|
260
257
|
it "sets the command response to true" do
|
|
261
|
-
subject.wrapped_object.
|
|
258
|
+
subject.wrapped_object.should_receive(:application)
|
|
262
259
|
subject.execute_command command
|
|
263
260
|
command.response(0.1).should be == true
|
|
264
261
|
end
|
|
265
262
|
|
|
266
263
|
it "sends the correct complete event" do
|
|
267
|
-
subject.wrapped_object.
|
|
264
|
+
subject.wrapped_object.should_receive(:application)
|
|
268
265
|
original_command.should_not be_complete
|
|
269
266
|
subject.execute_command command
|
|
270
267
|
reason.should be_a Punchblock::Event::Complete::Stop
|
|
@@ -272,7 +269,7 @@ module Punchblock
|
|
|
272
269
|
end
|
|
273
270
|
|
|
274
271
|
it "breaks the current dialplan application" do
|
|
275
|
-
subject.wrapped_object.
|
|
272
|
+
subject.wrapped_object.should_receive(:application).once.with 'break'
|
|
276
273
|
subject.execute_command command
|
|
277
274
|
end
|
|
278
275
|
end
|
|
@@ -29,7 +29,7 @@ module Punchblock
|
|
|
29
29
|
let(:response) { mock 'Response' }
|
|
30
30
|
|
|
31
31
|
it 'should execute the handler' do
|
|
32
|
-
response.
|
|
32
|
+
response.should_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
|
|
@@ -53,7 +53,7 @@ module Punchblock
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it "should send the event to the connection" do
|
|
56
|
-
connection.
|
|
56
|
+
connection.should_receive(:handle_event).once.with expected_event
|
|
57
57
|
subject.send_event event
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -69,12 +69,12 @@ module Punchblock
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it "should send a complete event with the specified reason" do
|
|
72
|
-
subject.wrapped_object.
|
|
72
|
+
subject.wrapped_object.should_receive(:send_event).once.with expected_event
|
|
73
73
|
subject.send_complete_event reason
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it "should cause the actor to be shut down" do
|
|
77
|
-
subject.wrapped_object.
|
|
77
|
+
subject.wrapped_object.stub(:send_event).and_return true
|
|
78
78
|
subject.send_complete_event reason
|
|
79
79
|
sleep 0.2
|
|
80
80
|
subject.should_not be_alive
|
|
@@ -83,14 +83,14 @@ module Punchblock
|
|
|
83
83
|
|
|
84
84
|
describe "#call_ended" do
|
|
85
85
|
it "should send a complete event with the call hangup reason" do
|
|
86
|
-
subject.wrapped_object.
|
|
86
|
+
subject.wrapped_object.should_receive(:send_complete_event).once.with Punchblock::Event::Complete::Hangup.new
|
|
87
87
|
subject.call_ended
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
describe "#application" do
|
|
92
92
|
it "should execute a FS application on the current call" do
|
|
93
|
-
call.
|
|
93
|
+
call.should_receive(:application).once.with('appname', "%[punchblock_component_id=#{subject.id}]options")
|
|
94
94
|
subject.application 'appname', 'options'
|
|
95
95
|
end
|
|
96
96
|
end
|