agent 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,28 +7,28 @@ describe Agent::Notifier do
7
7
 
8
8
  it "should notify using a payload" do
9
9
  @notifier.notify(1)
10
- @notifier.payload.should == 1
10
+ expect(@notifier.payload).to eq(1)
11
11
  end
12
12
 
13
13
  it "should acknowledge notification" do
14
- @notifier.should_not be_notified
14
+ expect(@notifier).not_to be_notified
15
15
  @notifier.notify(1)
16
- @notifier.should be_notified
16
+ expect(@notifier).to be_notified
17
17
  end
18
18
 
19
19
  it "should only notify once" do
20
20
  @notifier.notify(1)
21
21
  @notifier.notify(2)
22
- @notifier.payload.should == 1
22
+ expect(@notifier.payload).to eq(1)
23
23
  end
24
24
 
25
25
  it "should return nil when notified for the first time" do
26
- @notifier.notify(1).should be_nil
26
+ expect(@notifier.notify(1)).to be_nil
27
27
  end
28
28
 
29
29
  it "should return an error when notified more than once" do
30
30
  @notifier.notify(1)
31
- @notifier.notify(2).should be_message("already notified")
31
+ expect(@notifier.notify(2)).to be_message("already notified")
32
32
  end
33
33
 
34
34
  it "should allow waiting on a notification and should signal when it is notified" do
@@ -37,6 +37,6 @@ describe Agent::Notifier do
37
37
  sleep 0.1 # make sure the notifier in the goroutine is waiting
38
38
  @notifier.notify(1)
39
39
  payload, _ = ack.receive
40
- payload.should == 1
40
+ expect(payload).to eq(1)
41
41
  end
42
42
  end
@@ -13,8 +13,8 @@ describe Agent::Once do
13
13
  r << 1
14
14
  end
15
15
 
16
- r.size.should == 1
17
- r.first.should == 1
16
+ expect(r.size).to eq(1)
17
+ expect(r.first).to eq(1)
18
18
  end
19
19
 
20
20
  it "should only execute the first block passed to it" do
@@ -28,8 +28,8 @@ describe Agent::Once do
28
28
  r << 2
29
29
  end
30
30
 
31
- r.size.should == 1
32
- r.first.should == 1
31
+ expect(r.size).to eq(1)
32
+ expect(r.first).to eq(1)
33
33
  end
34
34
 
35
35
  it "should return the value returned from the block" do
@@ -37,18 +37,18 @@ describe Agent::Once do
37
37
  1
38
38
  end
39
39
 
40
- value.should == 1
40
+ expect(value).to eq(1)
41
41
  end
42
42
 
43
43
  it "should return nil for value and an error if it has already been used" do
44
44
  value, error = @once.perform{ 1 }
45
- value.should == 1
46
- error.should be_nil
45
+ expect(value).to eq(1)
46
+ expect(error).to be_nil
47
47
 
48
48
  value, error = @once.perform{ 2 }
49
- value.should be_nil
50
- error.should_not be_nil
51
- error.should be_message("already performed")
49
+ expect(value).to be_nil
50
+ expect(error).not_to be_nil
51
+ expect(error).to be_message("already performed")
52
52
  end
53
53
 
54
54
  it "should have minimal contention between threads when they contend for position" do
@@ -81,9 +81,9 @@ describe Agent::Once do
81
81
  # wait for the finished channel to be completed
82
82
  2.times{ finished_channel.receive }
83
83
 
84
- r.size.should == 1
85
- # Onlt the first sleep should be performed, so things should quickly
86
- (Time.now.to_f - s).should be_within(0.05).of(0.15)
84
+ expect(r.size).to eq(1)
85
+ # Only the first sleep should be performed, so things should happen quickly
86
+ expect(Time.now.to_f - s).to be_within(0.05).of(0.15)
87
87
 
88
88
  waiting_channel.close
89
89
  finished_channel.close
@@ -9,16 +9,16 @@ describe Agent::Pop do
9
9
  end
10
10
 
11
11
  it "should close" do
12
- @pop.should_not be_closed
12
+ expect(@pop).not_to be_closed
13
13
  @pop.close
14
- @pop.should be_closed
14
+ expect(@pop).to be_closed
15
15
  end
