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
@@ -13,23 +13,23 @@ module Adhearsion
13
13
  end
14
14
 
15
15
  it 'should trigger :stop_requested events on #shutdown' do
16
- Events.should_receive(:trigger_immediately).once.with(:stop_requested).ordered
17
- Events.should_receive(:trigger_immediately).once.with(:shutdown).ordered
16
+ expect(Events).to receive(:trigger_immediately).once.with(:stop_requested).ordered
17
+ expect(Events).to receive(:trigger_immediately).once.with(:shutdown).ordered
18
18
  Adhearsion::Process.booted
19
19
  Adhearsion::Process.shutdown
20
20
  sleep 0.2
21
21
  end
22
22
 
23
23
  it '#stop_when_zero_calls should wait until the list of active calls reaches 0' do
24
- pending
24
+ skip
25
25
  calls = ThreadSafeArray.new
26
26
  3.times do
27
27
  fake_call = Object.new
28
- fake_call.should_receive(:hangup).once
28
+ expect(fake_call).to receive(:hangup).once
29
29
  calls << fake_call
30
30
  end
31
- Adhearsion.should_receive(:active_calls).and_return calls
32
- Adhearsion::Process.instance.should_receive(:final_shutdown).once
31
+ expect(Adhearsion).to receive(:active_calls).and_return calls
32
+ expect(Adhearsion::Process.instance).to receive(:final_shutdown).once
33
33
  calls = []
34
34
  3.times do
35
35
  calls << Thread.new do
@@ -42,7 +42,7 @@ module Adhearsion
42
42
  end
43
43
 
44
44
  it 'should terminate the process immediately on #force_stop' do
45
- ::Process.should_receive(:exit).with(1).once.and_return true
45
+ expect(::Process).to receive(:exit).with(1).once.and_return true
46
46
  Adhearsion::Process.force_stop
47
47
  end
48
48
 
@@ -50,8 +50,8 @@ module Adhearsion
50
50
  it "should hang up active calls" do
51
51
  3.times do
52
52
  fake_call = Call.new
53
- fake_call.stub :id => random_call_id
54
- fake_call.should_receive(:hangup).once
53
+ allow(fake_call).to receive_messages :id => random_call_id
54
+ expect(fake_call).to receive(:hangup).once
55
55
  Adhearsion.active_calls << fake_call
56
56
  end
57
57
 
@@ -63,9 +63,9 @@ module Adhearsion
63
63
  it "should trigger shutdown handlers synchronously" do
64
64
  foo = lambda { |b| b }
65
65
 
66
- foo.should_receive(:[]).once.with(:a).ordered
67
- foo.should_receive(:[]).once.with(:b).ordered
68
- foo.should_receive(:[]).once.with(:c).ordered
66
+ expect(foo).to receive(:[]).once.with(:a).ordered
67
+ expect(foo).to receive(:[]).once.with(:b).ordered
68
+ expect(foo).to receive(:[]).once.with(:c).ordered
69
69
 
70
70
  Events.shutdown { sleep 2; foo[:a] }
71
71
  Events.shutdown { sleep 1; foo[:b] }
@@ -75,37 +75,37 @@ module Adhearsion
75
75
  end
76
76
 
77
77
  it "should stop the console" do
78
- Console.should_receive(:stop).once
78
+ expect(Console).to receive(:stop).once
79
79
  Adhearsion::Process.final_shutdown
80
80
  end
81
81
  end
82
82
 
83
83
  it 'should handle subsequent :shutdown events in the correct order' do
84
84
  Adhearsion::Process.booted
85
- Adhearsion::Process.state_name.should be :running
85
+ expect(Adhearsion::Process.state_name).to be :running
86
86
  Adhearsion::Process.shutdown
87
- Adhearsion::Process.state_name.should be :stopping
87
+ expect(Adhearsion::Process.state_name).to be :stopping
88
88
  Adhearsion::Process.shutdown
