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
@@ -4,10 +4,17 @@ require 'spec_helper'
4
4
 
5
5
  module Adhearsion
6
6
  describe OutboundCall do
7
- it { should be_a Call }
7
+ it { is_expected.to be_a Call }
8
8
 
9
- its(:id) { should be_nil }
10
- its(:variables) { should be == {} }
9
+ describe '#id' do
10
+ subject { super().id }
11
+ it { is_expected.to be_nil }
12
+ end
13
+
14
+ describe '#variables' do
15
+ subject { super().variables }
16
+ it { is_expected.to eq({}) }
17
+ end
11
18
 
12
19
  let(:mock_client) { double 'Punchblock Client', execute_command: true, new_call_uri: call_uri }
13
20
 
@@ -16,8 +23,15 @@ module Adhearsion
16
23
  Adhearsion.active_calls.clear
17
24
  end
18
25
 
19
- its(:client) { should be mock_client }
20
- its(:start_time) { should be nil }
26
+ describe '#client' do
27
+ subject { super().client }
28
+ it { is_expected.to be mock_client }
29
+ end
30
+
31
+ describe '#start_time' do
32
+ subject { super().start_time }
33
+ it { is_expected.to be nil }
34
+ end
21
35
 
22
36
  let(:transport) { 'xmpp' }
23
37
  let(:call_id) { SecureRandom.uuid }
@@ -30,7 +44,7 @@ module Adhearsion
30
44
  foo = :bar
31
45
  subject.after(1) { foo = :baz }
32
46
  sleep 1.1
33
- foo.should == :baz
47
+ expect(foo).to eq(:baz)
34
48
  end
35
49
 
36
50
  describe ".originate" do
@@ -40,18 +54,18 @@ module Adhearsion
40
54
 
41
55
  before do
42
56
  mock_call
43
- OutboundCall.should_receive(:new).and_return mock_call
57
+ expect(OutboundCall).to receive(:new).and_return mock_call
44
58
  end
45
59
 
46
60
  it "should dial the call to the correct endpoint and return it" do
47
- mock_call.wrapped_object.should_receive(:dial).with(to, :from => 'foo').once
48
- OutboundCall.originate(to, :from => 'foo').should be mock_call
61
+ expect(mock_call.wrapped_object).to receive(:dial).with(to, :from => 'foo').once
62
+ expect(OutboundCall.originate(to, :from => 'foo')).to be mock_call
49
63
  end
50
64
 
51
65
  it "should run through the router when the call is answered" do
52
- mock_call.wrapped_object.should_receive(:dial).once
66
+ expect(mock_call.wrapped_object).to receive(:dial).once
53
67
 
54
- Adhearsion.router.should_receive(:handle).once.with(mock_call)
68
+ expect(Adhearsion.router).to receive(:handle).once.with(mock_call)
55
69
 
56
70
  OutboundCall.originate(to) << Punchblock::Event::Answered.new
57
71
  end
@@ -60,15 +74,15 @@ module Adhearsion
60
74
  let(:controller) { CallController }
61
75
 
62
76
  it "should execute the controller on the call when it is answered" do
63
- mock_call.should_receive(:dial).once.with(to, {})
64
- mock_call.should_receive(:execute_controller).once.with kind_of(controller), kind_of(Proc)
77
+ expect(mock_call).to receive(:dial).once.with(to, {})
78
+ expect(mock_call).to receive(:execute_controller).once.with kind_of(controller), kind_of(Proc)
65
79
  call = OutboundCall.originate to, :controller => controller
66
80
  call << Punchblock::Event::Answered.new
67
81
  end
68
82
 
69
83
  it "should hangup the call after all controllers have executed" do
70
- mock_call.should_receive(:dial).once
71
- mock_call.should_receive(:hangup).once
84
+ expect(mock_call).to receive(:dial).once
85
+ expect(mock_call).to receive(:hangup).once
72
86
 
73
87
  call = OutboundCall.originate to, :controller => controller
