zk 1.9.6 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +5 -13
  2. data/.github/workflows/build.yml +55 -0
  3. data/Gemfile +15 -6
  4. data/README.markdown +9 -9
  5. data/RELEASES.markdown +10 -1
  6. data/lib/zk/client.rb +1 -1
  7. data/lib/zk/event_handler.rb +15 -7
  8. data/lib/zk/fork_hook.rb +2 -2
  9. data/lib/zk/locker/locker_base.rb +13 -0
  10. data/lib/zk/locker/semaphore.rb +1 -3
  11. data/lib/zk/node_deletion_watcher.rb +3 -4
  12. data/lib/zk/pool.rb +11 -11
  13. data/lib/zk/version.rb +1 -1
  14. data/spec/event_catcher_spec.rb +1 -1
  15. data/spec/message_queue_spec.rb +6 -6
  16. data/spec/shared/client_examples.rb +81 -81
  17. data/spec/shared/locker_examples.rb +13 -13
  18. data/spec/spec_helper.rb +10 -11
  19. data/spec/zk/00_forked_client_integration_spec.rb +3 -3
  20. data/spec/zk/client/locking_and_session_death_spec.rb +2 -2
  21. data/spec/zk/client_spec.rb +19 -19
  22. data/spec/zk/election_spec.rb +44 -44
  23. data/spec/zk/extensions_spec.rb +2 -2
  24. data/spec/zk/locker/exclusive_locker_spec.rb +41 -41
  25. data/spec/zk/locker/locker_basic_spec.rb +55 -33
  26. data/spec/zk/locker/semaphore_spec.rb +39 -32
  27. data/spec/zk/locker/shared_exclusive_integration_spec.rb +37 -37
  28. data/spec/zk/locker/shared_locker_spec.rb +43 -43
  29. data/spec/zk/locker_spec.rb +2 -2
  30. data/spec/zk/module_spec.rb +25 -25
  31. data/spec/zk/mongoid_spec.rb +47 -47
  32. data/spec/zk/node_deletion_watcher_spec.rb +39 -31
  33. data/spec/zk/pool_spec.rb +56 -65
  34. data/spec/zk/threaded_callback_spec.rb +10 -10
  35. data/spec/zk/threadpool_spec.rb +25 -25
  36. data/spec/zk/watch_spec.rb +67 -79
  37. data/spec/zk/zookeeper_spec.rb +31 -31
  38. data/zk.gemspec +1 -1
  39. metadata +23 -24
  40. data/.travis.yml +0 -30
@@ -9,17 +9,17 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
9
9
 
10
10
  it %[should raise LockAssertionFailedError if there is an exclusive lock with a number lower than ours] do
11
11
  # this should *really* never happen
12
- locker.lock.should be_true
12
+ expect(locker.lock).to be(true)
13
13
  shl_path = locker.lock_path
14
14
 
15
- locker2.lock.should be_true
15
+ expect(locker2.lock).to be(true)
16
16
 
17
- locker.unlock.should be_true
18
- locker.should_not be_locked
17
+ expect(locker.unlock).to be(true)
18
+ expect(locker).not_to be_locked
19
19
 
20
- zk.exists?(shl_path).should be_false
20
+ expect(zk.exists?(shl_path)).to be(false)
21
21
 
22
- locker2.lock_path.should_not == shl_path
22
+ expect(locker2.lock_path).not_to eq(shl_path)
23
23
 
24
24
  # convert the first shared lock path into a exclusive one
25
25
 
@@ -27,7 +27,7 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
27
27
 
28
28
  zk.create(exl_path, :ephemeral => true)
29
29
 
30
- lambda { locker2.assert! }.should raise_error(ZK::Exceptions::LockAssertionFailedError)
30
+ expect { locker2.assert! }.to raise_error(ZK::Exceptions::LockAssertionFailedError)
31
31
  end
32
32
  end
33
33
 
@@ -35,18 +35,18 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
35
35
  describe %[with default options] do