16
16
 
17
17
  it "should run multiple times" do
18
18
  @pop.send{1}
19
- @pop.should be_received
19
+ expect(@pop).to be_received
20
20
  @pop.send{2}
21
- @pop.object.should == 2
21
+ expect(@pop.object).to eq(2)
22
22
  end
23
23
 
24
24
  it "should continue when received" do
@@ -28,7 +28,7 @@ describe Agent::Pop do
28
28
 
29
29
  s, _ = @ack.receive
30
30
 
31
- (Time.now - s).should be_within(0.01).of(0)
31
+ expect(Time.now - s).to be_within(0.01).of(0)
32
32
  end
33
33
 
34
34
  it "should continue when closed" do
@@ -38,13 +38,13 @@ describe Agent::Pop do
38
38
 
39
39
  s, _ = @ack.receive
40
40
 
41
- (Time.now - s).should be_within(0.01).of(0)
41
+ expect(Time.now - s).to be_within(0.01).of(0)
42
42
  end
43
43
 
44
44
  it "should be able to be gracefully rolled back" do
45
- @pop.should_not be_received
45
+ expect(@pop).not_to be_received
46
46
  @pop.send{ raise Agent::Errors::Rollback }
47
- @pop.should_not be_received
47
+ expect(@pop).not_to be_received
48
48
  end
49
49
 
50
50
  it "should continue when it was already closed" do
@@ -56,7 +56,7 @@ describe Agent::Pop do
56
56
 
57
57
  s, _ = @ack.receive
58
58
 
59
- (Time.now - s).should be_within(0.01).of(0.2)
59
+ expect(Time.now - s).to be_within(0.01).of(0.2)
60
60
  end
61
61
  end
62
62
 
@@ -67,38 +67,38 @@ describe Agent::Pop do
67
67
  end
68
68
 
69
69
  it "should only send only once" do
70
- @blocking_once.should_not be_performed
70
+ expect(@blocking_once).not_to be_performed
71
71
  @pop.send{1}
72
- @pop.should be_received
73
- @blocking_once.should be_performed
74
- @pop.object.should == 1
72
+ expect(@pop).to be_received
73
+ expect(@blocking_once).to be_performed
74
+ expect(@pop.object).to eq(1)
75
75
 
76
76
  @pop.send{2}
77
- @pop.object.should == 1
77
+ expect(@pop.object).to eq(1)
78
78
 
79
- lambda{@pop.send{raise "an error"} }.should_not raise_error
79
+ expect{@pop.send{raise "an error"} }.not_to raise_error
80
80
  end
81
81
 
82
82
  it "be able to be gracefully rolled back" do
83
- @blocking_once.should_not be_performed
84
- @pop.should_not be_received
83
+ expect(@blocking_once).not_to be_performed
84
+ expect(@pop).not_to be_received
85
85
  @pop.send{ raise Agent::Errors::Rollback }
86
- @blocking_once.should_not be_performed
87
- @pop.should_not be_received
86
+ expect(@blocking_once).not_to be_performed
87
+ expect(@pop).not_to be_received
88
88
  end
89
89
 
90
90
  it "should send only once even when it is closed" do
91
91
  @pop.close
92
- @blocking_once.should_not be_performed
92
+ expect(@blocking_once).not_to be_performed
93
93
  @pop.send{1}
94
- @pop.should be_received
95
- @blocking_once.should be_performed
96
- @pop.object.should == nil
94
+ expect(@pop).to be_received
95
+ expect(@blocking_once).to be_performed
96
+ expect(@pop.object).to be_nil
97
97
 
98
98
  @pop.send{2}
99
- @pop.object.should == nil
99
+ expect(@pop.object).to be_nil
100
100
 
101
- lambda{@pop.send{raise "an error"} }.should_not raise_error
101
+ expect{@pop.send{raise "an error"} }.not_to raise_error
102
102
  end
103
103
  end
104
104
 
@@ -109,15 +109,15 @@ describe Agent::Pop do
109
109
  end
110
110
 
111
111
  it "should notify when being sent" do
112
- @notifier.should_not be_notified
112
+ expect(@notifier).not_to be_notified
113
113
  @pop.send{1}
114
- @notifier.should be_notified
114
+ expect(@notifier).to be_notified
115
115
  end