74
88
  call << Punchblock::Event::Answered.new
@@ -77,9 +91,9 @@ module Adhearsion
77
91
 
78
92
  context "with controller metadata specified" do
79
93
  it "should set the metadata on the controller" do
80
- mock_call.should_receive(:dial).once.with(to, {})
94
+ expect(mock_call).to receive(:dial).once.with(to, {})
81
95
  expected_controller = controller.new mock_call, foo: 'bar'
82
- mock_call.should_receive(:execute_controller).with(expected_controller, kind_of(Proc)).once
96
+ expect(mock_call).to receive(:execute_controller).with(expected_controller, kind_of(Proc)).once
83
97
  call = OutboundCall.originate to, :controller => controller, :controller_metadata => {:foo => 'bar'}
84
98
  call << Punchblock::Event::Answered.new
85
99
  end
@@ -88,9 +102,9 @@ module Adhearsion
88
102
 
89
103
  context "when given a block" do
90
104
  it "should execute the block as a controller on the call when it is answered" do
91
- mock_call.should_receive(:dial).once.with(to, {})
92
- mock_call.should_receive(:execute_controller).once.with(kind_of(CallController), kind_of(Proc)).and_return do |controller|
93
- controller.block.call.should be == :foobar
105
+ expect(mock_call).to receive(:dial).once.with(to, {})
106
+ expect(mock_call).to receive(:execute_controller).once.with(kind_of(CallController), kind_of(Proc)) do |controller|
107
+ expect(controller.block.call).to eq(:foobar)
94
108
  end
95
109
 
96
110
  call = OutboundCall.originate to do
@@ -102,8 +116,8 @@ module Adhearsion
102
116
 
103
117
  context "when the dial fails" do
104
118
  before do
105
- subject.wrapped_object.should_receive(:write_command)
106
- Punchblock::Command::Dial.any_instance.should_receive(:response).and_return StandardError.new("User not registered")
119
+ expect(subject.wrapped_object).to receive(:write_command)
120
+ expect_any_instance_of(Punchblock::Command::Dial).to receive(:response).and_return StandardError.new("User not registered")
107
121
  end
108
122
 
109
123
  after do
@@ -117,7 +131,7 @@ module Adhearsion
117
131
  it "should kill the actor" do
118
132
  expect { subject.dial to }.to raise_error("User not registered")
119
133
  sleep 0.1
120
- subject.should_not be_alive
134
+ expect(subject.alive?).to be false
121
135
  end
122
136
  end
123
137
  end
@@ -129,7 +143,7 @@ module Adhearsion
129
143
  let(:event) { Punchblock::Event::Answered.new }
130
144
 
131
145
  it "should trigger any on_answer callbacks set" do
132
- response.should_receive(:call).once.with(event)
146
+ expect(response).to receive(:call).once.with(event)
133
147
  subject.on_answer { |event| response.call event }
134
148
  subject << event
135
149
  end
@@ -137,27 +151,27 @@ module Adhearsion
137
151
  it "should record the call start time" do
138
152
  originate_time = Time.local(2008, 9, 1, 12, 0, 0)
139
153
  Timecop.freeze originate_time
140
- subject.duration.should == 0.0
154
+ expect(subject.duration).to eq(0.0)
141
155
 
142
156
  mid_point_time = Time.local(2008, 9, 1, 12, 0, 20)
143
157
  Timecop.freeze mid_point_time
144
- subject.duration.should == 0.0
158
+ expect(subject.duration).to eq(0.0)
145
159
 
146
160
  answer_time = Time.local(2008, 9, 1, 12, 0, 40)
147
161
  Timecop.freeze answer_time
148
162
  subject << event
149
- subject.start_time.should == answer_time
163
+ expect(subject.start_time).to eq(answer_time)
150
164
 
151
165
  later_time = Time.local(2008, 9, 1, 12, 0, 50)
152
166
  Timecop.freeze later_time
