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,18 +16,18 @@ module Adhearsion
16
16
  end
17
17
 
18
18
  it 'can add a call to the collection' do
19
- subject.any?.should be == false
19
+ expect(subject.any?).to eq(false)
20
20
  call = Call.new new_offer
21
21
  subject << call
22
- call.should be_a Adhearsion::Call
23
- subject.size.should be == 1
24
- subject[call.id].should be call
22
+ expect(call).to be_a Adhearsion::Call
23
+ expect(subject.size).to eq(1)
24
+ expect(subject[call.id]).to be call
25
25
  end
26
26
 
27
27
  it '#size should return the number of calls in the collection' do
28
- subject.size.should be == 0
28
+ expect(subject.size).to eq(0)
29
29
  subject << call
30
- subject.size.should be == 1
30
+ expect(subject.size).to eq(1)
31
31
  end
32
32
 
33
33
  describe "removing a call" do
@@ -39,9 +39,9 @@ module Adhearsion
39
39
  before { subject.remove_inactive_call deleted_call }
40
40
 
41
41
  it "should remove the call from the collection" do
42
- subject.size.should be == number_of_calls - 1
43
- subject[deleted_call.id].should be_nil
44
- subject.with_uri(deleted_call.uri).should be_nil
42
+ expect(subject.size).to eq(number_of_calls - 1)
43
+ expect(subject[deleted_call.id]).to be_nil
44
+ expect(subject.with_uri(deleted_call.uri)).to be_nil
45
45
  end
46
46
  end
47
47
 
@@ -50,14 +50,14 @@ module Adhearsion
50
50
  @call_id = deleted_call.id
51
51
  @call_uri = deleted_call.uri
52
52
  Celluloid::Actor.kill deleted_call
53
- deleted_call.should_not be_alive
53
+ expect(deleted_call.alive?).to be false
54
54
  subject.remove_inactive_call deleted_call
55
55
  end
56
56
 
57
57
  it "should remove the call from the collection" do
58
- subject.size.should be == number_of_calls - 1
59
- subject[@call_id].should be_nil
60
- subject.with_uri(@call_uri).should be_nil
58
+ expect(subject.size).to eq(number_of_calls - 1)
59
+ expect(subject[@call_id]).to be_nil
60
+ expect(subject.with_uri(@call_uri)).to be_nil
61
61
  end
62
62
  end
63
63
 
@@ -65,9 +65,9 @@ module Adhearsion
65
65
  before { subject.remove_inactive_call deleted_call.id }
66
66
 
67
67
  it "should remove the call from the collection" do
68
- subject.size.should be == number_of_calls - 1
69
- subject[deleted_call.id].should be_nil
70
- subject.with_uri(deleted_call.uri).should be_nil
68
+ expect(subject.size).to eq(number_of_calls - 1)
69
+ expect(subject[deleted_call.id]).to be_nil
70
+ expect(subject.with_uri(deleted_call.uri)).to be_nil
71
71
  end
72
72
  end
73
73
  end
@@ -79,7 +79,7 @@ module Adhearsion
79
79
  tagged_call = calls.last
80
80
  tagged_call.tag :moderator
81
81
 
82
- subject.with_tag(:moderator).should be == [tagged_call]
82
+ expect(subject.with_tag(:moderator)).to eq([tagged_call])
83
83
  end
84
84
 
85
85
  it "when a call is dead, ignore it in the search" do
@@ -89,20 +89,20 @@ module Adhearsion
89
89
  tagged_call.tag :moderator
90
90
  Celluloid::Actor.kill tagged_call
91
91
 
92
- subject.with_tag(:moderator).should be == []
92
+ expect(subject.with_tag(:moderator)).to eq([])
93
93
  end
94
94
  end
95
95
 
96
96
  it "finding calls by uri" do
97
97
  calls.each { |call| subject << call }
98
98
 
99
- subject.with_uri(calls.last.uri).should be == calls.last
99
+ expect(subject.with_uri(calls.last.uri)).to eq(calls.last)
100
100
  end
101
101
 
102
102
  describe "#<<" do
103
103
  it "should allow chaining" do
104
104
  subject << Call.new(new_offer) << Call.new(new_offer)
105
- subject.size.should be == 2
105
+ expect(subject.size).to eq(2)
106
106
  end
107
107
  end
108
108
 
@@ -117,9 +117,9 @@ module Adhearsion
117
117
 
118
118
  sleep 0.1
119
119
 