89
- Adhearsion::Process.state_name.should be :rejecting
89
+ expect(Adhearsion::Process.state_name).to be :rejecting
90
90
  Adhearsion::Process.shutdown
91
- Adhearsion::Process.state_name.should be :stopped
92
- Adhearsion::Process.instance.should_receive(:die_now!).once
91
+ expect(Adhearsion::Process.state_name).to be :stopped
92
+ expect(Adhearsion::Process.instance).to receive(:die_now!).once
93
93
  Adhearsion::Process.shutdown
94
94
  sleep 0.2
95
95
  end
96
96
 
97
97
  it 'should forcibly kill the Adhearsion process on :force_stop' do
98
- ::Process.should_receive(:exit).once.with(1)
98
+ expect(::Process).to receive(:exit).once.with(1)
99
99
  Adhearsion::Process.force_stop
100
100
  end
101
101
 
102
102
  describe "#fqdn" do
103
103
  it "should be a string" do
104
- Adhearsion::Process.fqdn.should be_a String
104
+ expect(Adhearsion::Process.fqdn).to be_a String
105
105
  end
106
106
 
107
107
  context "when networking issues crop up" do
108
- before { Socket.stub(:gethostbyname).and_raise(SocketError) }
108
+ before { allow(Socket).to receive(:gethostbyname).and_raise(SocketError) }
109
109
 
110
110
  it "should raise SocketError" do
111
111
  expect { Adhearsion::Process.fqdn }.to raise_error(SocketError)
@@ -23,7 +23,7 @@ module Adhearsion
23
23
 
24
24
  def initialize_punchblock(options = {})
25
25
  reset_default_config
26
- Initializer.stub(:connect)
26
+ allow(Initializer).to receive(:connect)
27
27
  Adhearsion.config.punchblock do |config|
28
28
  config.platform = options[:platform] if options.has_key?(:platform)
29
29
  config.username = options[:username] if options.has_key?(:username)
@@ -47,71 +47,71 @@ module Adhearsion
47
47
  let(:mock_client) { double 'Client' }
48
48
 
49
49
  before do
50
- mock_call.stub :id => call_id
50
+ allow(mock_call).to receive_messages :id => call_id
51
51
  mock_client.as_null_object
52
- mock_client.stub :event_handler= => true
52
+ allow(mock_client).to receive_messages :event_handler= => true
53
53
  Events.refresh!
54
- Adhearsion::Process.stub :fqdn => 'hostname'
55
- ::Process.stub :pid => 1234
54
+ allow(Adhearsion::Process).to receive_messages :fqdn => 'hostname'
55
+ allow(::Process).to receive_messages :pid => 1234
56
56
  end
57
57
 
58
58
  describe "starts the client with the default values" do
59
59
  subject { initialize_punchblock }
60
60
 
61
61
  it "should set properly the username value" do
62
- subject.username.should be == 'usera@127.0.0.1'
62
+ expect(subject.username).to eq('usera@127.0.0.1')
63
63
  end
64
64
 
65
65
  it "should set properly the password value" do
66
- subject.password.should be == '1'
66
+ expect(subject.password).to eq('1')
67
67
  end
68
68
 
69
69
  it "should set properly the host value" do
70
- subject.host.should be_nil
70
+ expect(subject.host).to be_nil
71
71
  end
72
72
 
73
73
  it "should set properly the port value" do
74
- subject.port.should be_nil
74
+ expect(subject.port).to be_nil
75
75
  end
76
76
 
77
77
  it "should set properly the certs_directory value" do
78
- subject.certs_directory.should be_nil
78
+ expect(subject.certs_directory).to be_nil
79
79
  end
80
80
 
81
81
  it "should set properly the root_domain value" do
82
- subject.root_domain.should be_nil
82
+ expect(subject.root_domain).to be_nil
83
83
  end
84
84
 
85
85
  it "should properly set the reconnect_attempts value" do
86
- subject.reconnect_attempts.should be == 1.0/0.0
86
+ expect(subject.reconnect_attempts).to eq(1.0/0.0)
87
87
  end