153
- subject.duration.should == 10.0
167
+ expect(subject.duration).to eq(10.0)
154
168
  end
155
169
  end
156
170
  end
157
171
 
158
172
  describe "#dial" do
159
173
  def expect_message_waiting_for_response(message, uri = call_uri)
160
- subject.wrapped_object.should_receive(:write_and_await_response).once.with(message, 60, true).and_return do |real_message|
174
+ expect(subject.wrapped_object).to receive(:write_and_await_response).once.with(message, 60, true) do |real_message|
161
175
  real_message.request!
162
176
  real_message.response = Punchblock::Ref.new(uri: uri)
163
177
  real_message
@@ -168,29 +182,29 @@ module Adhearsion
168
182
 
169
183
  context "while waiting for a response" do
170
184
  before do
171
- mock_client.should_receive(:execute_command).once.with(expected_dial_command).and_return true
185
+ expect(mock_client).to receive(:execute_command).once.with(expected_dial_command).and_return true
172
186
  subject.async.dial to, from: from
173
187
  sleep 1
174
188
  end
175
189
 
176
190
  it "should set the dial command" do
177
- subject.dial_command.should be == expected_dial_command
191
+ expect(subject.dial_command).to eq(expected_dial_command)
178
192
  end
179
193
 
180
194
  it "should know its requested URI" do
181
- subject.uri.should be == call_uri
195
+ expect(subject.uri).to eq(call_uri)
182
196
  end
183
197
 
184
198
  it "should know its requested ID" do
185
- subject.id.should be == call_id
199
+ expect(subject.id).to eq(call_id)
186
200
  end
187
201
 
188
202
  it "should know its domain" do
189
- subject.domain.should be == domain
203
+ expect(subject.domain).to eq(domain)
190
204
  end
191
205
 
192
206
  it "should be entered in the active calls registry" do
193
- Adhearsion.active_calls[call_id].should be subject
207
+ expect(Adhearsion.active_calls[call_id]).to be subject
194
208
  end
195
209
  end
196
210
 
@@ -207,37 +221,37 @@ module Adhearsion
207
221
 
208
222
  it "should set the dial command" do
209
223
  subject.dial to, :from => from
210
- subject.dial_command.should be == Punchblock::Command::Dial.new(:to => to, :from => from, :uri => call_uri, target_call_id: call_id, domain: domain, transport: transport)
224
+ expect(subject.dial_command).to eq(Punchblock::Command::Dial.new(:to => to, :from => from, :uri => call_uri, target_call_id: call_id, domain: domain, transport: transport))
211
225
  end
212
226
 
213
227
  it "should set the URI from the reference" do
214
228
  subject.dial to, :from => from
215
- subject.uri.should be == call_uri
229
+ expect(subject.uri).to eq(call_uri)
216
230
  end
217
231
 
218
232
  it "should set the call ID from the reference" do
219
233
  subject.dial to, :from => from
220
- subject.id.should be == call_id
234
+ expect(subject.id).to eq(call_id)
221
235
  end
222
236
 
223
237
  it "should set the call domain from the reference" do
224
238
  subject.dial to, :from => from
225
- subject.domain.should be == domain
239
+ expect(subject.domain).to eq(domain)
226
240
  end
227
241
 
228
242
  it "should set the to from the dial command" do
229
243
  subject.dial to, :from => from
230
- subject.to.should be == to
244
+ expect(subject.to).to eq(to)
231
245
  end
232
246
 
233
247
  it "should set the 'from' from the dial command" do
234
248
  subject.dial to, :from => from
235
- subject.from.should be == from
249
+ expect(subject.from).to eq(from)
236
250
  end
237
251
 
238
252
  it "should add the call to the active calls registry" do
239
253
  subject.dial to, :from => from
240
- Adhearsion.active_calls[call_id].should be subject
254
+ expect(Adhearsion.active_calls[call_id]).to be subject
241
255
  end
242
256
 
243
257
  context "when a different ref is returned than the one expected" do