120
- subject.size.should be == size_before
121
- subject[call_id].should be_nil
122
- subject.with_uri(call_uri).should be_nil
120
+ expect(subject.size).to eq(size_before)
121
+ expect(subject[call_id]).to be_nil
122
+ expect(subject.with_uri(call_uri)).to be_nil
123
123
  end
124
124
  end
125
125
 
@@ -133,7 +133,7 @@ module Adhearsion
133
133
  end
134
134
 
135
135
  def crash
136
- lambda { call.crash_me }.should raise_error(StandardError, "Someone crashed me")
136
+ expect { call.crash_me }.to raise_error(StandardError, "Someone crashed me")
137
137
  sleep 0.5
138
138
  end
139
139
 
@@ -143,20 +143,20 @@ module Adhearsion
143
143
  size_before = subject.size
144
144
 
145
145
  subject << call
146
- subject.size.should be > size_before
147
- subject[call_id].should be call
148
- subject.with_uri(call_uri).should be call
146
+ expect(subject.size).to be > size_before
147
+ expect(subject[call_id]).to be call
148
+ expect(subject.with_uri(call_uri)).to be call
149
149
 
150
150
  crash
151
- subject.size.should be == size_before
152
- subject[call_id].should be_nil
153
- subject.with_uri(call_uri).should be_nil
151
+ expect(subject.size).to eq(size_before)
152
+ expect(subject[call_id]).to be_nil
153
+ expect(subject.with_uri(call_uri)).to be_nil
154
154
  end
155
155
 
156
156
  it "is sends a hangup command for the call" do
157
157
  call_id = call.id
158
- PunchblockPlugin.stub :client => double('Client')
159
- PunchblockPlugin.client.should_receive(:execute_command).once.with(Punchblock::Command::Hangup.new, :async => true, :call_id => call_id)
158
+ allow(PunchblockPlugin).to receive_messages :client => double('Client')
159
+ expect(PunchblockPlugin.client).to receive(:execute_command).once.with(Punchblock::Command::Hangup.new, :async => true, :call_id => call_id)
160
160
 
161
161
  subject << call
162
162
 
@@ -165,7 +165,7 @@ module Adhearsion
165
165
 
166
166
  it "shuts down the actor" do
167
167
  crash
168
- call.should_not be_alive
168
+ expect(call.alive?).to be false
169
169
  end
170
170
  end
171
171
  end
@@ -11,30 +11,30 @@ describe Adhearsion::Configuration do
11
11
  end
12
12
 
13
13
  it "should have an empty configuration for the platform" do
14
- subject.should respond_to :platform
14
+ expect(subject).to respond_to :platform
15
15
  end
16
16
 
17
17
  it "should have a platform configuration object" do
18
- subject.platform.should be_instance_of Loquacious::Configuration
18
+ expect(subject.platform).to be_instance_of Loquacious::Configuration
19
19
  end
20
20
 
21
21
  it "should initialize root to nil" do
22
- subject.platform.root.should be_nil
22
+ expect(subject.platform.root).to be_nil
23
23
  end
24
24
 
25
25
  it "should initialize logging to level info" do
26
- subject.platform.logging.level.should be == :info
26
+ expect(subject.platform.logging.level).to eq(:info)
27
27
  end
28
28
 
29
29
  it "should allow to update a config value" do
30
- subject.platform.environment.should be == :development
30
+ expect(subject.platform.environment).to eq(:development)
31
31
  subject.platform.environment = :production
32
- subject.platform.environment.should be == :production
32
+ expect(subject.platform.environment).to eq(:production)
33
33
  end
34
34
 
35
35
  it "should allow to create new config values" do
36
36
  subject.platform.bar = "foo"
37
- subject.platform.bar.should be == "foo"
37
+ expect(subject.platform.bar).to eq("foo")
38
38
  end
39
39
  end
40
40
 
@@ -47,34 +47,34 @@ describe Adhearsion::Configuration do
47
47
  end
48
48
 
49
49
  it "should return the root value" do
50
- subject.platform.root.should be == "foo"
50
+ expect(subject.platform.root).to eq("foo")
51
51
  end
52
52
 
53
53
  it "should return the environment value" do
54
- subject.platform.environment.should be == :development
54
+ expect(subject.platform.environment).to eq(:development)
55
55
  end
56
56
 
57
57
  it "should return a description for the platform configuration" do
58
- Adhearsion.config.description(:platform).should be_instance_of String
58
+ expect(Adhearsion.config.description(:platform)).to be_instance_of String
59
59
  end
60
60
 