116
116
 
117
117
  it "should notify when being closed" do
118
- @notifier.should_not be_notified
118
+ expect(@notifier).not_to be_notified
119
119
  @pop.close
120
- @notifier.should be_notified
120
+ expect(@notifier).to be_notified
121
121
  end
122
122
  end
123
123
 
@@ -9,17 +9,17 @@ describe Agent::Push do
9
9
  end
10
10
 
11
11
  it "should close" do
12
- @push.should_not be_closed
12
+ expect(@push).not_to be_closed
13
13
  @push.close
14
- @push.should be_closed
14
+ expect(@push).to be_closed
15
15
  end
16
16
 
17
17
  it "should run multiple times" do
18
18
  i = 0
19
19
  @push.receive{|v| i += 1 }
20
- @push.should be_sent
20
+ expect(@push).to be_sent
21
21
  @push.receive{|v| i += 1 }
22
- i.should == 2
22
+ expect(i).to eq(2)
23
23
  end
24
24
 
25
25
  it "should continue when sent" do
@@ -29,18 +29,18 @@ describe Agent::Push do
29
29
 
30
30
  s, _ = @ack.receive
31
31
 
32
- (Time.now - s).should be_within(0.02).of(0)
32
+ expect(Time.now - s).to be_within(0.02).of(0)
33
33
  end
34
34
 
35
35
  it "should raise an error on the waiter when closed" do
36
36
  go!{ sleep 0.1; @push.close }
37
- lambda{ @push.wait }.should raise_error(Agent::Errors::ChannelClosed)
37
+ expect{ @push.wait }.to raise_error(Agent::Errors::ChannelClosed)
38
38
  end
39
39
 
40
40
  it "be able to be gracefully rolled back" do
41
- @push.should_not be_sent
41
+ expect(@push).not_to be_sent
42
42
  @push.receive{|v| raise Agent::Errors::Rollback }
43
- @push.should_not be_sent
43
+ expect(@push).not_to be_sent
44
44
  end
45
45
  end
46
46
 
@@ -50,16 +50,16 @@ describe Agent::Push do
50
50
  let(:push){ Agent::Push.new(object, :skip_marshal => skip_marshal) }
51
51
 
52
52
  it "makes a copy of the object" do
53
- push.object.should == object
54
- push.object.object_id.should_not == object.object_id
53
+ expect(push.object).to eq(object)
54
+ expect(push.object.object_id).not_to eq(object.object_id)
55
55
  end
56
56
 
57
57
  context "with an object type that skips marshaling" do
58
58
  let(:object){ ::Queue.new }
59
59
 
60
60
  it "does not make a copy of the object" do
61
- push.object.should == object
62
- push.object.object_id.should == object.object_id
61
+ expect(push.object).to eq(object)
62
+ expect(push.object.object_id).to eq(object.object_id)
63
63
  end
64
64
  end
65
65
 
@@ -67,8 +67,8 @@ describe Agent::Push do
67
67
  let(:skip_marshal){ true }
68
68
 
69
69
  it "does not make a copy of the object" do
70
- push.object.should == object
71
- push.object.object_id.should == object.object_id
70
+ expect(push.object).to eq(object)
71
+ expect(push.object.object_id).to eq(object.object_id)
72
72
  end
73
73
  end
74
74
  end
@@ -82,23 +82,23 @@ describe Agent::Push do
82
82
  it "should only send only once" do
83
83
  i = 0
84
84
 
85
- @blocking_once.should_not be_performed
85
+ expect(@blocking_once).not_to be_performed
86
86
  @push.receive{|v| i += 1 }
87
- @push.should be_sent
88
- @blocking_once.should be_performed
87
+ expect(@push).to be_sent
88
+ expect(@blocking_once).to be_performed
89
89
 
90
90
  @push.receive{|v| i += 1 }
91
- i.should == 1
91
+ expect(i).to eq(1)
92
92
 
93
- lambda{@push.receive{raise "an error"} }.should_not raise_error
93
+ expect{@push.receive{raise "an error"} }.not_to raise_error
94
94
  end
95
95
 
96
96
  it "be able to be gracefully rolled back" do