@@ -248,41 +262,41 @@ module Adhearsion
248
262
  end
249
263
 
250
264
  it "should set the URI from the reference" do
251
- subject.uri.should be == returned_uri
265
+ expect(subject.uri).to eq(returned_uri)
252
266
  end
253
267
 
254
268
  it "should set the call ID from the reference" do
255
- subject.id.should be == 'otherid'
269
+ expect(subject.id).to eq('otherid')
256
270
  end
257
271
 
258
272
  it "should set the call domain from the reference" do
259
- subject.domain.should be == 'wonderland.lit'
273
+ expect(subject.domain).to eq('wonderland.lit')
260
274
  end
261
275
 
262
276
  it "should make the call addressible in the active calls registry by the new ID" do
263
- Adhearsion.active_calls[call_id].should be_nil
264
- Adhearsion.active_calls['otherid'].should be subject
277
+ expect(Adhearsion.active_calls[call_id]).to be_nil
278
+ expect(Adhearsion.active_calls['otherid']).to be subject
265
279
  end
266
280
  end
267
281
 
268
282
  it "should immediately fire the :call_dialed event giving the call" do
269
- Adhearsion::Events.should_receive(:trigger_immediately).once.with(:call_dialed, subject)
283
+ expect(Adhearsion::Events).to receive(:trigger_immediately).once.with(:call_dialed, subject)
270
284
  subject.dial to, :from => from
271
285
  end
272
286
 
273
287
  it "should not modify the provided options" do
274
288
  options = {:from => from}
275
289
  original_options = Marshal.load(Marshal.dump(options))
276
- options.should be == original_options
290
+ expect(options).to eq(original_options)
277
291
  subject.dial to, options
278
- options.should be == original_options
292
+ expect(options).to eq(original_options)
279
293
  end
280
294
  end
281
295
 
282
296
  context "when the dial fails" do
283
297
  before do
284
- subject.wrapped_object.should_receive(:write_command)
285
- Punchblock::Command::Dial.any_instance.should_receive(:response).and_return StandardError.new("User not registered")
298
+ expect(subject.wrapped_object).to receive(:write_command)
299
+ expect_any_instance_of(Punchblock::Command::Dial).to receive(:response).and_return StandardError.new("User not registered")
286
300
  end
287
301
 
288
302
  after do
@@ -296,20 +310,20 @@ module Adhearsion
296
310
  it "should kill the actor" do
297
311
  expect { subject.dial to }.to raise_error("User not registered")
298
312
  sleep 0.1
299
- subject.should_not be_alive
313
+ expect(subject.alive?).to be false
300
314
  end
301
315
 
302
316
  it "should remove the call from the active calls hash" do
303
317
  expect { subject.dial to }.to raise_error("User not registered")
304
318
  sleep 0.1
305
- Adhearsion.active_calls[call_id].should be_nil
319
+ expect(Adhearsion.active_calls[call_id]).to be_nil
306
320
  end
307
321
  end
308
322
  end
309
323
 
310
324
  describe "basic control commands" do
311
325
  def expect_no_message_waiting_for_response
312
- subject.wrapped_object.should_receive(:write_and_await_response).never
326
+ expect(subject.wrapped_object).to receive(:write_and_await_response).never
313
327
  end
314
328
 
315
329
  describe '#accept' do
@@ -12,7 +12,7 @@ describe Adhearsion::Plugin do
12
12
  end
13
13
 
14
14
  before do
15
- Adhearsion::PunchblockPlugin::Initializer.stub :start => true
15
+ allow(Adhearsion::PunchblockPlugin::Initializer).to receive_messages :start => true
16
16
  end
17
17
 
18
18
  describe "inheritance" do
@@ -22,12 +22,12 @@ describe Adhearsion::Plugin do
22
22
 
23
23
  it "should provide the plugin name in a plugin class" do
24
24
  ::FooBar = Class.new Adhearsion::Plugin