88
88
 
89
89
  it "should properly set the reconnect_timer value" do
90
- subject.reconnect_timer.should be == 5
90
+ expect(subject.reconnect_timer).to eq(5)
91
91
  end
92
92
  end
93
93
 
94
94
  it "starts the client with the correct resource" do
95
95
  username = "usera@127.0.0.1/hostname-1234"
96
96
 
97
- Punchblock::Connection::XMPP.should_receive(:new).once.with(hash_including :username => username).and_return mock_client
97
+ expect(Punchblock::Connection::XMPP).to receive(:new).once.with(hash_including :username => username).and_return mock_client
98
98
  initialize_punchblock
99
99
  end
100
100
 
101
101
  context "when the fqdn is not available" do
102
102
  it "should use the local hostname instead" do
103
- Adhearsion::Process.stub(:fqdn).and_raise SocketError
104
- Socket.stub(:gethostname).and_return 'local_hostname'
103
+ allow(Adhearsion::Process).to receive(:fqdn).and_raise SocketError
104
+ allow(Socket).to receive(:gethostname).and_return 'local_hostname'
105
105
 
106
106
  username = "usera@127.0.0.1/local_hostname-1234"
107
107
 
108
- Punchblock::Connection::XMPP.should_receive(:new).once.with(hash_including :username => username).and_return mock_client
108
+ expect(Punchblock::Connection::XMPP).to receive(:new).once.with(hash_including :username => username).and_return mock_client
109
109
  initialize_punchblock
110
110
  end
111
111
  end
112
112
 
113
113
  it "starts the client with any overridden settings" do
114
- Punchblock::Connection::XMPP.should_receive(:new).once.with(username: 'userb@127.0.0.1/foo', password: '123', host: 'foo.bar.com', port: 200, certs: '/foo/bar', connection_timeout: 20, root_domain: 'foo.com').and_return mock_client
114
+ expect(Punchblock::Connection::XMPP).to receive(:new).once.with(username: 'userb@127.0.0.1/foo', password: '123', host: 'foo.bar.com', port: 200, certs: '/foo/bar', connection_timeout: 20, root_domain: 'foo.com').and_return mock_client
115
115
  initialize_punchblock username: 'userb@127.0.0.1/foo', password: '123', host: 'foo.bar.com', port: 200, certs_directory: '/foo/bar', connection_timeout: 20, root_domain: 'foo.com'
116
116
  end
117
117
 
@@ -119,12 +119,12 @@ module Adhearsion
119
119
  it 'should block until the connection is established' do
120
120
  reset_default_config
121
121
  mock_connection = double :mock_connection
122
- mock_connection.should_receive(:register_event_handler).once
123
- Punchblock::Client.should_receive(:new).once.and_return mock_connection
124
- mock_connection.should_receive(:run).once
122
+ expect(mock_connection).to receive(:register_event_handler).once
123
+ expect(Punchblock::Client).to receive(:new).once.and_return mock_connection
124
+ expect(mock_connection).to receive(:run).once
125
125
  t = Thread.new { Initializer.init; Initializer.run }
126
126
  t.join 5
127
- t.status.should be == "sleep"
127
+ expect(t.status).to eq("sleep")
128
128
  Events.trigger_immediately :punchblock, Punchblock::Connection::Connected.new
129
129
  t.join
130
130
  end
@@ -135,8 +135,8 @@ module Adhearsion
135
135
  Adhearsion::Process.reset
136
136
  Initializer.config = reset_default_config
137
137
  Initializer.config.reconnect_attempts = 1
138
- Adhearsion::Logging.get_logger(Initializer).should_receive(:fatal).at_most(:once)
139
- Initializer.stub(:client).and_return mock_client
138
+ expect(Adhearsion::Logging.get_logger(Initializer)).to receive(:fatal).at_most(:once)
139
+ allow(Initializer).to receive(:client).and_return mock_client
140
140
  end
141
141
 
142
142
  after :each do