97
- @blocking_once.should_not be_performed
98
- @push.should_not be_sent
97
+ expect(@blocking_once).not_to be_performed
98
+ expect(@push).not_to be_sent
99
99
  @push.receive{|v| raise Agent::Errors::Rollback }
100
- @blocking_once.should_not be_performed
101
- @push.should_not be_sent
100
+ expect(@blocking_once).not_to be_performed
101
+ expect(@push).not_to be_sent
102
102
  end
103
103
  end
104
104
 
@@ -109,15 +109,15 @@ describe Agent::Push do
109
109
  end
110
110
 
111
111
  it "should notify when being sent" do
112
- @notifier.should_not be_notified
112
+ expect(@notifier).not_to be_notified
113
113
  @push.receive{|v|}
114
- @notifier.should be_notified
114
+ expect(@notifier).to be_notified
115
115
  end
116
116
 
117
117
  it "should notify when being closed" do
118
- @notifier.should_not be_notified
118
+ expect(@notifier).not_to be_notified
119
119
  @push.close
120
- @notifier.should be_notified
120
+ expect(@notifier).to be_notified
121
121
  end
122
122
  end
123
123
 
@@ -8,20 +8,20 @@ describe Agent::Queue do
8
8
  end
9
9
 
10
10
  it "should be buffered" do
11
- @queue.should be_buffered
11
+ expect(@queue).to be_buffered
12
12
  end
13
13
 
14
14
  it "should not be unbuffered" do
15
- @queue.should_not be_unbuffered
15
+ expect(@queue).not_to be_unbuffered
16
16
  end
17
17
 
18
18
  it "should raise an error if the queue size is <= 0" do
19
- lambda{ Agent::Queue::Buffered.new(String, 0) }.should raise_error(Agent::Errors::InvalidQueueSize)
20
- lambda{ Agent::Queue::Buffered.new(String, -1) }.should raise_error(Agent::Errors::InvalidQueueSize)
19
+ expect{ Agent::Queue::Buffered.new(String, 0) }.to raise_error(Agent::Errors::InvalidQueueSize)
20
+ expect{ Agent::Queue::Buffered.new(String, -1) }.to raise_error(Agent::Errors::InvalidQueueSize)
21
21
  end
22
22
 
23
23
  it "should raise an erro when an object of an invalid type is pushed" do
24
- lambda { @queue.push(1) }.should raise_error(Agent::Errors::InvalidType)
24
+ expect { @queue.push(1) }.to raise_error(Agent::Errors::InvalidType)
25
25
  end
26
26
 
27
27
  it "should enqueue and dequeue in order" do
@@ -31,16 +31,16 @@ describe Agent::Queue do
31
31
 
32
32
  20.times do |i|
33
33
  o = @queue.pop[0].to_i
34
- o.should > previous
34
+ expect(o).to be > previous
35
35
  previous = o
36
36
  end
37
37
  end
38
38
 
39
39
  context "when the queue is empty" do
40
40
  it "should hold any attempts to pop from it" do
41
- @queue.operations.should be_empty
41
+ expect(@queue.operations).to be_empty
42
42
  @queue.pop(:deferred => true)
43
- @queue.operations.should_not be_empty
43
+ expect(@queue.operations).not_to be_empty
44
44
  end
45
45
 
46
46
  it "should be able to be pushed to" do
@@ -48,17 +48,17 @@ describe Agent::Queue do
48
48
  end
49
49
 
50
50
  it "should increase in size when pushed to" do
51
- @queue.size.should == 0
51
+ expect(@queue.size).to eq(0)
52
52
  @queue.push("1")
53
- @queue.size.should == 1
53
+ expect(@queue.size).to eq(1)
54
54
  end
55
55
 
56
56
  it "should be pushable" do
57
- @queue.push?.should == true
57
+ expect(@queue.push?).to eq(true)
58
58
  end
59
59
 
60
60
  it "should not be poppable" do
61
- @queue.pop?.should == false
61
+ expect(@queue.pop?).to eq(false)
62
62
  end
63
63
  end
64
64
 
@@ -72,27 +72,27 @@ describe Agent::Queue do
72
72
  end
73
73
 
74
74
  it "should increase in size when pushed to" do
75
- @queue.size.should == 1
75
+ expect(@queue.size).to eq(1)
76
76
  @queue.push("1")