25
- ::FooBar.plugin_name.should be == "foo_bar"
25
+ expect(::FooBar.plugin_name).to eq("foo_bar")
26
26
  end
27
27
 
28
28
  it "should provide the plugin name in a plugin instance" do
29
29
  ::FooBar = Class.new Adhearsion::Plugin
30
- ::FooBar.new.plugin_name.should be == "foo_bar"
30
+ expect(::FooBar.new.plugin_name).to eq("foo_bar")
31
31
  end
32
32
 
33
33
  it "should provide a setter for plugin name" do
@@ -35,7 +35,7 @@ describe Adhearsion::Plugin do
35
35
  self.plugin_name = "bar_foo"
36
36
  end
37
37
 
38
- ::FooBar.plugin_name.should be == "bar_foo"
38
+ expect(::FooBar.plugin_name).to eq("bar_foo")
39
39
  end
40
40
  end
41
41
 
@@ -54,28 +54,34 @@ describe Adhearsion::Plugin do
54
54
  end
55
55
  }
56
56
 
57
- its(:plugin_name) { should be == :bar_foo }
57
+ describe '#plugin_name' do
58
+ subject { super().plugin_name }
59
+ it { is_expected.to eq(:bar_foo) }
60
+ end
58
61
 
59
- its(:config) { should be_instance_of Loquacious::Configuration }
62
+ describe '#config' do
63
+ subject { super().config }
64
+ it { is_expected.to be_instance_of Loquacious::Configuration }
65
+ end
60
66
 
61
67
  it "should keep a default configuration and a description" do
62
68
  [:name, :password, :host].each do |value|
63
- subject.config.should respond_to value
69
+ expect(subject.config).to respond_to value
64
70
  end
65
71
 
66
- subject.config.name.should be == "user"
67
- subject.config.password.should be == "password"
68
- subject.config.host.should be == "localhost"
72
+ expect(subject.config.name).to eq("user")
73
+ expect(subject.config.password).to eq("password")
74
+ expect(subject.config.host).to eq("localhost")
69
75
  end
70
76
 
71
77
  it "should return a description of configuration options" do
72
- subject.show_description.should be_kind_of Loquacious::Configuration::Help
78
+ expect(subject.show_description).to be_kind_of Loquacious::Configuration::Help
73
79
  end
74
80
 
75
81
  describe "while updating config values" do
76
82
  it "should return the updated value" do
77
83
  subject.config.name = "usera"
78
- subject.config.name.should be == "usera"
84
+ expect(subject.config.name).to eq("usera")
79
85
  end
80
86
  end
81
87
 
@@ -87,15 +93,15 @@ describe Adhearsion::Plugin do
87
93
  it "should add plugins on the air" do
88
94
  Adhearsion::Plugin.delete_all
89
95
  Adhearsion::Plugin.add AhnPluginDemo
90
- Adhearsion::Plugin.count.should eql 1
96
+ expect(Adhearsion::Plugin.count).to eql 1
91
97
  end
92
98
 
93
99
  it "should delete plugins on the air" do
94
100
  Adhearsion::Plugin.delete_all
95
101
  Adhearsion::Plugin.add AhnPluginDemo
96
- Adhearsion::Plugin.count.should eql 1
102
+ expect(Adhearsion::Plugin.count).to eql 1
97
103
  Adhearsion::Plugin.delete AhnPluginDemo
98
- Adhearsion::Plugin.count.should eql 0
104
+ expect(Adhearsion::Plugin.count).to eql 0
99
105
  end
100
106
  end
101
107
 
@@ -107,7 +113,7 @@ describe Adhearsion::Plugin do
107
113
  it "should count the number of registered plugins" do
108
114
  number = Adhearsion::Plugin.count
109
115
  FooBar = Class.new Adhearsion::Plugin
110
- Adhearsion::Plugin.count.should eql(number + 1)
116
+ expect(Adhearsion::Plugin.count).to eql(number + 1)
111
117
  end