@@ -145,29 +145,29 @@ module Adhearsion
145
145
 
146
146
  it 'should reset the Adhearsion process state to "booting"' do
147
147
  Adhearsion::Process.booted
148
- Adhearsion::Process.state_name.should be == :running
149
- mock_client.stub(:run).and_raise Punchblock::DisconnectedError
150
- Adhearsion::Process.should_receive(:reset).at_least(:once)
148
+ expect(Adhearsion::Process.state_name).to eq(:running)
149
+ allow(mock_client).to receive(:run).and_raise Punchblock::DisconnectedError
150
+ expect(Adhearsion::Process).to receive(:reset).at_least(:once)
151
151
  Initializer.connect_to_server
152
152
  end
153
153
 
154
154
  it 'should retry the connection the specified number of times' do
155
155
  Initializer.config.reconnect_attempts = 3
156
- mock_client.stub(:run).and_raise Punchblock::DisconnectedError
156
+ allow(mock_client).to receive(:run).and_raise Punchblock::DisconnectedError
157
157
  Initializer.connect_to_server
158
- Initializer.attempts.should be == 3
158
+ expect(Initializer.attempts).to eq(3)
159
159
  end
160
160
 
161
161
  it 'should preserve a Punchblock::ProtocolError exception and give up' do
162
- mock_client.stub(:run).and_raise Punchblock::ProtocolError
162
+ allow(mock_client).to receive(:run).and_raise Punchblock::ProtocolError
163
163
  expect { Initializer.connect_to_server }.to raise_error Punchblock::ProtocolError
164
164
  end
165
165
 
166
166
  it 'should not attempt to reconnect if Adhearsion is shutting down' do
167
167
  Adhearsion::Process.booted
168
168
  Adhearsion::Process.shutdown
169
- mock_client.stub(:run).and_raise Punchblock::DisconnectedError
170
- Initializer.should_not raise_error Punchblock::DisconnectedError
169
+ allow(mock_client).to receive(:run).and_raise Punchblock::DisconnectedError
170
+ expect { Initializer.connect_to_server }.not_to raise_error
171
171
  end
172
172
  end
173
173
 
@@ -175,7 +175,7 @@ module Adhearsion
175
175
  let(:overrides) { {:username => 'test', :password => '123', :host => 'foo.bar.com', :port => 200, :certs => nil, :connection_timeout => 20, :root_domain => 'foo.com'} }
176
176
 
177
177
  it 'should start an Asterisk PB connection' do
178
- Punchblock::Connection::Asterisk.should_receive(:new).once.with(overrides).and_return mock_client
178
+ expect(Punchblock::Connection::Asterisk).to receive(:new).once.with(overrides).and_return mock_client
179
179
  initialize_punchblock overrides.merge(:platform => :asterisk)
180
180
  end
181
181
  end
@@ -184,13 +184,13 @@ module Adhearsion
184
184
  let(:overrides) { {:username => 'test', :password => '123', :host => 'foo.bar.com', :port => 200, :certs => nil, :connection_timeout => 20, :root_domain => 'foo.com'} }
185
185
 
186
186
  it 'should start a FreeSWITCH PB connection' do
187
- Punchblock::Connection::Freeswitch.should_receive(:new).once.with(overrides).and_return mock_client
187
+ expect(Punchblock::Connection::Freeswitch).to receive(:new).once.with(overrides).and_return mock_client
188
188
  initialize_punchblock overrides.merge(:platform => :freeswitch)
189
189
  end
190
190
  end
191
191
 
192
192
  it 'should place events from Punchblock into the event handler' do
193
- Events.instance.should_receive(:trigger).once.with(:punchblock, offer)
193
+ expect(Events.instance).to receive(:trigger).once.with(:punchblock, offer)
194
194
  initialize_punchblock
195
195
  Initializer.client.handle_event offer
196
196
  end
@@ -198,15 +198,15 @@ module Adhearsion
198
198
  describe "dispatching an offer" do
199
199
  before do