77
- @queue.size.should == 2
77
+ expect(@queue.size).to eq(2)
78
78
  end
79
79
 
80
80
  it "should be able to be popped from" do
81
- @queue.pop[0].should == "1"
81
+ expect(@queue.pop[0]).to eq("1")
82
82
  end
83
83
 
84
84
  it "should decrease in size when popped from" do
85
- @queue.size.should == 1
85
+ expect(@queue.size).to eq(1)
86
86
  @queue.pop
87
- @queue.size.should == 0
87
+ expect(@queue.size).to eq(0)
88
88
  end
89
89
 
90
90
  it "should be pushable" do
91
- @queue.push?.should == true
91
+ expect(@queue.push?).to eq(true)
92
92
  end
93
93
 
94
94
  it "should be poppable" do
95
- @queue.pop?.should == true
95
+ expect(@queue.pop?).to eq(true)
96
96
  end
97
97
  end
98
98
 
@@ -102,21 +102,21 @@ describe Agent::Queue do
102
102
  end
103
103
 
104
104
  it "should hold any attempts to push to it" do
105
- @queue.operations.should be_empty
105
+ expect(@queue.operations).to be_empty
106
106
  @queue.push("1", :deferred => true)
107
- @queue.operations.should_not be_empty
107
+ expect(@queue.operations).not_to be_empty
108
108
  end
109
109
 
110
110
  it "should be able to be popped from" do
111
- @queue.pop[0].should == "1"
111
+ expect(@queue.pop[0]).to eq("1")
112
112
  end
113
113
 
114
114
  it "should not be pushable" do
115
- @queue.push?.should == false
115
+ expect(@queue.push?).to eq(false)
116
116
  end
117
117
 
118
118
  it "should be poppable" do
119
- @queue.pop?.should == true
119
+ expect(@queue.pop?).to eq(true)
120
120
  end
121
121
  end
122
122
 
@@ -126,51 +126,51 @@ describe Agent::Queue do
126
126
  end
127
127
 
128
128
  it "should go from open to closed" do
129
- @queue.should_not be_closed
130
- @queue.should be_open
129
+ expect(@queue).not_to be_closed
130
+ expect(@queue).to be_open
131
131
  @queue.close
132
- @queue.should be_closed
133
- @queue.should_not be_open
132
+ expect(@queue).to be_closed
133
+ expect(@queue).not_to be_open
134
134
  end
135
135
 
136
136
  it "should close all the waiting operations" do
137
- @push1.should be_sent
138
- @push2.should be_sent
139
- @push3.should_not be_sent
140
- @push3.should_not be_closed
137
+ expect(@push1).to be_sent
138
+ expect(@push2).to be_sent
139
+ expect(@push3).not_to be_sent
140
+ expect(@push3).not_to be_closed
141
141
 
142
142
  @queue.close
143
143
 
144
- @push3.should be_closed
144
+ expect(@push3).to be_closed
145
145
  end
146
146
 
147
147
  it "should clear all waiting operations" do
148
- @queue.operations.size.should == 1
149
- @queue.pushes.size.should == 1
148
+ expect(@queue.operations.size).to eq(1)
149
+ expect(@queue.pushes.size).to eq(1)
150
150
  @queue.close
151
- @queue.operations.size.should == 0
152
- @queue.pushes.size.should == 0
151
+ expect(@queue.operations.size).to eq(0)
152
+ expect(@queue.pushes.size).to eq(0)
153
153
  end
154
154
 
155
155
  it "should clear all elements at rest" do
156
- @queue.queue.size.should == 2
156
+ expect(@queue.queue.size).to eq(2)
157
157
  @queue.close
158
- @queue.queue.size.should == 0
158
+ expect(@queue.queue.size).to eq(0)
159
159
  end
160
160
 
161
161
  context "after it is closed" do
162
162
  before{ @queue.close }
163
163
 
164
164
  it "should raise an error when #close is called again" do
165
- lambda{ @queue.close }.should raise_error(Agent::Errors::ChannelClosed)
165
+ expect{ @queue.close }.to raise_error(Agent::Errors::ChannelClosed)
166
166
  end
167
167
 
168
168
  it "should raise an error when a value is pushed onto the queue" do