61
61
  it "should allow to update a config value" do
62
- subject.platform.environment.should be == :development
62
+ expect(subject.platform.environment).to eq(:development)
63
63
  subject.platform.environment = :production
64
- subject.platform.environment.should be == :production
64
+ expect(subject.platform.environment).to eq(:production)
65
65
  end
66
66
 
67
67
  it "should allow to create new config values" do
68
68
  subject.platform.bar = "bazz"
69
- subject.platform.bar.should be == "bazz"
69
+ expect(subject.platform.bar).to eq("bazz")
70
70
  end
71
71
  end
72
72
 
73
73
  describe "when configuring a non existing object" do
74
74
  it "should raise a ConfigurationError" do
75
- lambda {
75
+ expect {
76
76
  Adhearsion.config.foo.bar = "bazz"
77
- }.should raise_error Adhearsion::Configuration::ConfigurationError, "Invalid plugin foo"
77
+ }.to raise_error Adhearsion::Configuration::ConfigurationError, "Invalid plugin foo"
78
78
  end
79
79
  end
80
80
 
@@ -86,11 +86,11 @@ describe Adhearsion::Configuration do
86
86
  subject{ Adhearsion.config[:platform] }
87
87
 
88
88
  it "should return the valid platform configuration object" do
89
- subject.should be_instance_of ::Loquacious::Configuration
89
+ expect(subject).to be_instance_of ::Loquacious::Configuration
90
90
  end
91
91
 
92
92
  it "should allow to retrieve any platform configuration value" do
93
- subject.environment.should be == :development
93
+ expect(subject.environment).to eq(:development)
94
94
  end
95
95
 
96
96
  describe "if configuration has a named environment" do
@@ -129,13 +129,13 @@ describe Adhearsion::Configuration do
129
129
  end
130
130
 
131
131
  it "should return by default the development value" do
132
- subject.platform.my_level.should be == 1
132
+ expect(subject.platform.my_level).to eq(1)
133
133
  end
134
134
 
135
135
  [:staging, :production, :test].each do |env|
136
136
  it "should return the #{env.to_s} value when environment set to #{env.to_s}" do
137
137
  config_object.platform.environment = env
138
- subject.platform.my_level.should be == env_values[env]
138
+ expect(subject.platform.my_level).to eq(env_values[env])
139
139
  end
140
140
  end
141
141
  end
@@ -149,12 +149,12 @@ describe Adhearsion::Configuration do
149
149
  end
150
150
 
151
151
  it "should return 'development' by default" do
152
- Adhearsion.config.platform.environment.should be == :development
152
+ expect(Adhearsion.config.platform.environment).to eq(:development)
153
153
  end
154
154
 
155
155
  [:development, :production, :staging, :test].each do |env|
156
156
  it "should respond to #{env.to_s}" do
157
- Adhearsion.config.should respond_to(env)
157
+ expect(Adhearsion.config).to respond_to(env)
158
158
  end
159
159
  end
160
160
 
@@ -162,20 +162,20 @@ describe Adhearsion::Configuration do
162
162
  [:production, :staging, :test].each do |env|
163
163
  it "should override the environment value with #{env.to_s} when set in ENV value" do
164
164
  ENV['AHN_ENV'] = env.to_s
165
- Adhearsion.config.platform.environment.should be == env
165
+ expect(Adhearsion.config.platform.environment).to eq(env)
166
166
  end
167
167
  end
168
168
  end
169
169
 
170
170
  it "should not override the default environment with the ENV value if valid" do
171
171
  ENV['AHN_ENV'] = "invalid_value"
172
- Adhearsion.config.platform.environment.should be == :development
172
+ expect(Adhearsion.config.platform.environment).to eq(:development)
173
173
  end
174
174
 
175
175
  it "should allow to add a new environment" do
176
- Adhearsion.config.valid_environment?(:another_environment).should be == false
176
+ expect(Adhearsion.config.valid_environment?(:another_environment)).to eq(false)
177
177
  Adhearsion.environments << :another_environment
178
- Adhearsion.config.valid_environment?(:another_environment).should be == true
178
+ expect(Adhearsion.config.valid_environment?(:another_environment)).to eq(true)
179
179
  end
180
180
 
181
181
  end
@@ -189,16 +189,16 @@ describe Adhearsion::Configuration do
189
189
 
190
190
  it "should retrieve a string with the platform configuration" do
191
191
  desc = subject.description :platform, :show_values => false