112
118
  end
113
119
 
@@ -142,7 +148,7 @@ describe Adhearsion::Plugin do
142
148
  FooBar = Class.new Adhearsion::Plugin
143
149
 
144
150
  # 1 => Punchblock. Must be empty once punchblock initializer is an external Plugin
145
- Adhearsion::Plugin.initializers.should have(1).initializers
151
+ expect(Adhearsion::Plugin.initializers.size).to eq(1)
146
152
  Adhearsion::Plugin.init_plugins
147
153
  end
148
154
 
@@ -155,8 +161,8 @@ describe Adhearsion::Plugin do
155
161
  end
156
162
  end
157
163
 
158
- FooBar.should_receive(:log).once
159
- Adhearsion::Plugin.initializers.length.should be 1
164
+ expect(FooBar).to receive(:log).once
165
+ expect(Adhearsion::Plugin.initializers.length).to be 1
160
166
  Adhearsion::Plugin.init_plugins
161
167
  end
162
168
 
@@ -181,7 +187,7 @@ describe Adhearsion::Plugin do
181
187
  end
182
188
  end
183
189
 
184
- FooBar.should_receive(:log).exactly(3).times
190
+ expect(FooBar).to receive(:log).exactly(3).times
185
191
  Adhearsion::Plugin.init_plugins
186
192
  end
187
193
 
@@ -201,8 +207,8 @@ describe Adhearsion::Plugin do
201
207
  end
202
208
  end
203
209
 
204
- Adhearsion::Plugin.initializers.tsort.first.name.should eql :foo_bar_baz
205
- Adhearsion::Plugin.initializers.tsort.last.name.should eql :foo_bar
210
+ expect(Adhearsion::Plugin.initializers.tsort.first.name).to eql :foo_bar_baz
211
+ expect(Adhearsion::Plugin.initializers.tsort.last.name).to eql :foo_bar
206
212
  end
207
213
 
208
214
  it "should allow to include an initializer after another one" do
@@ -227,9 +233,9 @@ describe Adhearsion::Plugin do
227
233
  end
228
234
  end
229
235
 
230
- Adhearsion::Plugin.initializers.length.should eql 3
231
- Adhearsion::Plugin.initializers.tsort.first.name.should eql :foo_bar
232
- Adhearsion::Plugin.initializers.tsort.last.name.should eql :foo_bar_baz
236
+ expect(Adhearsion::Plugin.initializers.length).to eql 3
237
+ expect(Adhearsion::Plugin.initializers.tsort.first.name).to eql :foo_bar
238
+ expect(Adhearsion::Plugin.initializers.tsort.last.name).to eql :foo_bar_baz
233
239
  end
234
240
  end
235
241
 
@@ -238,7 +244,7 @@ describe Adhearsion::Plugin do
238
244
  FooBar = Class.new Adhearsion::Plugin
239
245
 
240
246
  # May become 1 if Punchblock defines a runner.
241
- Adhearsion::Plugin.runners.should have(0).runners
247
+ expect(Adhearsion::Plugin.runners.size).to eq(0)
242
248
  Adhearsion::Plugin.run_plugins
243
249
  end
244
250
 
@@ -251,8 +257,8 @@ describe Adhearsion::Plugin do
251
257
  end
252
258
  end
253
259
 
254
- FooBar.should_receive(:log).once
255
- Adhearsion::Plugin.runners.length.should be 1
260
+ expect(FooBar).to receive(:log).once
261
+ expect(Adhearsion::Plugin.runners.length).to be 1
256
262
  Adhearsion::Plugin.run_plugins
257
263
  end
258
264
 
@@ -277,7 +283,7 @@ describe Adhearsion::Plugin do
277
283
  end
278
284
  end
279
285
 
280
- FooBar.should_receive(:log).exactly(3).times
286
+ expect(FooBar).to receive(:log).exactly(3).times
281
287
  Adhearsion::Plugin.run_plugins
282
288
  end
