punchblock 2.5.2 → 2.5.3
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -32,7 +32,7 @@ module Punchblock
|
|
32
32
|
before { original_command.request! }
|
33
33
|
|
34
34
|
it 'should send the appropriate action' do
|
35
|
-
ami_client.
|
35
|
+
expect(ami_client).to receive(:send_action).once.with('AGI', 'Channel' => channel, 'Command' => 'EXEC ANSWER', 'CommandID' => component_id).and_return(response)
|
36
36
|
subject.execute
|
37
37
|
end
|
38
38
|
|
@@ -44,7 +44,7 @@ module Punchblock
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'should send the appropriate action' do
|
47
|
-
ami_client.
|
47
|
+
expect(ami_client).to receive(:send_action).once.with('AGI', 'Channel' => channel, 'Command' => 'WAIT FOR DIGIT "1000" "foo"', 'CommandID' => component_id).and_return(response)
|
48
48
|
subject.execute
|
49
49
|
end
|
50
50
|
end
|
@@ -65,9 +65,9 @@ module Punchblock
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'should send the component node a ref with the action ID' do
|
68
|
-
ami_client.
|
68
|
+
expect(ami_client).to receive(:send_action).once.and_return response
|
69
69
|
subject.execute
|
70
|
-
original_command.response(1).
|
70
|
+
expect(original_command.response(1)).to eq(expected_response)
|
71
71
|
end
|
72
72
|
|
73
73
|
context 'with an error' do
|
@@ -76,11 +76,11 @@ module Punchblock
|
|
76
76
|
RubyAMI::Error.new.tap { |e| e.message = message }
|
77
77
|
end
|
78
78
|
|
79
|
-
before { ami_client.
|
79
|
+
before { expect(ami_client).to receive(:send_action).once.and_raise response }
|
80
80
|
|
81
81
|
it 'should send the component node false' do
|
82
82
|
subject.execute
|
83
|
-
original_command.response(1).
|
83
|
+
expect(original_command.response(1)).to be_false
|
84
84
|
end
|
85
85
|
|
86
86
|
context "which is 'No such channel'" do
|
@@ -88,7 +88,7 @@ module Punchblock
|
|
88
88
|
|
89
89
|
it "should return an :item_not_found error for the command" do
|
90
90
|
subject.execute
|
91
|
-
original_command.response(0.5).
|
91
|
+
expect(original_command.response(0.5)).to eq(ProtocolError.new.setup(:item_not_found, "Could not find a call with ID #{mock_call.id}", mock_call.id))
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -97,7 +97,7 @@ module Punchblock
|
|
97
97
|
|
98
98
|
it "should return an :item_not_found error for the command" do
|
99
99
|
subject.execute
|
100
|
-
original_command.response(0.5).
|
100
|
+
expect(original_command.response(0.5)).to eq(ProtocolError.new.setup(:item_not_found, "Could not find a call with ID #{mock_call.id}", mock_call.id))
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
@@ -132,10 +132,10 @@ module Punchblock
|
|
132
132
|
|
133
133
|
complete_event = original_command.complete_event 0.5
|
134
134
|
|
135
|
-
original_command.
|
135
|
+
expect(original_command).to be_complete
|
136
136
|
|
137
|
-
complete_event.component_id.
|
138
|
-
complete_event.reason.
|
137
|
+
expect(complete_event.component_id).to eq(component_id.to_s)
|
138
|
+
expect(complete_event.reason).to eq(expected_complete_reason)
|
139
139
|
end
|
140
140
|
|
141
141
|
context "when the command was ASYNCAGI BREAK" do
|
@@ -147,12 +147,12 @@ module Punchblock
|
|
147
147
|
|
148
148
|
before do
|
149
149
|
response = RubyAMI::Response.new 'Value' => chan_var
|
150
|
-
ami_client.
|
150
|
+
expect(ami_client).to receive(:send_action).once.with('GetVar', 'Channel' => channel, 'Variable' => 'PUNCHBLOCK_END_ON_ASYNCAGI_BREAK').and_return response
|
151
151
|
end
|
152
152
|
|
153
153
|
it 'should not send an end (hangup) event to the translator' do
|
154
|
-
translator.
|
155
|
-
translator.
|
154
|
+
expect(translator).to receive(:handle_pb_event).once.with kind_of(Punchblock::Event::Complete)
|
155
|
+
expect(translator).to receive(:handle_pb_event).never.with kind_of(Punchblock::Event::End)
|
156
156
|
subject.handle_ami_event ami_event
|
157
157
|
end
|
158
158
|
|
@@ -164,8 +164,8 @@ module Punchblock
|
|
164
164
|
platform_code: 16,
|
165
165
|
target_call_id: mock_call.id
|
166
166
|
|
167
|
-
translator.
|
168
|
-
translator.
|
167
|
+
expect(translator).to receive(:handle_pb_event).once.with kind_of(Punchblock::Event::Complete)
|
168
|
+
expect(translator).to receive(:handle_pb_event).once.with expected_end_event
|
169
169
|
subject.handle_ami_event ami_event
|
170
170
|
end
|
171
171
|
|
@@ -185,8 +185,8 @@ module Punchblock
|
|
185
185
|
platform_code: 16,
|
186
186
|
target_call_id: mock_call.id,
|
187
187
|
timestamp: DateTime.new(2014, 2, 25, 22, 46, 20)
|
188
|
-
translator.
|
189
|
-
translator.
|
188
|
+
expect(translator).to receive(:handle_pb_event).once.with kind_of(Punchblock::Event::Complete)
|
189
|
+
expect(translator).to receive(:handle_pb_event).once.with expected_end_event
|
190
190
|
|
191
191
|
subject.handle_ami_event ami_event
|
192
192
|
end
|
@@ -33,9 +33,9 @@ module Punchblock
|
|
33
33
|
before { stub_uuids component_id }
|
34
34
|
|
35
35
|
it 'should send the appropriate RubyAMI::Action and send the component node a ref' do
|
36
|
-
ami_client.
|
36
|
+
expect(ami_client).to receive(:send_action).once.with('ExtensionStatus', 'Context' => 'default', 'Exten' => 'idonno').and_return(RubyAMI::Response.new)
|
37
37
|
subject.execute
|
38
|
-
original_command.response(1).
|
38
|
+
expect(original_command.response(1)).to eq(expected_response)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -57,8 +57,8 @@ module Punchblock
|
|
57
57
|
|
58
58
|
context 'for a non-causal action' do
|
59
59
|
it 'should send a complete event to the component node' do
|
60
|
-
ami_client.
|
61
|
-
subject.
|
60
|
+
expect(ami_client).to receive(:send_action).once.and_return response
|
61
|
+
expect(subject).to receive(:send_complete_event).once.with expected_complete_reason
|
62
62
|
subject.execute
|
63
63
|
end
|
64
64
|
end
|
@@ -105,7 +105,7 @@ module Punchblock
|
|
105
105
|
Punchblock::Component::Asterisk::AMI::Action::Complete::Success.new message: 'Channel status will follow', text_body: 'Some text body', headers: {'Exten' => "idonno", 'Context' => "default", 'Hint' => "", 'Status' => "-1", 'EventList' => 'Complete', 'ListItems' => '3'}
|
106
106
|
end
|
107
107
|
|
108
|
-
before { ami_client.
|
108
|
+
before { expect(ami_client).to receive(:send_action).once.and_return response }
|
109
109
|
|
110
110
|
it 'should send events to the component node' do
|
111
111
|
event_node
|
@@ -114,7 +114,7 @@ module Punchblock
|
|
114
114
|
end
|
115
115
|
response.events << event << terminating_event
|
116
116
|
subject.execute
|
117
|
-
@event.
|
117
|
+
expect(@event).to eq(event_node)
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'should send a complete event to the component node' do
|
@@ -122,7 +122,7 @@ module Punchblock
|
|
122
122
|
|
123
123
|
subject.execute
|
124
124
|
|
125
|
-
original_command.complete_event(0.5).reason.
|
125
|
+
expect(original_command.complete_event(0.5).reason).to eq(expected_complete_reason)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -136,10 +136,10 @@ module Punchblock
|
|
136
136
|
end
|
137
137
|
|
138
138
|
it 'should send a complete event to the component node' do
|
139
|
-
ami_client.
|
139
|
+
expect(ami_client).to receive(:send_action).once.and_raise error
|
140
140
|
expected_complete_reason
|
141
141
|
subject.execute
|
142
|
-
original_command.complete_event(0.5).reason.
|
142
|
+
expect(original_command.complete_event(0.5).reason).to eq(expected_complete_reason)
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
@@ -72,7 +72,7 @@ module Punchblock
|
|
72
72
|
|
73
73
|
before do
|
74
74
|
call.stub answered?: true, execute_agi_command: true
|
75
|
-
call.
|
75
|
+
allow(call).to receive(:channel_var).with('PLAYBACKSTATUS').and_return playbackstatus
|
76
76
|
original_command.request!
|
77
77
|
end
|
78
78
|
|
@@ -92,9 +92,9 @@ module Punchblock
|
|
92
92
|
context '#barge_in' do
|
93
93
|
context 'true' do
|
94
94
|
it "should execute an output component on the call and return a ref" do
|
95
|
-
call.
|
95
|
+
expect(call).to receive(:execute_agi_command).once.with('EXEC Playback', 'tt-monkeys')
|
96
96
|
subject.execute
|
97
|
-
original_command.response(0.1).
|
97
|
+
expect(original_command.response(0.1)).to be_a Ref
|
98
98
|
end
|
99
99
|
|
100
100
|
context "if output fails to start" do
|
@@ -116,9 +116,9 @@ module Punchblock
|
|
116
116
|
|
117
117
|
context 'false' do
|
118
118
|
it "should execute an output component on the call" do
|
119
|
-
call.
|
119
|
+
expect(call).to receive(:execute_agi_command).once.with('EXEC Playback', 'tt-monkeys')
|
120
120
|
subject.execute
|
121
|
-
original_command.response(0.1).
|
121
|
+
expect(original_command.response(0.1)).to be_a Ref
|
122
122
|
end
|
123
123
|
|
124
124
|
context "if output fails to start" do
|
@@ -132,7 +132,7 @@ module Punchblock
|
|
132
132
|
|
133
133
|
it "should return the error returned by output" do
|
134
134
|
subject.execute
|
135
|
-
original_command.response(0.1).
|
135
|
+
expect(original_command.response(0.1)).to eq(output_response)
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -166,10 +166,10 @@ module Punchblock
|
|
166
166
|
it "should return a match complete event" do
|
167
167
|
expected_event
|
168
168
|
subject.execute
|
169
|
-
original_command.response(0.1).
|
169
|
+
expect(original_command.response(0.1)).to be_a Ref
|
170
170
|
send_ami_events_for_dtmf 1
|
171
171
|
|
172
|
-
connection.events.
|
172
|
+
expect(connection.events).to include(expected_event)
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
@@ -187,7 +187,7 @@ module Punchblock
|
|
187
187
|
before { command.request! }
|
188
188
|
it "returns a ProtocolError response" do
|
189
189
|
subject.execute_command command
|
190
|
-
command.response(0.1).
|
190
|
+
expect(command.response(0.1)).to be_a ProtocolError
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
@@ -207,9 +207,9 @@ module Punchblock
|
|
207
207
|
end
|
208
208
|
|
209
209
|
it "sets the command response to true" do
|
210
|
-
call.
|
210
|
+
expect(call).to receive(:redirect_back).once
|
211
211
|
subject.execute_command command
|
212
|
-
command.response(0.1).
|
212
|
+
expect(command.response(0.1)).to eq(true)
|
213
213
|
end
|
214
214
|
|
215
215
|
it "sends the correct complete event" do
|
@@ -219,14 +219,14 @@ module Punchblock
|
|
219
219
|
source_uri: subject.id,
|
220
220
|
target_call_id: call.id
|
221
221
|
|
222
|
-
call.
|
222
|
+
expect(call).to receive(:redirect_back)
|
223
223
|
subject.execute_command command
|
224
|
-
original_command.
|
224
|
+
expect(original_command).not_to be_complete
|
225
225
|
call.process_ami_event ami_event
|
226
226
|
|
227
227
|
sleep 0.2
|
228
228
|
|
229
|
-
connection.events.
|
229
|
+
expect(connection.events).to include(expected_event)
|
230
230
|
end
|
231
231
|
end
|
232
232
|
end
|
@@ -40,11 +40,11 @@ module Punchblock
|
|
40
40
|
before { original_command.request! }
|
41
41
|
|
42
42
|
it "calls send_progress on the call" do
|
43
|
-
call.
|
43
|
+
expect(call).to receive(:send_progress)
|
44
44
|
subject.execute
|
45
45
|
end
|
46
46
|
|
47
|
-
before { call.
|
47
|
+
before { allow(call).to receive :send_progress }
|
48
48
|
|
49
49
|
let(:original_command_opts) { {} }
|
50
50
|
|
@@ -92,16 +92,16 @@ module Punchblock
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should send a success complete event with the relevant data" do
|
95
|
-
reason.
|
95
|
+
expect(reason).to eq(expected_event)
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should not process further dtmf events" do
|
99
|
-
subject.
|
99
|
+
expect(subject).to receive(:process_dtmf).never
|
100
100
|
send_ami_events_for_dtmf 3
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should not leave the recognizer running" do
|
104
|
-
Celluloid::Actor.all.map { |a| a.class }.
|
104
|
+
expect(Celluloid::Actor.all.map { |a| a.class }).not_to include(Punchblock::Translator::DTMFRecognizer)
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -116,7 +116,28 @@ module Punchblock
|
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should send a nomatch complete event" do
|
119
|
-
reason.
|
119
|
+
expect(reason).to eq(expected_event)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "dtmf event received after recognizer has terminated" do
|
124
|
+
before do
|
125
|
+
send_ami_events_for_dtmf 1
|
126
|
+
send_ami_events_for_dtmf '#'
|
127
|
+
subject.execute
|
128
|
+
end
|
129
|
+
|
130
|
+
let :expected_event do
|
131
|
+
Punchblock::Component::Input::Complete::NoMatch.new
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should not crash the translator if the recognizer is dead" do
|
135
|
+
expect(Celluloid::Actor.all.map { |a| a.class }).to include(Punchblock::Translator::DTMFRecognizer)
|
136
|
+
recognizer = Celluloid::Actor.all.find { |a| a.class == Punchblock::Translator::DTMFRecognizer }
|
137
|
+
recognizer.terminate if recognizer
|
138
|
+
expect(Celluloid::Actor.all.map { |a| a.class }).not_to include(Punchblock::Translator::DTMFRecognizer)
|
139
|
+
subject.process_dtmf 1 # trigger failure
|
140
|
+
expect(Celluloid::Actor.all.map { |a| a.class }).to include(translator.class)
|
120
141
|
end
|
121
142
|
end
|
122
143
|
end
|
@@ -127,7 +148,7 @@ module Punchblock
|
|
127
148
|
it "should return an error and not execute any actions" do
|
128
149
|
subject.execute
|
129
150
|
error = ProtocolError.new.setup 'option error', 'A grammar document is required.'
|
130
|
-
original_command.response(0.1).
|
151
|
+
expect(original_command.response(0.1)).to eq(error)
|
131
152
|
end
|
132
153
|
end
|
133
154
|
|
@@ -154,7 +175,7 @@ module Punchblock
|
|
154
175
|
end
|
155
176
|
|
156
177
|
it "should use RubySpeech builtin grammar" do
|
157
|
-
reason.
|
178
|
+
expect(reason).to eq(expected_event)
|
158
179
|
end
|
159
180
|
end
|
160
181
|
|
@@ -181,7 +202,7 @@ module Punchblock
|
|
181
202
|
end
|
182
203
|
|
183
204
|
it "should use RubySpeech builtin grammar" do
|
184
|
-
reason.
|
205
|
+
expect(reason).to eq(expected_event)
|
185
206
|
end
|
186
207
|
end
|
187
208
|
|
@@ -190,7 +211,7 @@ module Punchblock
|
|
190
211
|
it "should return an error and not execute any actions" do
|
191
212
|
subject.execute
|
192
213
|
error = ProtocolError.new.setup 'option error', 'Only a single grammar is supported.'
|
193
|
-
original_command.response(0.1).
|
214
|
+
expect(original_command.response(0.1)).to eq(error)
|
194
215
|
end
|
195
216
|
end
|
196
217
|
end
|
@@ -201,7 +222,7 @@ module Punchblock
|
|
201
222
|
it "should return an error and not execute any actions" do
|
202
223
|
subject.execute
|
203
224
|
error = ProtocolError.new.setup 'option error', 'A mode value other than DTMF is unsupported.'
|
204
|
-
original_command.response(0.1).
|
225
|
+
expect(original_command.response(0.1)).to eq(error)
|
205
226
|
end
|
206
227
|
end
|
207
228
|
|
@@ -210,7 +231,7 @@ module Punchblock
|
|
210
231
|
it "should return an error and not execute any actions" do
|
211
232
|
subject.execute
|
212
233
|
error = ProtocolError.new.setup 'option error', 'A mode value other than DTMF is unsupported.'
|
213
|
-
original_command.response(0.1).
|
234
|
+
expect(original_command.response(0.1)).to eq(error)
|
214
235
|
end
|
215
236
|
end
|
216
237
|
|
@@ -219,7 +240,7 @@ module Punchblock
|
|
219
240
|
it "should return an error and not execute any actions" do
|
220
241
|
subject.execute
|
221
242
|
error = ProtocolError.new.setup 'option error', 'A mode value other than DTMF is unsupported.'
|
222
|
-
original_command.response(0.1).
|
243
|
+
expect(original_command.response(0.1)).to eq(error)
|
223
244
|
end
|
224
245
|
end
|
225
246
|
end
|
@@ -266,11 +287,11 @@ module Punchblock
|
|
266
287
|
end
|
267
288
|
|
268
289
|
it "should send a match complete event with the relevant data" do
|
269
|
-
reason.
|
290
|
+
expect(reason).to eq(expected_event)
|
270
291
|
end
|
271
292
|
|
272
293
|
it "should not process further dtmf events" do
|
273
|
-
subject.
|
294
|
+
expect(subject).to receive(:process_dtmf).never
|
274
295
|
send_ami_events_for_dtmf 3
|
275
296
|
end
|
276
297
|
end
|
@@ -285,7 +306,7 @@ module Punchblock
|
|
285
306
|
end
|
286
307
|
|
287
308
|
it "should send a nomatch complete event with the relevant data" do
|
288
|
-
reason.
|
309
|
+
expect(reason).to eq(expected_event)
|
289
310
|
end
|
290
311
|
end
|
291
312
|
|
@@ -300,7 +321,7 @@ module Punchblock
|
|
300
321
|
end
|
301
322
|
|
302
323
|
it "should send a nomatch complete event with the relevant data" do
|
303
|
-
reason.
|
324
|
+
expect(reason).to eq(expected_event)
|
304
325
|
end
|
305
326
|
end
|
306
327
|
end
|
@@ -319,7 +340,7 @@ module Punchblock
|
|
319
340
|
send_ami_events_for_dtmf 1
|
320
341
|
sleep 1.5
|
321
342
|
send_ami_events_for_dtmf 2
|
322
|
-
reason.
|
343
|
+
expect(reason).to be_a Punchblock::Component::Input::Complete::Match
|
323
344
|
end
|
324
345
|
|
325
346
|
it "should cause a NoInput complete event to be sent after the timeout" do
|
@@ -327,7 +348,7 @@ module Punchblock
|
|
327
348
|
sleep 1.5
|
328
349
|
send_ami_events_for_dtmf 1
|
329
350
|
send_ami_events_for_dtmf 2
|
330
|
-
reason.
|
351
|
+
expect(reason).to be_a Punchblock::Component::Input::Complete::NoInput
|
331
352
|
end
|
332
353
|
end
|
333
354
|
|
@@ -335,7 +356,7 @@ module Punchblock
|
|
335
356
|
let(:original_command_opts) { { :initial_timeout => -1 } }
|
336
357
|
|
337
358
|
it "should not start a timer" do
|
338
|
-
subject.
|
359
|
+
expect(subject).to receive(:begin_initial_timer).never
|
339
360
|
subject.execute
|
340
361
|
end
|
341
362
|
end
|
@@ -344,7 +365,7 @@ module Punchblock
|
|
344
365
|
let(:original_command_opts) { { :initial_timeout => nil } }
|
345
366
|
|
346
367
|
it "should not start a timer" do
|
347
|
-
subject.
|
368
|
+
expect(subject).to receive(:begin_initial_timer).never
|
348
369
|
subject.execute
|
349
370
|
end
|
350
371
|
end
|
@@ -355,7 +376,7 @@ module Punchblock
|
|
355
376
|
it "should return an error and not execute any actions" do
|
356
377
|
subject.execute
|
357
378
|
error = ProtocolError.new.setup 'option error', 'An initial timeout value that is negative (and not -1) is invalid.'
|
358
|
-
original_command.response(0.1).
|
379
|
+
expect(original_command.response(0.1)).to eq(error)
|
359
380
|
end
|
360
381
|
end
|
361
382
|
end
|
@@ -370,7 +391,7 @@ module Punchblock
|
|
370
391
|
send_ami_events_for_dtmf 1
|
371
392
|
sleep 0.5
|
372
393
|
send_ami_events_for_dtmf 2
|
373
|
-
reason.
|
394
|
+
expect(reason).to be_a Punchblock::Component::Input::Complete::Match
|
374
395
|
end
|
375
396
|
|
376
397
|
it "should cause a NoMatch complete event to be sent after the timeout" do
|
@@ -379,7 +400,7 @@ module Punchblock
|
|
379
400
|
send_ami_events_for_dtmf 1
|
380
401
|
sleep 1.5
|
381
402
|
send_ami_events_for_dtmf 2
|
382
|
-
reason.
|
403
|
+
expect(reason).to be_a Punchblock::Component::Input::Complete::NoMatch
|
383
404
|
end
|
384
405
|
|
385
406
|
context "with a trailing range repeat" do
|
@@ -399,7 +420,7 @@ module Punchblock
|
|
399
420
|
sleep 1.5
|
400
421
|
send_ami_events_for_dtmf 1
|
401
422
|
sleep 1.5
|
402
|
-
reason.
|
423
|
+
expect(reason).to be_a Punchblock::Component::Input::Complete::NoMatch
|
403
424
|
end
|
404
425
|
end
|
405
426
|
|
@@ -410,7 +431,7 @@ module Punchblock
|
|
410
431
|
instance "dtmf-1 dtmf-1"
|
411
432
|
input '11', mode: :dtmf
|
412
433
|
end
|
413
|
-
end
|
434
|
+
end
|
414
435
|
end
|
415
436
|
|
416
437
|
it "should fire a match on timeout" do
|
@@ -420,8 +441,8 @@ module Punchblock
|
|
420
441
|
sleep 0.5
|
421
442
|
send_ami_events_for_dtmf 1
|
422
443
|
sleep 1.5
|
423
|
-
reason.
|
424
|
-
reason.nlsml.
|
444
|
+
expect(reason).to be_a Punchblock::Component::Input::Complete::Match
|
445
|
+
expect(reason.nlsml).to eq(expected_nlsml)
|
425
446
|
end
|
426
447
|
|
427
448
|
context "on the first keypress" do
|
@@ -442,8 +463,8 @@ module Punchblock
|
|
442
463
|
sleep 0.5
|
443
464
|
send_ami_events_for_dtmf 1
|
444
465
|
sleep 1.5
|
445
|
-
reason.
|
446
|
-
reason.nlsml.
|
466
|
+
expect(reason).to be_a Punchblock::Component::Input::Complete::Match
|
467
|
+
expect(reason.nlsml).to eq(expected_nlsml)
|
447
468
|
end
|
448
469
|
end
|
449
470
|
end
|
@@ -454,7 +475,7 @@ module Punchblock
|
|
454
475
|
let(:original_command_opts) { { :inter_digit_timeout => -1 } }
|
455
476
|
|
456
477
|
it "should not start a timer" do
|
457
|
-
subject.
|
478
|
+
expect(subject).to receive(:begin_inter_digit_timer).never
|
458
479
|
subject.execute
|
459
480
|
end
|
460
481
|
end
|
@@ -463,7 +484,7 @@ module Punchblock
|
|
463
484
|
let(:original_command_opts) { { :inter_digit_timeout => nil } }
|
464
485
|
|
465
486
|
it "should not start a timer" do
|
466
|
-
subject.
|
487
|
+
expect(subject).to receive(:begin_inter_digit_timer).never
|
467
488
|
subject.execute
|
468
489
|
end
|
469
490
|
end
|
@@ -474,7 +495,7 @@ module Punchblock
|
|
474
495
|
it "should return an error and not execute any actions" do
|
475
496
|
subject.execute
|
476
497
|
error = ProtocolError.new.setup 'option error', 'An inter-digit timeout value that is negative (and not -1) is invalid.'
|
477
|
-
original_command.response(0.1).
|
498
|
+
expect(original_command.response(0.1)).to eq(error)
|
478
499
|
end
|
479
500
|
end
|
480
501
|
end
|
@@ -500,7 +521,7 @@ module Punchblock
|
|
500
521
|
|
501
522
|
it "returns a ProtocolError response" do
|
502
523
|
subject.execute_command command
|
503
|
-
command.response(0.1).
|
524
|
+
expect(command.response(0.1)).to be_a ProtocolError
|
504
525
|
end
|
505
526
|
end
|
506
527
|
|
@@ -516,8 +537,8 @@ module Punchblock
|
|
516
537
|
|
517
538
|
it "sets the command response to true" do
|
518
539
|
subject.execute_command command
|
519
|
-
command.response(0.1).
|
520
|
-
reason.
|
540
|
+
expect(command.response(0.1)).to eq(true)
|
541
|
+
expect(reason).to be_a Punchblock::Event::Complete::Stop
|
521
542
|
end
|
522
543
|
end
|
523
544
|
end
|