200
200
  initialize_punchblock
201
- Adhearsion::Process.should_receive(:state_name).once.and_return process_state
202
- Adhearsion::Call.should_receive(:new).once.and_return mock_call
201
+ expect(Adhearsion::Process).to receive(:state_name).once.and_return process_state
202
+ expect(Adhearsion::Call).to receive(:new).once.and_return mock_call
203
203
  end
204
204
 
205
205
  context "when the Adhearsion::Process is :booting" do
206
206
  let(:process_state) { :booting }
207
207
 
208
208
  it 'should reject a call with cause :declined' do
209
- mock_call.should_receive(:reject).once.with(:decline)
209
+ expect(mock_call).to receive(:reject).once.with(:decline)
210
210
  end
211
211
  end
212
212
 
@@ -218,7 +218,7 @@ module Adhearsion
218
218
  Adhearsion.router do
219
219
  route 'foobar', Class.new
220
220
  end
221
- Adhearsion.router.should_receive(:handle).once.with mock_call
221
+ expect(Adhearsion.router).to receive(:handle).once.with mock_call
222
222
  end
223
223
  end
224
224
  end
@@ -227,7 +227,7 @@ module Adhearsion
227
227
  let(:process_state) { :rejecting }
228
228
 
229
229
  it 'should reject a call with cause :declined' do
230
- mock_call.should_receive(:reject).once.with(:decline)
230
+ expect(mock_call).to receive(:reject).once.with(:decline)
231
231
  end
232
232
  end
233
233
 
@@ -235,7 +235,7 @@ module Adhearsion
235
235
  let(:process_state) { :foobar }
236
236
 
237
237
  it 'should reject a call with cause :error' do
238
- mock_call.should_receive(:reject).once.with(:error)
238
+ expect(mock_call).to receive(:reject).once.with(:error)
239
239
  end
240
240
  end
241
241
 
@@ -246,14 +246,14 @@ module Adhearsion
246
246
  let(:component) { double 'ComponentNode' }
247
247
  let(:mock_event) { double 'Event' }
248
248
 
249
- before { mock_event.stub target_call_id: call_id, source: component }
249
+ before { allow(mock_event).to receive_messages target_call_id: call_id, source: component }
250
250
 
251
251
  before do
252
252
  initialize_punchblock
253
253
  end
254
254
 
255
255
  it "should place the event in the call's inbox" do
256
- component.should_receive(:trigger_event_handler).once.with mock_event
256
+ expect(component).to receive(:trigger_event_handler).once.with mock_event
257
257
  Events.trigger_immediately :punchblock, mock_event
258
258
  end
259
259
  end
@@ -261,7 +261,7 @@ module Adhearsion
261
261
  describe "dispatching a call event" do
262
262
  let(:mock_event) { double 'Event' }
263
263
 
264
- before { mock_event.stub target_call_id: call_id }
264
+ before { allow(mock_event).to receive_messages target_call_id: call_id }
265
265
 
266
266
  describe "with an active call" do
267
267
  before do
@@ -269,15 +269,31 @@ module Adhearsion
269
269
  Adhearsion.active_calls << mock_call
270
270
  end
271
271
 
272
- it "should place the event in the call's inbox" do
273
- mock_call.async.should_receive(:deliver_message).once.with(mock_event)
272
+ it "should forward the event to the call actor" do
273
+ events = []
274
+ mock_call.register_event_handler do |event|
275
+ events << event
276
+ end
277
+ Initializer.dispatch_call_event mock_event
278
+ sleep 0.5
279
+ expect(events).to eql([mock_event])
280
+ end
281
+
282
+ it "should not block on the call handling the event" do
283
+
284
+ mock_call.register_event_handler do |event|
285
+ sleep 5
286
+ end
287
+ start_time = Time.now
274
288
  Initializer.dispatch_call_event mock_event
289
+ sleep 0.5
290
+ expect(Time.now - start_time).to be < 1
275
291
  end
276
292
  end
277
293
 
