adhearsion 2.5.4 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/CHANGELOG.md +15 -0
  4. data/README.markdown +2 -1
  5. data/Rakefile +1 -6
  6. data/adhearsion.gemspec +4 -3
  7. data/features/cli_daemon.feature +2 -4
  8. data/features/cli_restart.feature +14 -5
  9. data/features/cli_start.feature +0 -2
  10. data/features/cli_stop.feature +15 -6
  11. data/lib/adhearsion.rb +21 -23
  12. data/lib/adhearsion/call.rb +49 -5
  13. data/lib/adhearsion/call_controller.rb +29 -11
  14. data/lib/adhearsion/call_controller/dial.rb +21 -9
  15. data/lib/adhearsion/call_controller/menu_dsl.rb +12 -12
  16. data/lib/adhearsion/call_controller/menu_dsl/array_match_calculator.rb +1 -1
  17. data/lib/adhearsion/call_controller/menu_dsl/fixnum_match_calculator.rb +1 -0
  18. data/lib/adhearsion/call_controller/menu_dsl/string_match_calculator.rb +1 -1
  19. data/lib/adhearsion/call_controller/output.rb +36 -7
  20. data/lib/adhearsion/call_controller/output/abstract_player.rb +4 -0
  21. data/lib/adhearsion/call_controller/record.rb +1 -0
  22. data/lib/adhearsion/cli_commands/ahn_command.rb +7 -4
  23. data/lib/adhearsion/cli_commands/plugin_command.rb +2 -0
  24. data/lib/adhearsion/generators.rb +2 -4
  25. data/lib/adhearsion/generators/app/templates/simon_game_spec.rb +20 -20
  26. data/lib/adhearsion/initializer.rb +2 -2
  27. data/lib/adhearsion/plugin.rb +6 -6
  28. data/lib/adhearsion/punchblock_plugin.rb +3 -4
  29. data/lib/adhearsion/punchblock_plugin/initializer.rb +2 -1
  30. data/lib/adhearsion/router.rb +7 -7
  31. data/lib/adhearsion/router/route.rb +10 -4
  32. data/lib/adhearsion/rspec.rb +2 -0
  33. data/lib/adhearsion/version.rb +1 -1
  34. data/spec/adhearsion/call_controller/dial_spec.rb +589 -557
  35. data/spec/adhearsion/call_controller/input_spec.rb +91 -91
  36. data/spec/adhearsion/call_controller/menu_dsl/array_match_calculator_spec.rb +29 -29
  37. data/spec/adhearsion/call_controller/menu_dsl/calculated_match_collection_spec.rb +6 -6
  38. data/spec/adhearsion/call_controller/menu_dsl/calculated_match_spec.rb +19 -19
  39. data/spec/adhearsion/call_controller/menu_dsl/fixnum_match_calculator_spec.rb +6 -6
  40. data/spec/adhearsion/call_controller/menu_dsl/match_calculator_spec.rb +1 -1
  41. data/spec/adhearsion/call_controller/menu_dsl/menu_builder_spec.rb +21 -17
  42. data/spec/adhearsion/call_controller/menu_dsl/menu_spec.rb +96 -83
  43. data/spec/adhearsion/call_controller/menu_dsl/range_match_calculator_spec.rb +5 -5
  44. data/spec/adhearsion/call_controller/menu_dsl/string_match_calculator_spec.rb +9 -9
  45. data/spec/adhearsion/call_controller/output/async_player_spec.rb +14 -4
  46. data/spec/adhearsion/call_controller/output/formatter_spec.rb +14 -14
  47. data/spec/adhearsion/call_controller/output/player_spec.rb +15 -5
  48. data/spec/adhearsion/call_controller/output_spec.rb +126 -78
  49. data/spec/adhearsion/call_controller/record_spec.rb +38 -26
  50. data/spec/adhearsion/call_controller/utility_spec.rb +11 -11
  51. data/spec/adhearsion/call_controller_spec.rb +176 -136
  52. data/spec/adhearsion/call_spec.rb +443 -218
  53. data/spec/adhearsion/calls_spec.rb +33 -33
  54. data/spec/adhearsion/configuration_spec.rb +61 -61
  55. data/spec/adhearsion/console_spec.rb +29 -29
  56. data/spec/adhearsion/events_spec.rb +14 -14
  57. data/spec/adhearsion/generators_spec.rb +1 -1
  58. data/spec/adhearsion/initializer_spec.rb +42 -42
  59. data/spec/adhearsion/logging_spec.rb +33 -33
  60. data/spec/adhearsion/outbound_call_spec.rb +69 -55
  61. data/spec/adhearsion/plugin_spec.rb +53 -44
  62. data/spec/adhearsion/process_spec.rb +21 -21
  63. data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +68 -52
  64. data/spec/adhearsion/punchblock_plugin_spec.rb +6 -6
  65. data/spec/adhearsion/router/evented_route_spec.rb +2 -2
  66. data/spec/adhearsion/router/openended_route_spec.rb +9 -9
  67. data/spec/adhearsion/router/route_spec.rb +61 -31
  68. data/spec/adhearsion/router/unaccepting_route_spec.rb +13 -13
  69. data/spec/adhearsion/router_spec.rb +47 -33
  70. data/spec/adhearsion/statistics/dump_spec.rb +6 -6
  71. data/spec/adhearsion/statistics_spec.rb +9 -9
  72. data/spec/adhearsion_spec.rb +23 -20
  73. data/spec/spec_helper.rb +3 -6
  74. data/spec/support/call_controller_test_helpers.rb +7 -7
  75. data/spec/support/initializer_stubs.rb +1 -1
  76. data/spec/support/punchblock_mocks.rb +1 -1
  77. metadata +22 -10
  78. 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.should_receive(:interruptible_play).with(sound_file, renderer_options).and_return("1")