169
- lambda{ @queue.push("1") }.should raise_error(Agent::Errors::ChannelClosed)
169
+ expect{ @queue.push("1") }.to raise_error(Agent::Errors::ChannelClosed)
170
170
  end
171
171
 
172
172
  it "should return [nil, false] when popping from the queue" do
173
- @queue.pop.should == [nil, false]
173
+ expect(@queue.pop).to eq([nil, false])
174
174
  end
175
175
  end
176
176
  end
@@ -185,9 +185,9 @@ describe Agent::Queue do
185
185
  @queue.remove_operations(removable_pushes)
186
186
  while @queue.pop?
187
187
  i = @queue.pop[0]
188
- i.should_not be_nil
189
- i.should_not == "6"
190
- i.should_not == "7"
188
+ expect(i).not_to be_nil
189
+ expect(i).not_to eq("6")
190
+ expect(i).not_to eq("7")
191
191
  end
192
192
  end
193
193
  end
@@ -199,11 +199,11 @@ describe Agent::Queue do
199
199
  end
200
200
 
201
201
  it "should not be buffered" do
202
- @queue.should_not be_buffered
202
+ expect(@queue).not_to be_buffered
203
203
  end
204
204
 
205
205
  it "should be unbuffered" do
206
- @queue.should be_unbuffered
206
+ expect(@queue).to be_unbuffered
207
207
  end
208
208
 
209
209
  it "should enqueue and dequeue in order" do
@@ -213,32 +213,32 @@ describe Agent::Queue do
213
213
 
214
214
  20.times do |i|
215
215
  o = @queue.pop[0].to_i
216
- o.should > previous
216
+ expect(o).to be > previous
217
217
  previous = o
218
218
  end
219
219
  end
220
220
 
221
221
  context "when there are no operations waiting" do
222
222
  it "should not be poppable" do
223
- @queue.pop?.should == false
223
+ expect(@queue.pop?).to eq(false)
224
224
  end
225
225
 
226
226
  it "should not be pushable" do
227
- @queue.push?.should == false
227
+ expect(@queue.push?).to eq(false)
228
228
  end
229
229
 
230
230
  it "should queue pushes" do
231
- @queue.operations.size.should == 0
231
+ expect(@queue.operations.size).to eq(0)
232
232
  push = @queue.push("1", :deferred => true)
233
- push.should_not be_sent
234
- @queue.operations.size.should == 1
233
+ expect(push).not_to be_sent
234
+ expect(@queue.operations.size).to eq(1)
235
235
  end
236
236
 
237
237
  it "should queue pops" do
238
- @queue.operations.size.should == 0
238
+ expect(@queue.operations.size).to eq(0)
239
239
  pop = @queue.pop(:deferred => true)
240
- pop.should_not be_received
241
- @queue.operations.size.should == 1
240
+ expect(pop).not_to be_received
241
+ expect(@queue.operations.size).to eq(1)
242
242
  end
243
243
  end
244
244
 
@@ -248,25 +248,25 @@ describe Agent::Queue do
248
248
  end
249
249
 
250
250
  it "should not be poppable" do
251
- @queue.pop?.should == false
251
+ expect(@queue.pop?).to eq(false)
252
252
  end
253
253
 
254
254
  it "should be pushable" do
255
- @queue.push?.should == true
255
+ expect(@queue.push?).to eq(true)
256
256
  end
257
257
 
258
258
  it "should execute a push and the waiting pop immediately" do
259
259
  push = @queue.push("1", :deferred => true)
260
- @pop.should be_received
261
- push.should be_sent
262
- @pop.object.should == "1"
260
+ expect(@pop).to be_received
261
+ expect(push).to be_sent
262
+ expect(@pop.object).to eq("1")
263
263
  end
264
264
 
265
265
  it "should queue pops" do
266
- @queue.operations.size.should == 1
266
+ expect(@queue.operations.size).to eq(1)
267
267
  pop = @queue.pop(:deferred => true)
268
- pop.should_not be_received
269
- @queue.operations.size.should == 2
268
+ expect(pop).not_to be_received
269
+ expect(@queue.operations.size).to eq(2)
270
270
  end
271
271
  end
272
272
 
@@ -276,25 +276,25 @@ describe Agent::Queue do
276
276
  end