278
294
  describe "with an inactive call" do
279
295
  it "should log a warning" do
280
- Adhearsion::Logging.get_logger(Initializer).should_receive(:warn).once.with("Event received for inactive call #{call_id}: #{mock_event.inspect}")
296
+ expect(Adhearsion::Logging.get_logger(Initializer)).to receive(:warn).once.with("Event received for inactive call #{call_id}: #{mock_event.inspect}")
281
297
  Initializer.dispatch_call_event mock_event
282
298
  end
283
299
  end
@@ -289,7 +305,7 @@ module Adhearsion
289
305
  end
290
306
 
291
307
  it "should log a warning" do
292
- Adhearsion::Logging.get_logger(Initializer).should_receive(:warn).once.with("Event received for inactive call #{call_id}: #{mock_event.inspect}")
308
+ expect(Adhearsion::Logging.get_logger(Initializer)).to receive(:warn).once.with("Event received for inactive call #{call_id}: #{mock_event.inspect}")
293
309
  Initializer.dispatch_call_event mock_event
294
310
  end
295
311
  end
@@ -309,11 +325,11 @@ module Adhearsion
309
325
  end
310
326
 
311
327
  it "should set properly the username value" do
312
- subject.username.should be == 'userb@127.0.0.1'
328
+ expect(subject.username).to eq('userb@127.0.0.1')
313
329
  end
314
330
 
315
331
  it "should set properly the password value" do
316
- subject.password.should be == 'abc123'
332
+ expect(subject.password).to eq('abc123')
317
333
  end
318
334
  end
319
335
  end
@@ -332,8 +348,8 @@ module Adhearsion
332
348
 
333
349
  Initializer.handle_event ami_event
334
350
 
335
- latch.wait(1).should be true
336
- result.should be ami_event
351
+ expect(latch.wait(1)).to be true
352
+ expect(result).to be ami_event
337
353
  end
338
354
  end
339
355
  end
@@ -6,7 +6,7 @@ module Adhearsion
6
6
  describe PunchblockPlugin do
7
7
  it "should make the client accessible from the Initializer" do
8
8
  PunchblockPlugin::Initializer.client = :foo
9
- PunchblockPlugin.client.should be :foo
9
+ expect(PunchblockPlugin.client).to be :foo
10
10
  PunchblockPlugin::Initializer.client = nil
11
11
  end
12
12
 
@@ -15,11 +15,11 @@ module Adhearsion
15
15
  let(:response) { :foo }
16
16
  let(:mock_client) { double 'Client' }
17
17
 
18
- let(:execute_expectation) { PunchblockPlugin.client.should_receive(:execute_command).once }
18
+ let(:execute_expectation) { expect(PunchblockPlugin.client).to receive(:execute_command).once }
19
19
 
20
20
  before do
21
21
  PunchblockPlugin::Initializer.client = mock_client
22
- message.stub :execute! => true
22
+ allow(message).to receive_messages :execute! => true
23
23
  message.response = response
24
24
  execute_expectation
25
25
  end
@@ -38,12 +38,12 @@ module Adhearsion
38
38
  slow_command.response = response
39
39
  end
40
40
  PunchblockPlugin.execute_component slow_command
41
- (Time.now - starting_time).should >= 0.4
41
+ expect(Time.now - starting_time).to be >= 0.4
42
42
  end
43
43
 
44
44
  describe "with a successful response" do
45
45
  it "returns the executed command" do
46
- PunchblockPlugin.execute_component(message).should be message
46
+ expect(PunchblockPlugin.execute_component(message)).to be message
47
47
  end
48
48
  end
49
49
 
@@ -51,7 +51,7 @@ module Adhearsion
51
51
  let(:response) { Exception.new }
52
52
 
53
53
  it "raises the error" do
54
- lambda { PunchblockPlugin.execute_component message }.should raise_error Exception
54
+ expect { PunchblockPlugin.execute_component message }.to raise_error Exception
55
55
  end
56
56
  end
57
57
  end