adhearsion 2.5.4 → 2.6.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.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/CHANGELOG.md +15 -0
- data/README.markdown +2 -1
- data/Rakefile +1 -6
- data/adhearsion.gemspec +4 -3
- data/features/cli_daemon.feature +2 -4
- data/features/cli_restart.feature +14 -5
- data/features/cli_start.feature +0 -2
- data/features/cli_stop.feature +15 -6
- data/lib/adhearsion.rb +21 -23
- data/lib/adhearsion/call.rb +49 -5
- data/lib/adhearsion/call_controller.rb +29 -11
- data/lib/adhearsion/call_controller/dial.rb +21 -9
- data/lib/adhearsion/call_controller/menu_dsl.rb +12 -12
- data/lib/adhearsion/call_controller/menu_dsl/array_match_calculator.rb +1 -1
- data/lib/adhearsion/call_controller/menu_dsl/fixnum_match_calculator.rb +1 -0
- data/lib/adhearsion/call_controller/menu_dsl/string_match_calculator.rb +1 -1
- data/lib/adhearsion/call_controller/output.rb +36 -7
- data/lib/adhearsion/call_controller/output/abstract_player.rb +4 -0
- data/lib/adhearsion/call_controller/record.rb +1 -0
- data/lib/adhearsion/cli_commands/ahn_command.rb +7 -4
- data/lib/adhearsion/cli_commands/plugin_command.rb +2 -0
- data/lib/adhearsion/generators.rb +2 -4
- data/lib/adhearsion/generators/app/templates/simon_game_spec.rb +20 -20
- data/lib/adhearsion/initializer.rb +2 -2
- data/lib/adhearsion/plugin.rb +6 -6
- data/lib/adhearsion/punchblock_plugin.rb +3 -4
- data/lib/adhearsion/punchblock_plugin/initializer.rb +2 -1
- data/lib/adhearsion/router.rb +7 -7
- data/lib/adhearsion/router/route.rb +10 -4
- data/lib/adhearsion/rspec.rb +2 -0
- data/lib/adhearsion/version.rb +1 -1
- data/spec/adhearsion/call_controller/dial_spec.rb +589 -557
- data/spec/adhearsion/call_controller/input_spec.rb +91 -91
- data/spec/adhearsion/call_controller/menu_dsl/array_match_calculator_spec.rb +29 -29
- data/spec/adhearsion/call_controller/menu_dsl/calculated_match_collection_spec.rb +6 -6
- data/spec/adhearsion/call_controller/menu_dsl/calculated_match_spec.rb +19 -19
- data/spec/adhearsion/call_controller/menu_dsl/fixnum_match_calculator_spec.rb +6 -6
- data/spec/adhearsion/call_controller/menu_dsl/match_calculator_spec.rb +1 -1
- data/spec/adhearsion/call_controller/menu_dsl/menu_builder_spec.rb +21 -17
- data/spec/adhearsion/call_controller/menu_dsl/menu_spec.rb +96 -83
- data/spec/adhearsion/call_controller/menu_dsl/range_match_calculator_spec.rb +5 -5
- data/spec/adhearsion/call_controller/menu_dsl/string_match_calculator_spec.rb +9 -9
- data/spec/adhearsion/call_controller/output/async_player_spec.rb +14 -4
- data/spec/adhearsion/call_controller/output/formatter_spec.rb +14 -14
- data/spec/adhearsion/call_controller/output/player_spec.rb +15 -5
- data/spec/adhearsion/call_controller/output_spec.rb +126 -78
- data/spec/adhearsion/call_controller/record_spec.rb +38 -26
- data/spec/adhearsion/call_controller/utility_spec.rb +11 -11
- data/spec/adhearsion/call_controller_spec.rb +176 -136
- data/spec/adhearsion/call_spec.rb +443 -218
- data/spec/adhearsion/calls_spec.rb +33 -33
- data/spec/adhearsion/configuration_spec.rb +61 -61
- data/spec/adhearsion/console_spec.rb +29 -29
- data/spec/adhearsion/events_spec.rb +14 -14
- data/spec/adhearsion/generators_spec.rb +1 -1
- data/spec/adhearsion/initializer_spec.rb +42 -42
- data/spec/adhearsion/logging_spec.rb +33 -33
- data/spec/adhearsion/outbound_call_spec.rb +69 -55
- data/spec/adhearsion/plugin_spec.rb +53 -44
- data/spec/adhearsion/process_spec.rb +21 -21
- data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +68 -52
- data/spec/adhearsion/punchblock_plugin_spec.rb +6 -6
- data/spec/adhearsion/router/evented_route_spec.rb +2 -2
- data/spec/adhearsion/router/openended_route_spec.rb +9 -9
- data/spec/adhearsion/router/route_spec.rb +61 -31
- data/spec/adhearsion/router/unaccepting_route_spec.rb +13 -13
- data/spec/adhearsion/router_spec.rb +47 -33
- data/spec/adhearsion/statistics/dump_spec.rb +6 -6
- data/spec/adhearsion/statistics_spec.rb +9 -9
- data/spec/adhearsion_spec.rb +23 -20
- data/spec/spec_helper.rb +3 -6
- data/spec/support/call_controller_test_helpers.rb +7 -7
- data/spec/support/initializer_stubs.rb +1 -1
- data/spec/support/punchblock_mocks.rb +1 -1
- metadata +22 -10
- data/features/support/utils.rb +0 -9
@@ -16,22 +16,22 @@ module Adhearsion
|
|
16
16
|
let(:sound_files) { [sound_file] }
|
17
17
|
|
18
18
|
it "should play the sound files for the menu" do
|
19
|
-
subject.
|
20
|
-
subject.play_sound_files_for_menu(menu_instance, sound_files).
|
19
|
+
expect(subject).to receive(:interruptible_play).with(sound_file, renderer_options).and_return("1")
|
20
|
+
expect(subject.play_sound_files_for_menu(menu_instance, sound_files)).to eq('1')
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should wait for digit if nothing is pressed during playback" do
|
24
|
-
subject.
|
25
|
-
subject.
|
26
|
-
subject.play_sound_files_for_menu(menu_instance, sound_files).
|
24
|
+
expect(subject).to receive(:interruptible_play).with(sound_file, renderer_options).and_return(nil)
|
25
|
+
expect(subject).to receive(:wait_for_digit).with(menu_instance.timeout).and_return("1")
|
26
|
+
expect(subject.play_sound_files_for_menu(menu_instance, sound_files)).to eq('1')
|
27
27
|
end
|
28
28
|
|
29
29
|
context "with a renderer specified" do
|
30
30
|
let(:options) { { :renderer => :native } }
|
31
31
|
let(:renderer_options) { { renderer: :native } }
|
32
32
|
it "should play the sound files for the menu" do
|
33
|
-
subject.
|
34
|
-
subject.play_sound_files_for_menu(menu_instance, sound_files).
|
33
|
+
expect(subject).to receive(:interruptible_play).with(sound_file, renderer_options).and_return("1")
|
34
|
+
expect(subject.play_sound_files_for_menu(menu_instance, sound_files)).to eq('1')
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -39,9 +39,9 @@ module Adhearsion
|
|
39
39
|
context "when the menu is not interruptible" do
|
40
40
|
let(:options) { { :interruptible => false } }
|
41
41
|
it "should play the sound files and wait for digit" do
|
42
|
-
subject.
|
43
|
-
subject.
|
44
|
-
subject.play_sound_files_for_menu(menu_instance, sound_files).
|
42
|
+
expect(subject).to receive(:play).with(sound_file, renderer_options).and_return true
|
43
|
+
expect(subject).to receive(:wait_for_digit).with(menu_instance.timeout).and_return("1")
|
44
|
+
expect(subject.play_sound_files_for_menu(menu_instance, sound_files)).to eq('1')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -49,9 +49,9 @@ module Adhearsion
|
|
49
49
|
let(:options) { { :renderer => :native, :interruptible => false } }
|
50
50
|
let(:renderer_options) { { renderer: :native } }
|
51
51
|
it "should pass the renderer option to #play" do
|
52
|
-
subject.
|
53
|
-
subject.
|
54
|
-
subject.play_sound_files_for_menu(menu_instance, sound_files).
|
52
|
+
expect(subject).to receive(:play).with(sound_file, renderer_options).and_return true
|
53
|
+
expect(subject).to receive(:wait_for_digit).with(menu_instance.timeout).and_return("1")
|
54
|
+
expect(subject.play_sound_files_for_menu(menu_instance, sound_files)).to eq('1')
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end#play_sound_files_for_menu
|
@@ -92,14 +92,14 @@ module Adhearsion
|
|
92
92
|
|
93
93
|
it "sends the correct input component" do
|
94
94
|
expect_component_complete_event
|
95
|
-
subject.
|
95
|
+
expect(subject).to receive(:execute_component_and_await_completion).once.with(input_component).and_return input_component
|
96
96
|
subject.wait_for_digit timeout
|
97
97
|
end
|
98
98
|
|
99
99
|
it "returns the correct pressed digit" do
|
100
100
|
expect_component_complete_event
|
101
|
-
subject.
|
102
|
-
subject.wait_for_digit(timeout).
|
101
|
+
expect(subject).to receive(:execute_component_and_await_completion).once.with(kind_of(Punchblock::Component::Input)).and_return input_component
|
102
|
+
expect(subject.wait_for_digit(timeout)).to eq('5')
|
103
103
|
end
|
104
104
|
|
105
105
|
context "when the utterance does not have dtmf- prefix" do
|
@@ -107,8 +107,8 @@ module Adhearsion
|
|
107
107
|
|
108
108
|
it "returns the correct pressed digit" do
|
109
109
|
expect_component_complete_event
|
110
|
-
subject.
|
111
|
-
subject.wait_for_digit(timeout).
|
110
|
+
expect(subject).to receive(:execute_component_and_await_completion).once.with(kind_of(Punchblock::Component::Input)).and_return input_component
|
111
|
+
expect(subject.wait_for_digit(timeout)).to eq('5')
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
@@ -118,7 +118,7 @@ module Adhearsion
|
|
118
118
|
|
119
119
|
it "does not set a timeout on the component" do
|
120
120
|
expect_component_complete_event
|
121
|
-
subject.
|
121
|
+
expect(subject).to receive(:execute_component_and_await_completion).once.with(input_component).and_return input_component
|
122
122
|
subject.wait_for_digit timeout
|
123
123
|
end
|
124
124
|
end
|
@@ -130,15 +130,15 @@ module Adhearsion
|
|
130
130
|
let(:block) { Proc.new {} }
|
131
131
|
|
132
132
|
it "calls instance_exec if the match object has a block" do
|
133
|
-
match_object.
|
134
|
-
subject.
|
133
|
+
allow(match_object).to receive_messages(:block => block)
|
134
|
+
expect(subject).to receive(:instance_exec).with(overrides[:extension], &block)
|
135
135
|
subject.jump_to(match_object, overrides)
|
136
136
|
end
|
137
137
|
|
138
138
|
it "calls invoke if the match object does not have a block" do
|
139
|
-
match_object.
|
140
|
-
match_object.
|
141
|
-
subject.
|
139
|
+
expect(match_object).to receive(:block).and_return(false)
|
140
|
+
expect(match_object).to receive(:match_payload).and_return(:payload)
|
141
|
+
expect(subject).to receive(:invoke).with(:payload, overrides)
|
142
142
|
subject.jump_to(match_object, overrides)
|
143
143
|
end
|
144
144
|
end#jump_to
|
@@ -162,91 +162,91 @@ module Adhearsion
|
|
162
162
|
let(:response) { '1234' }
|
163
163
|
|
164
164
|
before do
|
165
|
-
menu_instance.
|
166
|
-
MenuDSL::Menu.
|
165
|
+
allow(menu_instance).to receive_messages :status => status, :result => response
|
166
|
+
expect(MenuDSL::Menu).to receive(:new).and_return(menu_instance)
|
167
167
|
end
|
168
168
|
|
169
169
|
it "logs a warning about dropped DTMF" do
|
170
|
-
menu_instance.
|
170
|
+
expect(menu_instance).to receive(:continue).and_return(result_done)
|
171
171
|
|
172
|
-
call.logger.
|
172
|
+
expect(call.logger).to receive(:warn).with(/deprecated/)
|
173
173
|
subject.menu sound_files
|
174
174
|
end
|
175
175
|
|
176
176
|
it "exits the function if MenuResultDone" do
|
177
|
-
menu_instance.
|
178
|
-
menu_instance.
|
177
|
+
expect(menu_instance).to receive(:should_continue?).and_return(true)
|
178
|
+
expect(menu_instance).to receive(:continue).and_return(result_done)
|
179
179
|
result = subject.menu sound_files
|
180
|
-
result.menu.
|
181
|
-
result.response.
|
180
|
+
expect(result.menu).to be menu_instance
|
181
|
+
expect(result.response).to be response
|
182
182
|
end
|
183
183
|
|
184
184
|
it "exits the function if MenuTerminated" do
|
185
|
-
menu_instance.
|
186
|
-
menu_instance.
|
185
|
+
expect(menu_instance).to receive(:should_continue?).and_return(true)
|
186
|
+
expect(menu_instance).to receive(:continue).and_return(result_terminated)
|
187
187
|
result = subject.menu sound_files
|
188
|
-
result.menu.
|
189
|
-
result.response.
|
188
|
+
expect(result.menu).to be menu_instance
|
189
|
+
expect(result.response).to be response
|
190
190
|
end
|
191
191
|
|
192
192
|
it "exits the function if MenuLimitReached" do
|
193
|
-
menu_instance.
|
194
|
-
menu_instance.
|
193
|
+
expect(menu_instance).to receive(:should_continue?).and_return(true)
|
194
|
+
expect(menu_instance).to receive(:continue).and_return(result_limit_reached)
|
195
195
|
result = subject.menu sound_files
|
196
|
-
result.menu.
|
197
|
-
result.response.
|
196
|
+
expect(result.menu).to be menu_instance
|
197
|
+
expect(result.response).to be response
|
198
198
|
end
|
199
199
|
|
200
200
|
it "executes failure hook and returns :failure if menu fails" do
|
201
|
-
menu_instance.
|
202
|
-
menu_instance.
|
201
|
+
expect(menu_instance).to receive(:should_continue?).and_return(false)
|
202
|
+
expect(menu_instance).to receive(:execute_failure_hook).once
|
203
203
|
result = subject.menu sound_files
|
204
|
-
result.menu.
|
205
|
-
result.response.
|
204
|
+
expect(result.menu).to be menu_instance
|
205
|
+
expect(result.response).to be response
|
206
206
|
end
|
207
207
|
|
208
208
|
it "executes invalid hook if input is invalid" do
|
209
|
-
menu_instance.
|
210
|
-
menu_instance.
|
211
|
-
menu_instance.
|
212
|
-
menu_instance.
|
209
|
+
expect(menu_instance).to receive(:should_continue?).twice.and_return(true)
|
210
|
+
expect(menu_instance).to receive(:continue).and_return(result_invalid, result_done)
|
211
|
+
expect(menu_instance).to receive(:execute_invalid_hook).once
|
212
|
+
expect(menu_instance).to receive(:restart!).once
|
213
213
|
result = subject.menu sound_files
|
214
|
-
result.menu.
|
215
|
-
result.response.
|
214
|
+
expect(result.menu).to be menu_instance
|
215
|
+
expect(result.response).to be response
|
216
216
|
end
|
217
217
|
|
218
218
|
it "plays audio, then executes timeout hook if input times out" do
|
219
|
-
menu_instance.
|
220
|
-
menu_instance.
|
221
|
-
subject.
|
222
|
-
menu_instance.
|
223
|
-
menu_instance.
|
219
|
+
expect(menu_instance).to receive(:should_continue?).twice.and_return(true)
|
220
|
+
expect(menu_instance).to receive(:continue).and_return(result_get_another_or_timeout, result_done)
|
221
|
+
expect(subject).to receive(:play_sound_files_for_menu).with(menu_instance, sound_files).and_return(nil)
|
222
|
+
expect(menu_instance).to receive(:execute_timeout_hook).once
|
223
|
+
expect(menu_instance).to receive(:restart!).once
|
224
224
|
subject.menu sound_files
|
225
225
|
end
|
226
226
|
|
227
227
|
it "plays audio, then adds digit to digit buffer if input is received" do
|
228
|
-
menu_instance.
|
229
|
-
menu_instance.
|
230
|
-
subject.
|
231
|
-
menu_instance.
|
228
|
+
expect(menu_instance).to receive(:should_continue?).twice.and_return(true)
|
229
|
+
expect(menu_instance).to receive(:continue).and_return(result_get_another_or_timeout, result_done)
|
230
|
+
expect(subject).to receive(:play_sound_files_for_menu).with(menu_instance, sound_files).and_return("1")
|
231
|
+
expect(menu_instance).to receive(:<<).with("1").once
|
232
232
|
subject.menu sound_files
|
233
233
|
end
|
234
234
|
|
235
235
|
it "plays audio, then jumps to payload when input is finished" do
|
236
|
-
menu_instance.
|
237
|
-
menu_instance.
|
238
|
-
subject.
|
239
|
-
subject.
|
236
|
+
expect(menu_instance).to receive(:should_continue?).and_return(true)
|
237
|
+
expect(menu_instance).to receive(:continue).and_return(result_get_another_or_finish)
|
238
|
+
expect(subject).to receive(:play_sound_files_for_menu).with(menu_instance, sound_files).and_return(nil)
|
239
|
+
expect(subject).to receive(:jump_to).with(:match_object, :extension => :new_extension).once
|
240
240
|
subject.menu sound_files
|
241
241
|
end
|
242
242
|
|
243
243
|
it "jumps to payload when result is found" do
|
244
|
-
menu_instance.
|
245
|
-
menu_instance.
|
246
|
-
subject.
|
244
|
+
expect(menu_instance).to receive(:should_continue?).and_return(true)
|
245
|
+
expect(menu_instance).to receive(:continue).and_return(result_found)
|
246
|
+
expect(subject).to receive(:jump_to).with(:match_object, :extension => :new_extension).once
|
247
247
|
result = subject.menu sound_files
|
248
|
-
result.menu.
|
249
|
-
result.response.
|
248
|
+
expect(result.menu).to be menu_instance
|
249
|
+
expect(result.response).to be response
|
250
250
|
end
|
251
251
|
|
252
252
|
context "if a digit limit is specified" do
|
@@ -275,62 +275,62 @@ module Adhearsion
|
|
275
275
|
|
276
276
|
before do
|
277
277
|
menu_instance
|
278
|
-
MenuDSL::Menu.
|
278
|
+
expect(MenuDSL::Menu).to receive(:new).and_return(menu_instance)
|
279
279
|
end
|
280
280
|
|
281
281
|
it "logs a warning about dropped DTMF" do
|
282
|
-
menu_instance.
|
282
|
+
expect(menu_instance).to receive(:continue).and_return(result_done)
|
283
283
|
|
284
|
-
call.logger.
|
284
|
+
expect(call.logger).to receive(:warn).with(/deprecated/)
|
285
285
|
subject.ask sound_files
|
286
286
|
end
|
287
287
|
|
288
288
|
it "exits the function if MenuResultDone" do
|
289
|
-
menu_instance.
|
289
|
+
expect(menu_instance).to receive(:continue).and_return(result_done)
|
290
290
|
result = subject.ask sound_files
|
291
|
-
result.menu.
|
292
|
-
result.response.
|
291
|
+
expect(result.menu).to be menu_instance
|
292
|
+
expect(result.response).to eq('')
|
293
293
|
end
|
294
294
|
|
295
295
|
it "exits the function if MenuTerminated" do
|
296
|
-
menu_instance.
|
296
|
+
expect(menu_instance).to receive(:continue).and_return(result_terminated)
|
297
297
|
result = subject.ask sound_files
|
298
|
-
result.menu.
|
299
|
-
result.response.
|
298
|
+
expect(result.menu).to be menu_instance
|
299
|
+
expect(result.response).to eq('')
|
300
300
|
end
|
301
301
|
|
302
302
|
it "exits the function if MenuLimitReached" do
|
303
|
-
menu_instance.
|
303
|
+
expect(menu_instance).to receive(:continue).and_return(result_limit_reached)
|
304
304
|
result = subject.ask sound_files
|
305
|
-
result.menu.
|
306
|
-
result.response.
|
305
|
+
expect(result.menu).to be menu_instance
|
306
|
+
expect(result.response).to eq('')
|
307
307
|
end
|
308
308
|
|
309
309
|
it "plays audio, then executes timeout hook if input times out" do
|
310
|
-
menu_instance.
|
311
|
-
subject.
|
310
|
+
expect(menu_instance).to receive(:continue).and_return(result_get_another_or_timeout)
|
311
|
+
expect(subject).to receive(:play_sound_files_for_menu).once.with(menu_instance, sound_files).and_return(nil)
|
312
312
|
result = subject.ask sound_files
|
313
|
-
result.menu.
|
314
|
-
result.response.
|
315
|
-
result.status.
|
313
|
+
expect(result.menu).to be menu_instance
|
314
|
+
expect(result.response).to eq('')
|
315
|
+
expect(result.status).to be :timeout
|
316
316
|
end
|
317
317
|
|
318
318
|
it "plays audio, then adds digit to digit buffer if input is received" do
|
319
|
-
menu_instance.
|
320
|
-
subject.
|
321
|
-
menu_instance.
|
319
|
+
expect(menu_instance).to receive(:continue).and_return(result_get_another_or_timeout, result_done)
|
320
|
+
expect(subject).to receive(:play_sound_files_for_menu).once.with(menu_instance, sound_files).and_return("1")
|
321
|
+
expect(menu_instance).to receive(:<<).with("1").once
|
322
322
|
subject.ask sound_files
|
323
323
|
end
|
324
324
|
end
|
325
325
|
|
326
326
|
context "with a block passed" do
|
327
327
|
it "validates the buffer using that block, terminating on something truthy" do
|
328
|
-
subject.
|
328
|
+
expect(subject).to receive(:play_sound_files_for_menu).twice.and_return("1")
|
329
329
|
result = subject.ask sound_files, limit: 3 do |buffer|
|
330
330
|
buffer == '11'
|
331
331
|
end
|
332
|
-
result.status.
|
333
|
-
result.response.
|
332
|
+
expect(result.status).to eq(:validator_terminated)
|
333
|
+
expect(result.response).to eq('11')
|
334
334
|
end
|
335
335
|
end
|
336
336
|
|
@@ -12,63 +12,63 @@ module Adhearsion
|
|
12
12
|
it "matching arrays with fixnums" do
|
13
13
|
calculator = ArrayMatchCalculator.new [11,5,14,115], match_payload
|
14
14
|
match_case = calculator.match '11'
|
15
|
-
match_case.
|
16
|
-
match_case.
|
17
|
-
match_case.exact_matches.
|
18
|
-
match_case.potential_matches.
|
15
|
+
expect(match_case).to be_exact_match
|
16
|
+
expect(match_case).to be_potential_match
|
17
|
+
expect(match_case.exact_matches).to eq([11])
|
18
|
+
expect(match_case.potential_matches).to eq([115])
|
19
19
|
end
|
20
20
|
|
21
21
|
it "matching arrays with strings with digits and special digits" do
|
22
22
|
calculator = ArrayMatchCalculator.new %w[*57 4 *54 115 ###], match_payload
|
23
23
|
match_case = calculator.match '*5'
|
24
|
-
match_case.
|
25
|
-
match_case.
|
26
|
-
match_case.potential_matches.
|
24
|
+
expect(match_case).not_to be_exact_match
|
25
|
+
expect(match_case).to be_potential_match
|
26
|
+
expect(match_case.potential_matches).to eq(%w[*57 *54])
|
27
27
|
|
28
28
|
match_case = calculator.match '*57'
|
29
|
-
match_case.
|
30
|
-
match_case.
|
31
|
-
match_case.exact_matches.
|
29
|
+
expect(match_case).to be_exact_match
|
30
|
+
expect(match_case).not_to be_potential_match
|
31
|
+
expect(match_case.exact_matches).to eq(%w[*57])
|
32
32
|
end
|
33
33
|
|
34
34
|
it "matching an array with a combination of Fixnums and Strings" do
|
35
35
|
calculator = ArrayMatchCalculator.new ['11',5,'14',115], match_payload
|
36
36
|
match_case = calculator.match '11'
|
37
|
-
match_case.
|
38
|
-
match_case.
|
39
|
-
match_case.exact_matches.
|
40
|
-
match_case.potential_matches.
|
37
|
+
expect(match_case).to be_exact_match
|
38
|
+
expect(match_case).to be_potential_match
|
39
|
+
expect(match_case.exact_matches).to eq(['11'])
|
40
|
+
expect(match_case.potential_matches).to eq([115])
|
41
41
|
end
|
42
42
|
|
43
43
|
it "matching empty array should never match" do
|
44
44
|
calculator = ArrayMatchCalculator.new [], match_payload
|
45
45
|
match_case = calculator.match '98'
|
46
|
-
match_case.
|
47
|
-
match_case.
|
48
|
-
match_case.exact_matches.
|
49
|
-
match_case.potential_matches.
|
46
|
+
expect(match_case).not_to be_exact_match
|
47
|
+
expect(match_case).not_to be_potential_match
|
48
|
+
expect(match_case.exact_matches).to eq([])
|
49
|
+
expect(match_case.potential_matches).to eq([])
|
50
50
|
|
51
51
|
match_case = calculator.match '*2'
|
52
|
-
match_case.
|
53
|
-
match_case.
|
54
|
-
match_case.exact_matches.
|
55
|
-
match_case.potential_matches.
|
52
|
+
expect(match_case).not_to be_exact_match
|
53
|
+
expect(match_case).not_to be_potential_match
|
54
|
+
expect(match_case.exact_matches).to eq([])
|
55
|
+
expect(match_case.potential_matches).to eq([])
|
56
56
|
end
|
57
57
|
|
58
58
|
it "matching array with nil should skip nil field" do
|
59
59
|
pattern = [1,2,nil,5,10]
|
60
60
|
calculator = ArrayMatchCalculator.new pattern, match_payload
|
61
61
|
match_case = calculator.match '1'
|
62
|
-
match_case.
|
63
|
-
match_case.
|
64
|
-
match_case.exact_matches.
|
65
|
-
match_case.potential_matches.
|
62
|
+
expect(match_case).to be_exact_match
|
63
|
+
expect(match_case).to be_potential_match
|
64
|
+
expect(match_case.exact_matches).to eq([1])
|
65
|
+
expect(match_case.potential_matches).to eq([10])
|
66
66
|
|
67
67
|
match_case = calculator.match '99'
|
68
|
-
match_case.
|
69
|
-
match_case.
|
68
|
+
expect(match_case).not_to be_exact_match
|
69
|
+
expect(match_case).not_to be_potential_match
|
70
70
|
|
71
|
-
pattern.
|
71
|
+
expect(pattern).to eq([1,2,nil,5,10])
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -26,10 +26,10 @@ module Adhearsion
|
|
26
26
|
mock_matches_2 = mock_with_potential_matches mock_matches_array_2
|
27
27
|
|
28
28
|
subject << mock_matches_1
|
29
|
-
subject.actual_potential_matches.
|
29
|
+
expect(subject.actual_potential_matches).to eq(mock_matches_array_1)
|
30
30
|
|
31
31
|
subject << mock_matches_2
|
32
|
-
subject.actual_potential_matches.
|
32
|
+
expect(subject.actual_potential_matches).to eq(mock_matches_array_1 + mock_matches_array_2)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "the <<() method should collect the exact matches into the actual_exact_matches Array" do
|
@@ -39,20 +39,20 @@ module Adhearsion
|
|
39
39
|
mock_matches_2 = mock_with_exact_matches mock_matches_array_2
|
40
40
|
|
41
41
|
subject << mock_matches_1
|
42
|
-
subject.actual_exact_matches.
|
42
|
+
expect(subject.actual_exact_matches).to eq(mock_matches_array_1)
|
43
43
|
|
44
44
|
subject << mock_matches_2
|
45
|
-
subject.actual_exact_matches.
|
45
|
+
expect(subject.actual_exact_matches).to eq(mock_matches_array_1 + mock_matches_array_2)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "if any exact matches exist, the exact_match?() method should return true" do
|
49
49
|
subject << mock_with_exact_matches([1,2,3])
|
50
|
-
subject.exact_match
|
50
|
+
expect(subject.exact_match?).to be true
|
51
51
|
end
|
52
52
|
|
53
53
|
it "if any potential matches exist, the potential_match?() method should return true" do
|
54
54
|
subject << mock_with_potential_matches([1,2,3])
|
55
|
-
subject.potential_match
|
55
|
+
expect(subject.potential_match?).to be true
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|