192
- desc.length.should be > 0
193
- desc.should match(/^.*environment.*$/)
194
- desc.should match(/^.*root.*$/)
192
+ expect(desc.length).to be > 0
193
+ expect(desc).to match(/^.*environment.*$/)
194
+ expect(desc).to match(/^.*root.*$/)
195
195
  end
196
196
 
197
197
  it "should retrieve a string with the platform configuration and values" do
198
198
  desc = subject.description :platform
199
- desc.length.should be > 0
200
- desc.should match(/^.*environment.*:development.*$/)
201
- desc.should match(/^.*root.*$/)
199
+ expect(desc.length).to be > 0
200
+ expect(desc).to match(/^.*environment.*:development.*$/)
201
+ expect(desc).to match(/^.*root.*$/)
202
202
  end
203
203
 
204
204
  describe "if there are plugins installed" do
@@ -219,9 +219,9 @@ describe Adhearsion::Configuration do
219
219
  subject { Adhearsion.config.my_plugin }
220
220
 
221
221
  it "should have the correct values" do
222
- subject[:name].should be == 'user'
223
- subject[:password].should be == 'password'
224
- subject[:host].should be == 'localhost'
222
+ expect(subject[:name]).to eq('user')
223
+ expect(subject[:password]).to eq('password')
224
+ expect(subject[:host]).to eq('localhost')
225
225
  end
226
226
  end
227
227
 
@@ -229,9 +229,9 @@ describe Adhearsion::Configuration do
229
229
  subject { Adhearsion.config[:my_plugin] }
230
230
 
231
231
  it "should have the correct values" do
232
- subject[:name].should be == 'user'
233
- subject[:password].should be == 'password'
234
- subject[:host].should be == 'localhost'
232
+ expect(subject[:name]).to eq('user')
233
+ expect(subject[:password]).to eq('password')
234
+ expect(subject[:host]).to eq('localhost')
235
235
  end
236
236
  end
237
237
 
@@ -256,13 +256,13 @@ describe Adhearsion::Configuration do
256
256
 
257
257
  it "should return the development value by default" do
258
258
  Adhearsion.config # initialize
259
- subject.name.should be == "development"
259
+ expect(subject.name).to eq("development")
260
260
  end
261
261
 
262
262
  [:development, :staging, :production, :test].each do |env|
263
263
  it "should return the #{env.to_s} value when environment is set to #{env.to_s}" do
264
264
  Adhearsion.config.platform.environment = env
265
- subject.name.should be == env.to_s
265
+ expect(subject.name).to eq(env.to_s)
266
266
  end
267
267
  end
268
268
  end
@@ -270,40 +270,40 @@ describe Adhearsion::Configuration do
270
270
 
271
271
  it "should retrieve a valid plugin description" do
272
272
  desc = subject.description :my_plugin
273
- desc.length.should be > 0
274
- desc.should match(/^.*name.*user.*$/)
275
- desc.should match(/^.*password.*password.*$/)
276
- desc.should match(/^.*host.*localhost.*$/)
273
+ expect(desc.length).to be > 0
274
+ expect(desc).to match(/^.*name.*user.*$/)
275
+ expect(desc).to match(/^.*password.*password.*$/)
276
+ expect(desc).to match(/^.*host.*localhost.*$/)
277
277
  end
278
278
 
279
279
  it "should retrieve a valid plugin description with no values" do
280
280
  desc = subject.description :my_plugin, :show_values => false
281
- desc.length.should be > 0
282
- desc.should match(/^.*name.*$/)
283
- desc.should match(/^.*password.*$/)
284
- desc.should match(/^.*host.*$/)
281
+ expect(desc.length).to be > 0
282
+ expect(desc).to match(/^.*name.*$/)
283
+ expect(desc).to match(/^.*password.*$/)
284
+ expect(desc).to match(/^.*host.*$/)
285
285
  end
286
286
 
287
287
  it "should retrieve both platform and plugin configuration" do
288
288
  desc = subject.description :all
289
- desc.length.should be > 0
290
- desc.should match(/^.*environment.*:development.*$/)
291
- desc.should match(/^.*root.*$/)
292
- desc.should match(/^.*name.*user.*$/)
293
- desc.should match(/^.*password.*password.*$/)
294
- desc.should match(/^.*host.*localhost.*$/)
289
+ expect(desc.length).to be > 0
290
+ expect(desc).to match(/^.*environment.*:development.*$/)
291
+ expect(desc).to match(/^.*root.*$/)
292
+ expect(desc).to match(/^.*name.*user.*$/)
293
+ expect(desc).to match(/^.*password.*password.*$/)
294
+ expect(desc).to match(/^.*host.*localhost.*$/)
295
295
  end