20
- subject.play_sound_files_for_menu(menu_instance, sound_files).should be == '1'
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.should_receive(:interruptible_play).with(sound_file, renderer_options).and_return(nil)
25
- subject.should_receive(:wait_for_digit).with(menu_instance.timeout).and_return("1")
26
- subject.play_sound_files_for_menu(menu_instance, sound_files).should be == '1'
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.should_receive(:interruptible_play).with(sound_file, renderer_options).and_return("1")
34
- subject.play_sound_files_for_menu(menu_instance, sound_files).should be == '1'
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.should_receive(:play).with(sound_file, renderer_options).and_return true
43
- subject.should_receive(:wait_for_digit).with(menu_instance.timeout).and_return("1")
44
- subject.play_sound_files_for_menu(menu_instance, sound_files).should be == '1'
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.should_receive(:play).with(sound_file, renderer_options).and_return true
53
- subject.should_receive(:wait_for_digit).with(menu_instance.timeout).and_return("1")
54
- subject.play_sound_files_for_menu(menu_instance, sound_files).should be == '1'
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.should_receive(:execute_component_and_await_completion).once.with(input_component).and_return input_component
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.should_receive(:execute_component_and_await_completion).once.with(kind_of(Punchblock::Component::Input)).and_return input_component
102
- subject.wait_for_digit(timeout).should be == '5'
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.should_receive(:execute_component_and_await_completion).once.with(kind_of(Punchblock::Component::Input)).and_return input_component
111
- subject.wait_for_digit(timeout).should be == '5'
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.should_receive(:execute_component_and_await_completion).once.with(input_component).and_return input_component
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.stub(:block => block)
134
- subject.should_receive(:instance_exec).with(overrides[:extension], &block)
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.should_receive(:block).and_return(false)
140
- match_object.should_receive(:match_payload).and_return(:payload)
141
- subject.should_receive(:invoke).with(:payload, overrides)
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.stub :status => status, :result => response
166
- MenuDSL::Menu.should_receive(:new).and_return(menu_instance)
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.should_receive(:continue).and_return(result_done)
170
+ expect(menu_instance).to receive(:continue).and_return(result_done)
171
171
 