277
277
 
278
278
  it "should be poppable" do
279
- @queue.pop?.should == true
279
+ expect(@queue.pop?).to eq(true)
280
280
  end
281
281
 
282
282
  it "should not be pushable" do
283
- @queue.push?.should == false
283
+ expect(@queue.push?).to eq(false)
284
284
  end
285
285
 
286
286
  it "should queue pushes" do
287
- @queue.operations.size.should == 1
287
+ expect(@queue.operations.size).to eq(1)
288
288
  push = @queue.push("1", :deferred => true)
289
- push.should_not be_sent
290
- @queue.operations.size.should == 2
289
+ expect(push).not_to be_sent
290
+ expect(@queue.operations.size).to eq(2)
291
291
  end
292
292
 
293
293
  it "should execute a pop and the waiting push immediately" do
294
294
  pop = @queue.pop(:deferred => true)
295
- @push.should be_sent
296
- pop.should be_received
297
- pop.object.should == "1"
295
+ expect(@push).to be_sent
296
+ expect(pop).to be_received
297
+ expect(pop.object).to eq("1")
298
298
  end
299
299
  end
300
300
 
@@ -304,46 +304,46 @@ describe Agent::Queue do
304
304
  end
305
305
 
306
306
  it "should go from open to closed" do
307
- @queue.should_not be_closed
308
- @queue.should be_open
307
+ expect(@queue).not_to be_closed
308
+ expect(@queue).to be_open
309
309
  @queue.close
310
- @queue.should be_closed
311
- @queue.should_not be_open
310
+ expect(@queue).to be_closed
311
+ expect(@queue).not_to be_open
312
312
  end
313
313
 
314
314
  it "should close all the waiting operations" do
315
- @push1.should_not be_sent
316
- @push1.should_not be_closed
317
- @push2.should_not be_sent
318
- @push2.should_not be_closed
315
+ expect(@push1).not_to be_sent
316
+ expect(@push1).not_to be_closed
317
+ expect(@push2).not_to be_sent
318
+ expect(@push2).not_to be_closed
319
319
 
320
320
  @queue.close
321
321
 
322
- @push1.should be_closed
323
- @push2.should be_closed
322
+ expect(@push1).to be_closed
323
+ expect(@push2).to be_closed
324
324
  end
325
325
 
326
326
  it "should clear all waiting operations" do
327
- @queue.operations.size.should == 2
328
- @queue.pushes.size.should == 2
327
+ expect(@queue.operations.size).to eq(2)
328
+ expect(@queue.pushes.size).to eq(2)
329
329
  @queue.close
330
- @queue.operations.size.should == 0
331
- @queue.pushes.size.should == 0
330
+ expect(@queue.operations.size).to eq(0)
331
+ expect(@queue.pushes.size).to eq(0)
332
332
  end
333
333
 
334
334
  context "after it is closed" do
335
335
  before{ @queue.close }
336
336
 
337
337
  it "should raise an error when #close is called again" do
338
- lambda{ @queue.close }.should raise_error(Agent::Errors::ChannelClosed)
338
+ expect{ @queue.close }.to raise_error(Agent::Errors::ChannelClosed)
339
339
  end
340
340
 
341
341
  it "should raise an error when a value is pushed onto the queue" do
342
- lambda{ @queue.push("1") }.should raise_error(Agent::Errors::ChannelClosed)
342
+ expect{ @queue.push("1") }.to raise_error(Agent::Errors::ChannelClosed)
343
343
  end
344
344
 
345
345
  it "should return [nil, false] when popping from the queue" do
346
- @queue.pop.should == [nil, false]
346
+ expect(@queue.pop).to eq([nil, false])
347
347
  end
348
348
  end
349
349
  end
@@ -358,9 +358,9 @@ describe Agent::Queue do
358
358
  @queue.remove_operations(removable_pushes)
359
359
  while @queue.pop?
360
360
  i = @queue.pop[0]
361
- i.should_not be_nil
362
- i.should_not == "6"
363
- i.should_not == "7"
361
+ expect(i).not_to be_nil
362
+ expect(i).not_to eq("6")
363
+ expect(i).not_to eq("7")
364
364
  end
365
365
  end
366
366
  end