296
296
 
297
297
  it "should retrieve both platform and plugin configuration with no values" do
298
298
  desc = subject.description :all, :show_values => false
299
- desc.length.should be > 0
300
- desc.should match(/^.*Configuration for platform.*$/)
301
- desc.should match(/^.*environment.*$/)
302
- desc.should match(/^.*root.*$/)
303
- desc.should match(/^.*Configuration for my_plugin.*$/)
304
- desc.should match(/^.*name.*$/)
305
- desc.should match(/^.*password.*$/)
306
- desc.should match(/^.*host.*$/)
299
+ expect(desc.length).to be > 0
300
+ expect(desc).to match(/^.*Configuration for platform.*$/)
301
+ expect(desc).to match(/^.*environment.*$/)
302
+ expect(desc).to match(/^.*root.*$/)
303
+ expect(desc).to match(/^.*Configuration for my_plugin.*$/)
304
+ expect(desc).to match(/^.*name.*$/)
305
+ expect(desc).to match(/^.*password.*$/)
306
+ expect(desc).to match(/^.*host.*$/)
307
307
  end
308
308
  end
309
309
 
@@ -5,26 +5,26 @@ require 'spec_helper'
5
5
  module Adhearsion
6
6
  describe Console do
7
7
  before do
8
- Console.instance.stub :pry => nil
8
+ allow(Console.instance).to receive_messages :pry => nil
9
9
  end
10
10
 
11
11
  describe "providing hooks to include console functionality" do
12
12
  it "should allow mixing in a module globally on all CallController classes" do
13
13
  Console.mixin TestBiscuit
14
- Console.throwadogabone.should be true
14
+ expect(Console.throwadogabone).to be true
15
15
  end
16
16
  end
17
17
 
18
18
  unless defined? JRUBY_VERSION # These tests are not valid on JRuby
19
19
  describe 'testing for readline' do
20
20
  it 'should return false when detecting readline' do
21
- Readline.should_receive(:emacs_editing_mode).once.and_return true
22
- Console.cruby_with_readline?.should be true
21
+ expect(Readline).to receive(:emacs_editing_mode).once.and_return true
22
+ expect(Console.cruby_with_readline?).to be true
23
23
  end
24
24
 
25
25
  it 'should return true when detecting libedit' do
26
- Readline.should_receive(:emacs_editing_mode).once.and_raise NotImplementedError
27
- Console.cruby_with_readline?.should be false
26
+ expect(Readline).to receive(:emacs_editing_mode).once.and_raise NotImplementedError
27
+ expect(Console.cruby_with_readline?).to be false
28
28
  end
29
29
  end
30
30
  end
@@ -32,7 +32,7 @@ module Adhearsion
32
32
  describe "#log_level" do
33
33
  context "with a value" do
34
34
  it "should set the log level via Adhearsion::Logging" do
35
- Adhearsion::Logging.should_receive(:level=).once.with(:foo)
35
+ expect(Adhearsion::Logging).to receive(:level=).once.with(:foo)
36
36
  Console.log_level :foo
37
37
  end
38
38
  end
@@ -40,28 +40,28 @@ module Adhearsion
40
40
  context "without a value" do
41
41
  it "should return the current level as a symbol" do
42
42
  Adhearsion::Logging.level = :fatal
43
- Console.log_level.should be == :fatal
43
+ expect(Console.log_level).to eq(:fatal)
44
44
  end
45
45
  end
46
46
  end
47
47
 
48
48
  describe "#silence!" do
49
49
  it "should delegate to Adhearsion::Logging" do
50
- Adhearsion::Logging.should_receive(:silence!).once
50
+ expect(Adhearsion::Logging).to receive(:silence!).once
51
51
  Console.silence!
52
52
  end
53
53
  end
54
54
 
55
55
  describe "#unsilence!" do
56
56
  it "should delegate to Adhearsion::Logging" do
57
- Adhearsion::Logging.should_receive(:unsilence!).once
57
+ expect(Adhearsion::Logging).to receive(:unsilence!).once
58
58
  Console.unsilence!
59
59
  end
60
60
  end
61
61
 
62
62
  describe "#shutdown!" do
63
63
  it "should tell the process to shutdown" do
64
- Adhearsion::Process.should_receive(:shutdown!).once
64
+ expect(Adhearsion::Process).to receive(:shutdown!).once
65
65
  Console.shutdown!