172
- call.logger.should_receive(:warn).with(/deprecated/)
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.should_receive(:should_continue?).and_return(true)
178
- menu_instance.should_receive(:continue).and_return(result_done)
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.should be menu_instance
181
- result.response.should be 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.should_receive(:should_continue?).and_return(true)
186
- menu_instance.should_receive(:continue).and_return(result_terminated)
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.should be menu_instance
189
- result.response.should be 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.should_receive(:should_continue?).and_return(true)
194
- menu_instance.should_receive(:continue).and_return(result_limit_reached)
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.should be menu_instance
197
- result.response.should be 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.should_receive(:should_continue?).and_return(false)
202
- menu_instance.should_receive(:execute_failure_hook).once
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.should be menu_instance
205
- result.response.should be 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.should_receive(:should_continue?).twice.and_return(true)
210
- menu_instance.should_receive(:continue).and_return(result_invalid, result_done)
211
- menu_instance.should_receive(:execute_invalid_hook).once
212
- menu_instance.should_receive(:restart!).once
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.should be menu_instance
215
- result.response.should be 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.should_receive(:should_continue?).twice.and_return(true)
220
- menu_instance.should_receive(:continue).and_return(result_get_another_or_timeout, result_done)
221
- subject.should_receive(:play_sound_files_for_menu).with(menu_instance, sound_files).and_return(nil)
222
- menu_instance.should_receive(:execute_timeout_hook).once
223
- menu_instance.should_receive(:restart!).once
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.should_receive(:should_continue?).twice.and_return(true)
229
- menu_instance.should_receive(:continue).and_return(result_get_another_or_timeout, result_done)
230
- subject.should_receive(:play_sound_files_for_menu).with(menu_instance, sound_files).and_return("1")
231
- menu_instance.should_receive(:<<).with("1").once
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.should_receive(:should_continue?).and_return(true)
237
- menu_instance.should_receive(:continue).and_return(result_get_another_or_finish)
238
- subject.should_receive(:play_sound_files_for_menu).with(menu_instance, sound_files).and_return(nil)
239
- subject.should_receive(:jump_to).with(:match_object, :extension => :new_extension).once
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.should_receive(:should_continue?).and_return(true)
245
- menu_instance.should_receive(:continue).and_return(result_found)
246
- subject.should_receive(:jump_to).with(:match_object, :extension => :new_extension).once
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.should be menu_instance
249
- result.response.should be 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.should_receive(:new).and_return(menu_instance)
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.should_receive(:continue).and_return(result_done)
282
+ expect(menu_instance).to receive(:continue).and_return(result_done)
283
283
 
284
- call.logger.should_receive(:warn).with(/deprecated/)
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.should_receive(:continue).and_return(result_done)
289
+ expect(menu_instance).to receive(:continue).and_return(result_done)
290
290
  result = subject.ask sound_files
291
- result.menu.should be menu_instance
292
- result.response.should == ''
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.should_receive(:continue).and_return(result_terminated)
296
+ expect(menu_instance).to receive(:continue).and_return(result_terminated)
297
297
  result = subject.ask sound_files
298
- result.menu.should be menu_instance
299
- result.response.should == ''
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.should_receive(:continue).and_return(result_limit_reached)
303
+ expect(menu_instance).to receive(:continue).and_return(result_limit_reached)
304
304
  result = subject.ask sound_files
305
- result.menu.should be menu_instance
306
- result.response.should == ''
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.should_receive(:continue).and_return(result_get_another_or_timeout)
311
- subject.should_receive(:play_sound_files_for_menu).once.with(menu_instance, sound_files).and_return(nil)
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.should be menu_instance
314
- result.response.should be == ''
315
- result.status.should be :timeout
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.should_receive(:continue).and_return(result_get_another_or_timeout, result_done)
320
- subject.should_receive(:play_sound_files_for_menu).once.with(menu_instance, sound_files).and_return("1")
321
- menu_instance.should_receive(:<<).with("1").once
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.should_receive(:play_sound_files_for_menu).twice.and_return("1")
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.should == :validator_terminated
333
- result.response.should == '11'
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.should be_exact_match
16
- match_case.should be_potential_match
17
- match_case.exact_matches.should be == [11]
18
- match_case.potential_matches.should be == [115]
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.should_not be_exact_match
25
- match_case.should be_potential_match
26
- match_case.potential_matches.should be == %w[*57 *54]
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.should be_exact_match
30
- match_case.should_not be_potential_match
31
- match_case.exact_matches.should be == %w[*57]
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.should be_exact_match
38
- match_case.should be_potential_match
39
- match_case.exact_matches.should be == ['11']
40
- match_case.potential_matches.should be == [115]
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.should_not be_exact_match
47
- match_case.should_not be_potential_match
48
- match_case.exact_matches.should be == []
49
- match_case.potential_matches.should be == []
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.should_not be_exact_match
53
- match_case.should_not be_potential_match
54
- match_case.exact_matches.should be == []
55
- match_case.potential_matches.should be == []
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.should be_exact_match
63
- match_case.should be_potential_match
64
- match_case.exact_matches.should be == [1]
65
- match_case.potential_matches.should be == [10]
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.should_not be_exact_match
69
- match_case.should_not be_potential_match
68
+ expect(match_case).not_to be_exact_match
69
+ expect(match_case).not_to be_potential_match
70
70
 
71
- pattern.should == [1,2,nil,5,10]
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.should be == mock_matches_array_1
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.should be == mock_matches_array_1 + mock_matches_array_2
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.should be == mock_matches_array_1
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.should be == mock_matches_array_1 + mock_matches_array_2
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?.should be true
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?.should be true
55
+ expect(subject.potential_match?).to be true
56
56
  end
57
57
  end
58
58
  end