283
289
 
@@ -297,8 +303,8 @@ describe Adhearsion::Plugin do
297
303
  end
298
304
  end
299
305
 
300
- Adhearsion::Plugin.runners.tsort.first.name.should eql :foo_bar_baz
301
- Adhearsion::Plugin.runners.tsort.last.name.should eql :foo_bar
306
+ expect(Adhearsion::Plugin.runners.tsort.first.name).to eql :foo_bar_baz
307
+ expect(Adhearsion::Plugin.runners.tsort.last.name).to eql :foo_bar
302
308
  end
303
309
 
304
310
  it "should allow to include an runner after another one" do
@@ -323,9 +329,9 @@ describe Adhearsion::Plugin do
323
329
  end
324
330
  end
325
331
 
326
- Adhearsion::Plugin.runners.length.should eql 3
327
- Adhearsion::Plugin.runners.tsort.first.name.should eql :foo_bar
328
- Adhearsion::Plugin.runners.tsort.last.name.should eql :foo_bar_baz
332
+ expect(Adhearsion::Plugin.runners.length).to eql 3
333
+ expect(Adhearsion::Plugin.runners.tsort.first.name).to eql :foo_bar
334
+ expect(Adhearsion::Plugin.runners.tsort.last.name).to eql :foo_bar_baz
329
335
  end
330
336
  end
331
337
  end
@@ -340,32 +346,35 @@ describe Adhearsion::Plugin do
340
346
  subject { Adhearsion::Plugin.tasks }
341
347
 
342
348
  it "should return an Array" do
343
- subject.should be_instance_of Array
349
+ expect(subject).to be_instance_of Array
344
350
  end
345
351
 
346
- its(:length) { should be == 0 }
352
+ describe '#length' do
353
+ subject { super().length }
354
+ it { is_expected.to eq(0) }
355
+ end
347
356
 
348
357
  it "should not load a new task when there is no block in the method call" do
349
- subject.length.should be == 0
358
+ expect(subject.length).to eq(0)
350
359
  FooBar = Class.new Adhearsion::Plugin do
351
360
  tasks
352
361
  end
353
362
 
354
- subject.length.should be == 0
363
+ expect(subject.length).to eq(0)
355
364
  end
356
365
 
357
366
  it "should load a new task when there is a block in the method call" do
358
- subject.length.should be == 0
367
+ expect(subject.length).to eq(0)
359
368
  FooBar = Class.new Adhearsion::Plugin do
360
369
  tasks do
361
370
  puts "foo bar"
362
371
  end
363
372
  end
364
- Adhearsion::Plugin.tasks.length.should be == 1
373
+ expect(Adhearsion::Plugin.tasks.length).to eq(1)
365
374
  end
366
375
 
367
376
  it "should execute the tasks blocks while loading rake tasks" do
368
- subject.length.should be == 0
377
+ expect(subject.length).to eq(0)
369
378
  FooBar = Class.new Adhearsion::Plugin do
370
379
  tasks do
371
380
  FooBar.foo
@@ -373,7 +382,7 @@ describe Adhearsion::Plugin do
373
382
  def self.foo
374
383
  end
375
384
  end
376
- FooBar.should_receive(:foo).once
385
+ expect(FooBar).to receive(:foo).once
377
386
  Adhearsion::Plugin.load_tasks
378
387
  end
379
388
 
@@ -392,8 +401,8 @@ describe Adhearsion::Plugin do
392
401
  generators :gen1 => TestGenerator1, :gen2 => TestGenerator2
393
402
  end
394
403
 
395
- Adhearsion::Generators.mappings[:gen1].should be TestGenerator1
396
- Adhearsion::Generators.mappings[:gen2].should be TestGenerator2
404
+ expect(Adhearsion::Generators.mappings[:gen1]).to be TestGenerator1
405
+ expect(Adhearsion::Generators.mappings[:gen2]).to be TestGenerator2
397
406
  end
398
407
  end
399
408