66
66
  end
67
67
  end
@@ -69,9 +69,9 @@ module Adhearsion
69
69
  describe "#originate" do
70
70
  it "should be an alias for Adhearsion::OutboundCall.originate" do
71
71
  foo = nil
72
- Adhearsion::OutboundCall.should_receive(:originate).once.with(:foo, :bar).and_yield
72
+ expect(Adhearsion::OutboundCall).to receive(:originate).once.with(:foo, :bar).and_yield
73
73
  Console.originate(:foo, :bar) { foo = :bar}
74
- foo.should == :bar
74
+ expect(foo).to eq(:bar)
75
75
  end
76
76
  end
77
77
 
@@ -81,12 +81,12 @@ module Adhearsion
81
81
 
82
82
  before do
83
83
  Adhearsion.active_calls.clear
84
- call.stub(:id => call_id)
84
+ allow(call).to receive_messages(:id => call_id)
85
85
  end
86
86
 
87
87
  context "with a call" do
88
88
  it "should interact with the call" do
89
- Console.instance.should_receive(:interact_with_call).once.with call
89
+ expect(Console.instance).to receive(:interact_with_call).once.with call
90
90
  Console.take call
91
91
  end
92
92
  end
@@ -98,7 +98,7 @@ module Adhearsion
98
98
  end
99
99
 
100
100
  it "should interact with the current call" do
101
- Console.instance.should_receive(:interact_with_call).once.with call
101
+ expect(Console.instance).to receive(:interact_with_call).once.with call
102
102
  Console.take
103
103
  end
104
104
  end
@@ -107,15 +107,15 @@ module Adhearsion
107
107
  let(:call2) { Call.new }
108
108
 
109
109
  before do
110
- call2.stub :id => rand.to_s
110
+ allow(call2).to receive_messages :id => rand.to_s
111
111
  Adhearsion.active_calls << call << call2
112
112
  end
113
113
 
114
114
  it "should allow selection of the call to use" do
115
115
  mock_io = StringIO.new
116
116
  Console.input = mock_io
117
- mock_io.should_receive(:gets).once.and_return "1\n"
118
- Console.instance.should_receive(:interact_with_call).once.with call2
117
+ expect(mock_io).to receive(:gets).once.and_return "1\n"
118
+ expect(Console.instance).to receive(:interact_with_call).once.with call2
119
119
  Console.take
120
120
  end
121
121
  end
@@ -128,15 +128,15 @@ module Adhearsion
128
128
  end
129
129
 
130
130
  it "should interact with that call" do
131
- Console.instance.should_receive(:interact_with_call).once.with call
131
+ expect(Console.instance).to receive(:interact_with_call).once.with call
132
132
  Console.take call_id
133
133
  end
134
134
  end
135
135
 
136
136
  context "if an active call with that ID does not exist" do
137
137
  it "should log an error explaining that the call does not exist" do
138
- Console.logger.should_receive(:error).once.with(/does not exist/)
139
- Console.instance.should_receive(:interact_with_call).never
138
+ expect(Console.logger).to receive(:error).once.with(/does not exist/)
139
+ expect(Console.instance).to receive(:interact_with_call).never
140
140
  Console.take call_id
141
141
  end
142
142
  end
@@ -147,16 +147,16 @@ module Adhearsion
147
147
  let(:call) { Call.new }
148
148
 
149
149
  it "should pause the call's controllers, and unpause even if the interactive controller raises" do
150
- call.should_receive(:pause_controllers).once.ordered
151
- CallController.should_receive(:exec).once.ordered.and_raise StandardError
152
- call.should_receive(:resume_controllers).once.ordered
153
- lambda { Console.interact_with_call call }.should raise_error StandardError
150
+ expect(call).to receive(:pause_controllers).once.ordered
151
+ expect(CallController).to receive(:exec).once.ordered.and_raise StandardError
152
+ expect(call).to receive(:resume_controllers).once.ordered
153
+ expect { Console.interact_with_call call }.to raise_error StandardError
154
154
  end
155
155
 
156
156
  it "should execute an interactive call controller on the call" do
157
- CallController.should_receive(:exec).once do |c|
158
- c.should be_a Console::InteractiveController
159
- c.call.should be call
157
+ expect(CallController).to receive(:exec).once do |c|
158
+ expect(c).to be_a Console::InteractiveController
159
+ expect(c.call).to be call
160
160
  end
161
161
  Console.interact_with_call call
162
162
  end