36
36
  it %[should work if the lock root doesn't exist] do
37
37
  zk.rm_rf(ZK::Locker.default_root_lock_node)
38
- locker.should be_acquirable
38
+ expect(locker).to be_acquirable
39
39
  end
40
40
 
41
41
  it %[should check local state of lockedness] do
42
- locker.lock.should be_true
43
- locker.should be_acquirable
42
+ expect(locker.lock).to be(true)
43
+ expect(locker).to be_acquirable
44
44
  end
45
45
 
46
46
  it %[should check if any participants would prevent us from acquiring the lock] do
47
47
  ex_lock = ZK::Locker.exclusive_locker(zk, path)
48
- ex_lock.lock.should be_true
49
- locker.should_not be_acquirable
48
+ expect(ex_lock.lock).to be(true)
49
+ expect(locker).not_to be_acquirable
50
50
  end
51
51
  end
52
52
  end
@@ -59,13 +59,13 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
59
59
  end
60
60
 
61
61
  it %[should acquire the first lock] do
62
- @rval.should be_true
63
- locker.should be_locked
62
+ expect(@rval).to be(true)
63
+ expect(locker).to be_locked
64
64
  end
65
65
 
66
66
  it %[should acquire the second lock] do
67
- @rval2.should be_true
68
- locker2.should be_locked
67
+ expect(@rval2).to be(true)
68
+ expect(locker2).to be_locked
69
69
  end
70
70
  end
71
71
 
@@ -77,11 +77,11 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
77
77
  end
78
78
 
79
79
  it %[should return false] do
80
- @rval.should be_false
80
+ expect(@rval).to be(false)
81
81
  end
82
82
 
83
83
  it %[should not be locked] do
84
- locker.should_not be_locked
84
+ expect(locker).not_to be_locked
85
85
  end
86
86
  end
87
87
 
@@ -96,7 +96,7 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
96
96
  it %[should acquire the lock after the write lock is released old-style] do
97
97
  ary = []
98
98
 
99
- locker.lock.should be_false
99
+ expect(locker.lock).to be(false)
100
100
 
101
101
  th = Thread.new do
102
102
  locker.lock(true)
@@ -104,24 +104,24 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
104
104
  end
105
105
 
106
106
  locker.wait_until_blocked(5)
107
- locker.should be_waiting
108
- locker.should_not be_locked
109
- ary.should be_empty
107
+ expect(locker).to be_waiting
108
+ expect(locker).not_to be_locked
109
+ expect(ary).to be_empty
110
110
 
111
111
  zk.delete(@write_lock_path)
112
112
 
113
- th.join(2).should == th
113
+ expect(th.join(2)).to eq(th)
114
114
 
115
- ary.should_not be_empty
116
- ary.length.should == 1
115
+ expect(ary).not_to be_empty
116
+ expect(ary.length).to eq(1)
117
117
 
118
- locker.should be_locked
118
+ expect(locker).to be_locked
119
119
  end
120
120
 
121
121
  it %[should acquire the lock after the write lock is released new-style] do
122
122
  ary = []
123
123
 
124
- locker.lock.should be_false
124
+ expect(locker.lock).to be(false)
125
125
 
126
126
  th = Thread.new do
127
127
  locker.lock(:wait => true)
@@ -129,18 +129,18 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
129
129
  end
130
130
 
131
131
  locker.wait_until_blocked(5)
132
- locker.should be_waiting
133
- locker.should_not be_locked
134
- ary.should be_empty
132
+ expect(locker).to be_waiting
133
+ expect(locker).not_to be_locked
134
+ expect(ary).to be_empty
135
135
 
136
136
  zk.delete(@write_lock_path)
137
137
 
138
- th.join(2).should == th
138
+ expect(th.join(2)).to eq(th)
139
139
 
140
- ary.should_not be_empty
141
- ary.length.should == 1
140
+ expect(ary).not_to be_empty
141
+ expect(ary.length).to eq(1)
142
142
 
143
- locker.should be_locked
143
+ expect(locker).to be_locked
144
144
  end
145
145
  end
146
146
 
@@ -150,9 +150,9 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
150
150
 
151
151
  write_lock_dir = File.dirname(@write_lock_path)
152
152
 
153
- zk.children(write_lock_dir).length.should == 1
153
+ expect(zk.children(write_lock_dir).length).to eq(1)
154
154
 
155
- locker.lock.should be_false
155
+ expect(locker.lock).to be(false)
156
156
 
157
157
  th = Thread.new do
158
158
  begin
@@ -164,16 +164,16 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
164
164
  end
165
165
 
166
166
  locker.wait_until_blocked(5)
167
- locker.should be_waiting
168
- locker.should_not be_locked
169
- ary.should be_empty
167
+ expect(locker).to be_waiting
168
+ expect(locker).not_to be_locked
169
+ expect(ary).to be_empty
170
170
 
171
- th.join(2).should == th
171
+ expect(th.join(2)).to eq(th)
172
172
 
173
- zk.children(write_lock_dir).length.should == 1
173
+ expect(zk.children(write_lock_dir).length).to eq(1)
174
174
 
175
- ary.should be_empty
176
- @exc.should be_kind_of(ZK::Exceptions::LockWaitTimeoutError)
175
+ expect(ary).to be_empty
176
+ expect(@exc).to be_kind_of(ZK::Exceptions::LockWaitTimeoutError)
177
177
  end
178
178
 
179
179
  end
@@ -14,9 +14,9 @@ describe ZK::Locker do
14
14
 
15
15
  ZK::Locker.cleanup(@zk)
16
16
 
17
- lambda { locker.assert! }.should_not raise_error
17
+ expect { locker.assert! }.not_to raise_error
18
18
 
19
- bogus_lock_dir_names.each { |n| @zk.stat("#{ZK::Locker.default_root_lock_node}/#{n}").should_not exist }
19
+ bogus_lock_dir_names.each { |n| expect(@zk.stat("#{ZK::Locker.default_root_lock_node}/#{n}")).not_to exist }
20
20
 
21
21
  end
22
22
  end
@@ -21,7 +21,7 @@ describe ZK do
21
21
 
22
22
  describe %[with a chrooted connection string and a :chroot => '/path'] do
23
23
  it %[should raise an ArgumentError] do
24
- lambda { @zk = ZK.new("#{connection_host}/zktest", :chroot => '/zktest') }.should raise_error(ArgumentError)
24
+ expect { @zk = ZK.new("#{connection_host}/zktest", :chroot => '/zktest') }.to raise_error(ArgumentError)
25
25
  end
26
26
  end
27
27
 
@@ -29,7 +29,7 @@ describe ZK do
29
29
  before { @zk = ZK.new }
30
30
 
31
31
  it %[should create a default connection] do
32
- @zk.should be_connected
32
+ expect(@zk).to be_connected
33
33
  end
34
34
  end
35
35
 
@@ -54,10 +54,10 @@ describe ZK do
54
54
  before { @zk = ZK.new(:chroot => chroot_path) }
55
55
 
56
56
  it %[should use the default connection string, create the chroot and return the connection] do
57
- @zk.exists?('/').should be_true
57
+ expect(@zk.exists?('/')).to be(true)
58
58
  @zk.create('/blah', 'data')
59
59
 
60
- @unchroot.get("#{chroot_path}/blah").first.should == 'data'
60
+ expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
61
61
  end
62
62
  end
63
63
 
@@ -69,10 +69,10 @@ describe ZK do
69
69
  end
70
70
 
71
71
  it %[should create the chroot path and then return the connection] do
72
- @zk.exists?('/').should be_true
72
+ expect(@zk.exists?('/')).to be(true)
73
73
  @zk.create('/blah', 'data')
74
74
 
75
- @unchroot.get("#{chroot_path}/blah").first.should == 'data'
75
+ expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
76
76
  end
77
77
  end
78
78
 
@@ -82,26 +82,26 @@ describe ZK do
82
82
  end
83
83
 
84
84
  it %[should create the chroot path and then return the connection] do
85
- @zk.exists?('/').should be_true
85
+ expect(@zk.exists?('/')).to be(true)
86
86
  @zk.create('/blah', 'data')
87
87
 
88
- @unchroot.get("#{chroot_path}/blah").first.should == 'data'
88
+ expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
89
89
  end
90
90
  end
91
91
 
92
92
  describe %[and :chroot => :check] do
93
93
  it %[should barf with a ChrootPathDoesNotExistError] do
94
- lambda do
94
+ expect do
95
95
  # assign in case of a bug, that way this connection will get torn down
96
96
  @zk = ZK.new("#{connection_host}#{chroot_path}", :chroot => :check)
97
- end.should raise_error(ZK::Exceptions::ChrootPathDoesNotExistError)
97
+ end.to raise_error(ZK::Exceptions::ChrootPathDoesNotExistError)
98
98
  end
99
99
  end
100
100
 
101
101
  describe %[and :chroot => :do_nothing] do
102
102
  it %[should return a connection in a weird state] do
103
103
  @zk = ZK.new("#{connection_host}#{chroot_path}", :chroot => :do_nothing)
104
- lambda { @zk.get('/') }.should raise_error(ZK::Exceptions::NoNode)
104
+ expect { @zk.get('/') }.to raise_error(ZK::Exceptions::NoNode)
105
105
  end
106
106
  end
107
107
 
@@ -109,10 +109,10 @@ describe ZK do
109
109
  before { @zk = ZK.new(connection_host, :chroot => chroot_path) }
110
110
 
111
111
  it %[should create the chroot path and then return the connection] do
112
- @zk.exists?('/').should be_true
112
+ expect(@zk.exists?('/')).to be(true)
113
113
  @zk.create('/blah', 'data')
114
114
 
115
- @unchroot.get("#{chroot_path}/blah").first.should == 'data'
115
+ expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
116
116
  end
117
117
  end
118
118
  end # as a connection string
@@ -125,10 +125,10 @@ describe ZK do
125
125
  before { @zk = ZK.new(:chroot => chroot_path) }
126
126
 
127
127
  it %[should use the default connection string and totally work] do
128
- @zk.exists?('/').should be_true
128
+ expect(@zk.exists?('/')).to be(true)
129
129
  @zk.create('/blah', 'data')
130
130
 
131
- @unchroot.get("#{chroot_path}/blah").first.should == 'data'
131
+ expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
132
132
  end
133
133
  end
134
134
 
@@ -139,10 +139,10 @@ describe ZK do
139
139
  end
140
140
 
141
141
  it %[should totally work] do
142
- @zk.exists?('/').should be_true
142
+ expect(@zk.exists?('/')).to be(true)
143
143
  @zk.create('/blah', 'data')
144
144
 
145
- @unchroot.get("#{chroot_path}/blah").first.should == 'data'
145
+ expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
146
146
  end
147
147
  end
148
148
 
@@ -152,26 +152,26 @@ describe ZK do
152
152
  end
153
153
 
154
154
  it %[should totally work] do
155
- @zk.exists?('/').should be_true
155
+ expect(@zk.exists?('/')).to be(true)
156
156
  @zk.create('/blah', 'data')
157
157
 
158
- @unchroot.get("#{chroot_path}/blah").first.should == 'data'
158
+ expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
159
159
  end
160
160
  end
161
161
 
162
162
  describe %[and :chroot => :check] do
163
163
  it %[should totally work] do
164
- lambda do
164
+ expect do
165
165
  # assign in case of a bug, that way this connection will get torn down
166
166
  @zk = ZK.new("#{connection_host}#{chroot_path}", :chroot => :check)
167
- end.should_not raise_error
167
+ end.not_to raise_error
168
168
  end
169
169
  end
170
170
 
171
171
  describe %[and :chroot => :do_nothing] do
172
172
  it %[should totally work] do
173
173
  @zk = ZK.new("#{connection_host}#{chroot_path}", :chroot => :do_nothing)
174
- lambda { @zk.get('/') }.should_not raise_error
174
+ expect { @zk.get('/') }.not_to raise_error
175
175
  end
176
176
  end
177
177
 
@@ -179,15 +179,15 @@ describe ZK do
179
179
  before { @zk = ZK.new(connection_host, :chroot => chroot_path) }
180
180
 
181
181
  it %[should totally work] do
182
- @zk.exists?('/').should be_true
182
+ expect(@zk.exists?('/')).to be(true)
183
183
  @zk.create('/blah', 'data')
184
184
 
185
- @unchroot.get("#{chroot_path}/blah").first.should == 'data'
185
+ expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
186
186
  end
187
187
  end
188
188
  end # as a connection string
189
189
  end # that exists
190
- end # with a chroot
190
+ end # with a chroot
191
191
  end # :new
192
192
  end # ZK
193
193
 
@@ -18,7 +18,7 @@ describe ZK::Mongoid::Locking do
18
18
  unless th.join(5) == th
19
19
  logger.warn { "Forcing pool closed!" }
20
20
  ZK::Mongoid::Locking.zk_lock_pool.force_close!
21
- th.join(5).should == th
21
+ expect(th.join(5)).to eq(th)
22
22
  end
23
23
 
24
24
  ZK::Mongoid::Locking.zk_lock_pool = nil
@@ -35,8 +35,8 @@ describe ZK::Mongoid::Locking do
35
35
  end
36
36
 
37
37
  th.join_until { !@lock_state.nil? }
38
- @lock_state.should_not be_nil
39
- @lock_state.should be_true
38
+ expect(@lock_state).not_to be_nil
39
+ expect(@lock_state).to be(true)
40
40
  end
41
41
 
42
42
  it %[should allow another thread to enter the shared lock] do
@@ -52,10 +52,10 @@ describe ZK::Mongoid::Locking do
52
52
  end
53
53
 
54
54
  @th1.join_until { @counter > 0 }
55
- @counter.should > 0
55
+ expect(@counter).to be > 0
56
56
 
57
57
  @th1.join_until { @queue.num_waiting > 0 }
58
- @queue.num_waiting.should > 0
58
+ expect(@queue.num_waiting).to be > 0
59
59
 
60
60
  @th2 = Thread.new do
61
61
  @other_doc.with_shared_lock do
@@ -64,9 +64,9 @@ describe ZK::Mongoid::Locking do
64
64
  end
65
65
 
66
66
  @th2.join_until { @counter == 2 }
67
- @counter.should == 2
67
+ expect(@counter).to eq(2)
68
68
 
69
- @th2.join(2).should == @th2
69
+ expect(@th2.join(2)).to eq(@th2)
70
70
  ensure
71
71
  @queue << :unlock
72
72
 
@@ -102,32 +102,32 @@ describe ZK::Mongoid::Locking do
102
102
  end
103
103
 
104
104
  @th1.join_until { q2.num_waiting >= 1 }
105
- q2.num_waiting.should >= 1
105
+ expect(q2.num_waiting).to be >= 1
106
106
 
107
107
  @th2.join_until { q1.size == 0 }
108
- q1.size.should be_zero
108
+ expect(q1.size).to be_zero
109
109
 
110
- @got_exclusive_lock.should_not be_true
110
+ expect(@got_exclusive_lock).not_to be(true)
111
111
 
112
112
  q2.enq(:release)
113
113
 
114
114
  @th1.join_until { q2.size == 0 }
115
- q2.size.should be_zero
115
+ expect(q2.size).to be_zero
116
116
 
117
117
  @th2.join_until(5) { @got_exclusive_lock }
118
- @got_exclusive_lock.should be_true
118
+ expect(@got_exclusive_lock).to be(true)
119
119
 
120
120
  rescue Exception => e
121
121
  $stderr.puts e.to_std_format
122
122
  raise e
123
- ensure
123
+ ensure
124
124
  q2 << :release
125
125
 
126
126
  unless @th1.join(2)
127
127
  $stderr.puts "UH OH! @th1 IS HUNG!!"
128
128
  end
129
129
 
130
- unless @th2.join(2)
130
+ unless @th2.join(2)
131
131
  $stderr.puts "UH OH! @th2 IS HUNG!!"
132
132
  end
133
133
  end
@@ -145,8 +145,8 @@ describe ZK::Mongoid::Locking do
145
145
  end
146
146
 
147
147
  th.join_until { !@lock_state.nil? }
148
- @lock_state.should_not be_nil
149
- @lock_state.should be_true
148
+ expect(@lock_state).not_to be_nil
149
+ expect(@lock_state).to be(true)
150
150
  end
151
151
 
152
152
  it %[should allow the same thread to re-enter the lock] do
@@ -165,7 +165,7 @@ describe ZK::Mongoid::Locking do
165
165
  end
166
166
 
167
167
  th.join_until { @counter >= 2 }
168
- @counter.should == 2
168
+ expect(@counter).to eq(2)
169
169
  end
170
170
 
171
171
  it %[should block another thread from entering the lock] do
@@ -181,9 +181,9 @@ describe ZK::Mongoid::Locking do
181
181
  end
182
182
 
183
183
  th1.join_until { @counter == 1 }
184
- @counter.should == 1
184
+ expect(@counter).to eq(1)
185
185
 
186
- th1.zk_mongoid_lock_registry[:exclusive].should include(@doc.zk_lock_name)
186
+ expect(th1.zk_mongoid_lock_registry[:exclusive]).to include(@doc.zk_lock_name)
187
187
 
188
188
  th2 = Thread.new do
189
189
  @other_doc.lock_for_update do
@@ -196,17 +196,17 @@ describe ZK::Mongoid::Locking do
196
196
 
197
197
  # this is not a deterministic check of whether or not th2 ran and did not
198
198
  # get the lock but probably close enough
199
-
200
- @counter.should == 1
201
- @other_doc_got_lock.should == false
202
- th2.zk_mongoid_lock_registry[:exclusive].should_not include(@other_doc.zk_lock_name)
199
+
200
+ expect(@counter).to eq(1)
201
+ expect(@other_doc_got_lock).to eq(false)
202
+ expect(th2.zk_mongoid_lock_registry[:exclusive]).not_to include(@other_doc.zk_lock_name)
203
203
 
204
204
  queue << :release_lock
205
- th1.join(5).should == th1
205
+ expect(th1.join(5)).to eq(th1)
206
206
 
207
207
  th2.join_until { @counter == 2 }
208
- @counter.should == 2
209
- @other_doc_got_lock.should be_true
208
+ expect(@counter).to eq(2)
209
+ expect(@other_doc_got_lock).to be(true)
210
210
  end
211
211
 
212
212
  describe :with_name do
@@ -217,7 +217,7 @@ describe ZK::Mongoid::Locking do
217
217
  after do
218
218
  if @queue.num_waiting > 0
219
219
  @queue << :bogus
220
- @th1.join(5).should == @th1
220
+ expect(@th1.join(5)).to eq(@th1)
221
221
  end
222
222
  end
223
223
 
@@ -235,9 +235,9 @@ describe ZK::Mongoid::Locking do
235
235
  end
236
236
 
237
237
  @th1.join_until { @counter == 1 }
238
- @counter.should == 1
238
+ expect(@counter).to eq(1)
239
239
 
240
- @th1.zk_mongoid_lock_registry[:exclusive].should include(@doc.zk_lock_name(@name))
240
+ expect(@th1.zk_mongoid_lock_registry[:exclusive]).to include(@doc.zk_lock_name(@name))
241
241
 
242
242
  @th2 = Thread.new do
243
243
  @other_doc.lock_for_update(@name) do
@@ -250,16 +250,16 @@ describe ZK::Mongoid::Locking do
250
250
 
251
251
  # this is not a deterministic check of whether or not @th2 ran and did not
252
252
  # get the lock but probably close enough
253
-
254
- @counter.should == 1
255
- @other_doc_got_lock.should == false
253
+
254
+ expect(@counter).to eq(1)
255
+ expect(@other_doc_got_lock).to eq(false)
256
256
 
257
257
  @queue << :release_lock
258
- @th1.join(5).should == @th1
258
+ expect(@th1.join(5)).to eq(@th1)
259
259
 
260
260
  @th2.join_until { @counter == 2 }
261
- @counter.should == 2
262
- @other_doc_got_lock.should be_true
261
+ expect(@counter).to eq(2)
262
+ expect(@other_doc_got_lock).to be(true)
263
263
  end
264
264
 
265
265
  it %[should not affect another thread using a different name] do
@@ -276,9 +276,9 @@ describe ZK::Mongoid::Locking do
276
276
  end
277
277
 
278
278
  @th1.join_until { @counter == 1 }
279
- @counter.should == 1
279
+ expect(@counter).to eq(1)
280
280
 
281
- @th1.zk_mongoid_lock_registry[:exclusive].should include(@doc.zk_lock_name(@name))
281
+ expect(@th1.zk_mongoid_lock_registry[:exclusive]).to include(@doc.zk_lock_name(@name))
282
282
 
283
283
  @th2 = Thread.new do
284
284
  @other_doc.lock_for_update do
@@ -288,41 +288,41 @@ describe ZK::Mongoid::Locking do
288
288
  end
289
289
 
290
290
  @th2.join_until { @other_doc_got_lock }
291
- @other_doc_got_lock.should be_true
292
-
293
- @counter.should == 2
291
+ expect(@other_doc_got_lock).to be(true)
292
+
293
+ expect(@counter).to eq(2)
294
294
 
295
295
  @queue << :release_lock
296
- @th1.join(2).should == @th1
296
+ expect(@th1.join(2)).to eq(@th1)
297
297
  end
298
298
  end
299
299
  end
300
300
 
301
301
  describe :assert_locked_for_update! do
302
302
  it %[should raise MustBeExclusivelyLockedException if the current thread does not hold the lock] do
303
- lambda { @doc.assert_locked_for_update! }.should raise_error(ZK::Exceptions::MustBeExclusivelyLockedException)
303
+ expect { @doc.assert_locked_for_update! }.to raise_error(ZK::Exceptions::MustBeExclusivelyLockedException)
304
304
  end
305
305
 
306
306
  it %[should not raise an exception if the current thread holds the lock] do
307
- lambda do
307
+ expect do
308
308
  @doc.lock_for_update do
309
309
  @doc.assert_locked_for_update!
310
310
  end
311
- end.should_not raise_error
311
+ end.not_to raise_error
312
312
  end
313
313
  end
314
314
 
315
315
  describe :assert_locked_for_share! do
316
316
  it %[should raise MustBeShareLockedException if the current thread does not hold a shared lock] do
317
- lambda { @doc.assert_locked_for_share! }.should raise_error(ZK::Exceptions::MustBeShareLockedException)
317
+ expect { @doc.assert_locked_for_share! }.to raise_error(ZK::Exceptions::MustBeShareLockedException)
318
318
  end
319
319
 
320
320
  it %[should not raise an exception if the current thread holds a shared lock] do
321
- lambda do
321
+ expect do
322
322
  @doc.with_shared_lock do
323
323
  @doc.assert_locked_for_share!
324
324
  end
325
- end.should_not raise_error
325
+ end.not_to raise_error
326
326
  end
327
327
  end
328
328
  end