zk 1.9.3 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/build.yml +55 -0
  3. data/.gitignore +1 -0
  4. data/Gemfile +18 -8
  5. data/README.markdown +9 -9
  6. data/RELEASES.markdown +28 -1
  7. data/lib/zk/client/base.rb +15 -0
  8. data/lib/zk/client/threaded.rb +3 -3
  9. data/lib/zk/client.rb +1 -1
  10. data/lib/zk/election.rb +1 -1
  11. data/lib/zk/event_handler.rb +16 -8
  12. data/lib/zk/event_handler_subscription/base.rb +1 -1
  13. data/lib/zk/fork_hook.rb +9 -4
  14. data/lib/zk/locker/locker_base.rb +14 -2
  15. data/lib/zk/locker/semaphore.rb +1 -3
  16. data/lib/zk/logger.rb +34 -0
  17. data/lib/zk/node_deletion_watcher.rb +4 -5
  18. data/lib/zk/pool.rb +12 -12
  19. data/lib/zk/subscription.rb +1 -1
  20. data/lib/zk/threaded_callback.rb +1 -1
  21. data/lib/zk/threadpool.rb +1 -1
  22. data/lib/zk/version.rb +1 -1
  23. data/lib/zk.rb +1 -5
  24. data/spec/event_catcher_spec.rb +1 -1
  25. data/spec/logging_progress_bar_formatter.rb +1 -1
  26. data/spec/message_queue_spec.rb +6 -6
  27. data/spec/shared/client_examples.rb +81 -81
  28. data/spec/shared/locker_examples.rb +13 -13
  29. data/spec/spec_helper.rb +12 -13
  30. data/spec/support/bogus_mongoid.rb +1 -1
  31. data/spec/support/client_forker.rb +1 -1
  32. data/spec/support/event_catcher.rb +1 -1
  33. data/spec/support/logging.rb +15 -47
  34. data/spec/zk/00_forked_client_integration_spec.rb +3 -3
  35. data/spec/zk/client/locking_and_session_death_spec.rb +2 -2
  36. data/spec/zk/client_spec.rb +19 -19
  37. data/spec/zk/election_spec.rb +44 -44
  38. data/spec/zk/extensions_spec.rb +2 -2
  39. data/spec/zk/locker/exclusive_locker_spec.rb +41 -41
  40. data/spec/zk/locker/locker_basic_spec.rb +55 -33
  41. data/spec/zk/locker/semaphore_spec.rb +39 -32
  42. data/spec/zk/locker/shared_exclusive_integration_spec.rb +37 -37
  43. data/spec/zk/locker/shared_locker_spec.rb +43 -43
  44. data/spec/zk/locker_spec.rb +2 -2
  45. data/spec/zk/module_spec.rb +25 -25
  46. data/spec/zk/mongoid_spec.rb +47 -47
  47. data/spec/zk/node_deletion_watcher_spec.rb +39 -31
  48. data/spec/zk/pool_spec.rb +56 -65
  49. data/spec/zk/threaded_callback_spec.rb +10 -10
  50. data/spec/zk/threadpool_spec.rb +25 -25
  51. data/spec/zk/watch_spec.rb +67 -79
  52. data/spec/zk/zookeeper_spec.rb +36 -30
  53. data/zk.gemspec +1 -2
  54. metadata +26 -47
  55. data/.travis.yml +0 -25
  56. data/lib/zk/logging.rb +0 -36
data/spec/spec_helper.rb CHANGED
@@ -9,11 +9,11 @@ if File.exists?(release_ops_path)
9
9
  ReleaseOps::SimpleCov.maybe_start
10
10
  end
11
11
 
12
-
13
12
  Bundler.require(:development, :test)
14
13
 
15
14
  require 'zk'
16
15
  require 'benchmark'
16
+ require 'pry'
17
17
 
18
18
  # Requires supporting ruby files with custom matchers and macros, etc,
19
19
  # in spec/support/ and its subdirectories.
@@ -21,11 +21,10 @@ Dir[File.expand_path("../{support,shared}/**/*.rb", __FILE__)].sort.each {|f| re
21
21
 
22
22
  $stderr.sync = true
23
23
 
24
- require 'flexmock'
25
-
26
24
  RSpec.configure do |config|
27
- config.mock_with :flexmock
28
- config.include(FlexMock::ArgumentTypes)
25
+ config.expect_with :rspec do |c|
26
+ c.syntax = :expect
27
+ end
29
28
 
30
29
  [WaitWatchers, SpecGlobalLogger, Pendings].each do |mod|
31
30
  config.include(mod)
@@ -48,8 +47,8 @@ RSpec.configure do |config|
48
47
  if ZK.spawn_zookeeper?
49
48
  require 'zk-server'
50
49
 
51
- config.before(:suite) do
52
- ::Logging.logger['spec'].debug { "Starting zookeeper service" }
50
+ config.before(:suite) do
51
+ SpecGlobalLogger.logger.debug { "Starting zookeeper service" }
53
52
  ZK::Server.run do |c|
54
53
  c.client_port = ZK.test_port
55
54
  c.force_sync = false
@@ -58,7 +57,7 @@ RSpec.configure do |config|
58
57
  end
59
58
 
60
59
  config.after(:suite) do
61
- ::Logging.logger['spec'].debug { "stopping zookeeper service" }
60
+ SpecGlobalLogger.logger.debug { "stopping zookeeper service" }
62
61
  ZK::Server.shutdown
63
62
  end
64
63
  end
@@ -68,24 +67,24 @@ RSpec.configure do |config|
68
67
  count = 0
69
68
  ObjectSpace.each_object(klass) { |o| count += 1 if tester.call(o) }
70
69
  unless count.zero?
71
- raise "There were #{count} leaked #{klass} objects after #{example.full_description.inspect}"
70
+ raise "There were #{count} leaked #{klass} objects after #{example.full_description.inspect}"
72
71
  end
73
72
  end
74
73
 
75
74
  # these make tests run slow
76
75
  if ENV['ZK_LEAK_CHECK']
77
- config.after do
76
+ config.after do
78
77
  leak_check(ZK::Client::Threaded) { |o| !o.closed? }
79
78
  leak_check(ZK::ThreadedCallback, &:alive?)
80
79
  leak_check(ZK::Threadpool, &:alive?)
81
80
  leak_check(Thread) { |th| Thread.current != th && th.alive? }
82
- ZK::ForkHook.hooks.values.flatten.should be_empty
81
+ expect(ZK::ForkHook.hooks.values.flatten).to be_empty
83
82
  end
84
83
  end
85
84
  end
86
85
 
87
86
  class ::Thread
88
- # join with thread until given block is true, the thread joins successfully,
87
+ # join with thread until given block is true, the thread joins successfully,
89
88
  # or timeout seconds have passed
90
89
  #
91
90
  def join_until(timeout=2)
@@ -97,7 +96,7 @@ class ::Thread
97
96
  Thread.pass
98
97
  end
99
98
  end
100
-
99
+
101
100
  def join_while(timeout=2)
102
101
  time_to_stop = Time.now + timeout
103
102
 
@@ -1,6 +1,6 @@
1
1
  class BogusMongoid
2
2
  include ZK::Mongoid::Locking
3
- include ZK::Logging
3
+ include ZK::Logger
4
4
 
5
5
  attr_reader :id
6
6
 
@@ -1,5 +1,5 @@
1
1
  class ClientForker
2
- include ZK::Logging
2
+ include ZK::Logger
3
3
  attr_reader :base_path, :cnx_args, :stat
4
4
 
5
5
  def self.run(cnx_args, base_path)
@@ -1,6 +1,6 @@
1
1
  class EventCatcher
2
2
  extend Forwardable
3
- include ZK::Logging
3
+ include ZK::Logger
4
4
 
5
5
  def_delegators :@mutex, :synchronize
6
6
 
@@ -1,68 +1,36 @@
1
1
  module ZK
2
2
  TEST_LOG_PATH = File.join(ZK::ZK_ROOT, 'test.log')
3
3
 
4
- def self.logging_gem_setup
5
- layout_opts = {
6
- :pattern => '%.1l, [%d #%p] (%9.9T) %25.25c{2}: %m\n',
7
- }
8
-
9
- layout_opts[:date_pattern] = ZK.jruby? ? '%H:%M:%S.%3N' : '%H:%M:%S.%6N'
10
-
11
- layout = ::Logging.layouts.pattern(layout_opts)
12
-
13
- appender = ENV['ZK_DEBUG'] ? ::Logging.appenders.stderr : ::Logging.appenders.file(ZK::TEST_LOG_PATH)
14
- appender.layout = layout
15
- # appender.immediate_at = "debug,info,warn,error,fatal"
16
- # appender.auto_flushing = true
17
- appender.auto_flushing = 25
18
- appender.flush_period = 5
19
-
20
- %w[ZK ClientForker spec Zookeeper].each do |name|
21
- ::Logging.logger[name].tap do |log|
22
- log.appenders = [appender]
23
- log.level = :debug
4
+ def self.setup_test_logger
5
+ log =
6
+ if ENV['ZK_DEBUG']
7
+ ::Logger.new(STDERR)
8
+ else
9
+ ::Logger.new(TEST_LOG_PATH)
24
10
  end
25
- end
26
-
27
- # this logger is kinda noisy
28
- ::Logging.logger['ZK::EventHandler'].level = :info
29
-
30
- Zookeeper.logger = ::Logging.logger['Zookeeper']
31
- Zookeeper.logger.level = ENV['ZOOKEEPER_DEBUG'] ? :debug : :warn
32
-
33
- ZK::ForkHook.after_fork_in_child { ::Logging.reopen }
34
- end
35
11
 
12
+ log.level = ::Logger::DEBUG
36
13
 
37
- def self.stdlib_logger_setup
38
- require 'logger'
39
- log = ::Logger.new($stderr).tap {|l| l.level = ::Logger::DEBUG }
40
- ZK.logger = log
41
- Zookeeper.logger = log
14
+ ZK::Logger.wrapped_logger = log
42
15
  end
43
16
  end
44
17
 
45
- ZK.logging_gem_setup
46
- # ZK.stdlib_logger_setup
47
-
48
- # Zookeeper.logger = ZK.logger.clone_new_log(:progname => 'zoo')
49
- # Zookeeper.logger = ZK.logger
50
- # Zookeeper.set_debug_level(4)
18
+ ZK.setup_test_logger
51
19
 
52
20
  module SpecGlobalLogger
21
+ extend self
22
+
53
23
  def logger
54
- @spec_global_logger ||= ::Logging.logger['spec']
24
+ @spec_global_logger ||= Zookeeper::Logger::ForwardingLogger.for(ZK::Logger.wrapped_logger, 'spec')
55
25
  end
56
26
 
57
27
  # sets the log level to FATAL for the duration of the block
58
28
  def mute_logger
59
- zk_log = Logging.logger['ZK']
60
- orig_level, zk_log.level = zk_log.level, :off
61
- orig_zoo_level, Zookeeper.debug_level = Zookeeper.debug_level, Zookeeper::Constants::ZOO_LOG_LEVEL_ERROR
29
+ zk_log = ZK::Logger.wrapped_logger
30
+
31
+ orig_level, zk_log.level = zk_log.level, ::Logger::FATAL
62
32
  yield
63
33
  ensure
64
34
  zk_log.level = orig_level
65
- Zookeeper.debug_level = orig_zoo_level
66
35
  end
67
36
  end
68
-
@@ -23,9 +23,9 @@ describe 'forked client integration' do
23
23
  it %[should deliver callbacks in the child] do
24
24
  10.times do
25
25
  ClientForker.run(@cnx_args, @base_path) do |forker|
26
- forker.stat.should_not be_signaled
27
- forker.stat.should be_exited
28
- forker.stat.should be_success
26
+ expect(forker.stat).not_to be_signaled
27
+ expect(forker.stat).to be_exited
28
+ expect(forker.stat).to be_success
29
29
  end
30
30
  end
31
31
  end # should deliver callbacks in the child
@@ -42,9 +42,9 @@ shared_examples_for 'session death' do
42
42
  deliver_session_event_to(zoo_state, @other_zk)
43
43
 
44
44
  # ditto, this is probably happening synchrnously
45
- wait_until(2) { @a }.should be_true
45
+ expect(wait_until(2) { @a }).to be(true)
46
46
 
47
- lambda { th.join(2) }.should raise_error(zoo_error_class)
47
+ expect { th.join(2) }.to raise_error(zoo_error_class)
48
48
  end
49
49
  end # session death
50
50
 
@@ -21,7 +21,7 @@ describe ZK::Client::Threaded do
21
21
  it %[should do the right thing and not fail] do
22
22
  # this is an extra special case where the user obviously hates us
23
23
 
24
- @zk.should be_kind_of(ZK::Client::Threaded) # yeah yeah, just be sure
24
+ expect(@zk).to be_kind_of(ZK::Client::Threaded) # yeah yeah, just be sure
25
25
 
26
26
  shutdown_thread = nil
27
27
 
@@ -31,17 +31,17 @@ describe ZK::Client::Threaded do
31
31
 
32
32
  wait_while { shutdown_thread.nil? }
33
33
 
34
- shutdown_thread.should_not be_nil
35
- shutdown_thread.should be_kind_of(Thread)
34
+ expect(shutdown_thread).not_to be_nil
35
+ expect(shutdown_thread).to be_kind_of(Thread)
36
36
 
37
- shutdown_thread.join(5).should == shutdown_thread
37
+ expect(shutdown_thread.join(5)).to eq(shutdown_thread)
38
38
 
39
- wait_until(5) { @zk.closed? }.should be_true
39
+ expect(wait_until(5) { @zk.closed? }).to be(true)
40
40
  end
41
41
  end
42
42
  end
43
43
 
44
- describe :reopen do
44
+ describe :reopen, :jruby => :broken do
45
45
  include_context 'connection opts'
46
46
 
47
47
  before do
@@ -53,15 +53,15 @@ describe ZK::Client::Threaded do
53
53
  end
54
54
 
55
55
  it %[should say the client is connected after reopen] do
56
- @zk.connected?.should == true
56
+ expect(@zk.connected?).to eq(true)
57
57
 
58
58
  @zk.close!
59
59
 
60
- @zk.connected?.should == false
60
+ expect(@zk.connected?).to eq(false)
61
61
 
62
62
  @zk.reopen
63
63
 
64
- @zk.connected?.should == true
64
+ expect(@zk.connected?).to eq(true)
65
65
  end
66
66
  end
67
67
 
@@ -80,7 +80,7 @@ describe ZK::Client::Threaded do
80
80
  # TODO: this is a terrible test. there is no way to guarantee that this
81
81
  # has been retried. the join at the end should not raise an error
82
82
 
83
- @zk.should_not be_connected
83
+ expect(@zk).not_to be_connected
84
84
 
85
85
  th = Thread.new do
86
86
  @zk.stat('/path/to/blah', :retry_duration => 30)
@@ -89,11 +89,11 @@ describe ZK::Client::Threaded do
89
89
  th.run
90
90
 
91
91
  @zk.connect
92
- th.join(5).should == th
92
+ expect(th.join(5)).to eq(th)
93
93
  end
94
94
 
95
95
  it %[barfs if the connection is closed before the connected event is received] do
96
- @zk.should_not be_connected
96
+ expect(@zk).not_to be_connected
97
97
 
98
98
  exc = nil
99
99
 
@@ -110,14 +110,14 @@ describe ZK::Client::Threaded do
110
110
 
111
111
  @zk.close!
112
112
 
113
- th.join(5).should == th
113
+ expect(th.join(5)).to eq(th)
114
114
 
115
- exc.should_not be_nil
116
- exc.should be_kind_of(ZK::Exceptions::Retryable)
115
+ expect(exc).not_to be_nil
116
+ expect(exc).to be_kind_of(ZK::Exceptions::Retryable)
117
117
  end
118
118
 
119
119
  it %[should barf if the timeout expires] do
120
- @zk.should_not be_connected
120
+ expect(@zk).not_to be_connected
121
121
 
122
122
  exc = nil
123
123
 
@@ -132,10 +132,10 @@ describe ZK::Client::Threaded do
132
132
 
133
133
  th.run
134
134
 
135
- th.join(5).should == th
135
+ expect(th.join(5)).to eq(th)
136
136
 
137
- exc.should_not be_nil
138
- exc.should be_kind_of(ZK::Exceptions::Retryable)
137
+ expect(exc).not_to be_nil
138
+ expect(exc).to be_kind_of(ZK::Exceptions::Retryable)
139
139
  end
140
140
  end
141
141
  end # ZK::Client::Threaded
@@ -4,7 +4,7 @@ describe ZK::Election, :jruby => :broken do
4
4
  include_context 'connection opts'
5
5
 
6
6
  before do
7
- ZK.open(connection_host) do |cnx|
7
+ ZK.open(connection_host) do |cnx|
8
8
  logger.debug { "REMOVING /_zkelection" }
9
9
  cnx.rm_rf('/_zkelection')
10
10
  end
@@ -56,8 +56,8 @@ describe ZK::Election, :jruby => :broken do
56
56
  end
57
57
 
58
58
  @palin.on_losing_election do
59
- @obama_won.should be_true
60
- @palin.leader_acked?.should be_true
59
+ expect(@obama_won).to be(true)
60
+ expect(@palin.leader_acked?).to be(true)
61
61
  @palin_lost = true
62
62
  end
63
63
 
@@ -68,21 +68,21 @@ describe ZK::Election, :jruby => :broken do
68
68
  oth.run
69
69
 
70
70
  wait_until { @obama_waiting }
71
- @obama_waiting.should be_true
71
+ expect(@obama_waiting).to be(true)
72
72
 
73
73
  # palin's callbacks haven't fired
74
- @palin_lost.should be_nil
74
+ expect(@palin_lost).to be_nil
75
75
 
76
76
  latch.release
77
77
 
78
78
  wait_until { @obama_won }
79
- @obama_won.should be_true
79
+ expect(@obama_won).to be(true)
80
80
 
81
- lambda { oth.join(1).should == oth }.should_not raise_error
81
+ expect { expect(oth.join(1)).to eq(oth) }.not_to raise_error
82
82
 
83
83
  wait_until { @palin_lost }
84
84
 
85
- @palin_lost.should be_true
85
+ expect(@palin_lost).to be(true)
86
86
  end
87
87
  end
88
88
 
@@ -92,7 +92,7 @@ describe ZK::Election, :jruby => :broken do
92
92
  @obama_won = @obama_lost = @palin_won = @palin_lost = nil
93
93
  win_latch, lose_latch = Latch.new, Latch.new
94
94
 
95
- @obama.on_winning_election do
95
+ @obama.on_winning_election do
96
96
  logger.debug { "obama on_winning_election fired" }
97
97
  @obama_won = true
98
98
  win_latch.release
@@ -115,50 +115,50 @@ describe ZK::Election, :jruby => :broken do
115
115
  @palin_lost = true
116
116
  lose_latch.release
117
117
  end
118
-
118
+
119
119
  @obama.vote!
120
120
  @palin.vote!
121
121
 
122
122
  win_latch.await
123
- @obama_won.should be_true
123
+ expect(@obama_won).to be(true)
124
124
 
125
125
  lose_latch.await
126
- @palin_lost.should be_true
126
+ expect(@palin_lost).to be(true)
127
127
  end
128
128
 
129
129
  describe 'winner' do
130
130
  it %[should fire the on_winning_election callbacks] do
131
- @obama_won.should be_true
131
+ expect(@obama_won).to be(true)
132
132
  end
133
133
 
134
134
  it %[should not fire the on_losing_election callbacks] do
135
- @obama_lost.should be_nil
135
+ expect(@obama_lost).to be_nil
136
136
  end
137
137
 
138
138
  it %[should acknowledge completion of winning callbacks] do
139
- @zk.exists?(@obama.leader_ack_path).should be_true
139
+ expect(@zk.exists?(@obama.leader_ack_path)).to be(true)
140
140
  end
141
141
 
142
142
  it %[should write its data to the leader_ack node] do
143
- @zk.get(@obama.leader_ack_path).first.should == @data1
143
+ expect(@zk.get(@obama.leader_ack_path).first).to eq(@data1)
144
144
  end
145
145
 
146
146
  it %[should know it's the leader] do
147
- @obama.should be_leader
147
+ expect(@obama).to be_leader
148
148
  end
149
149
  end
150
150
 
151
151
  describe 'loser' do # gets a talk show on Fox News? I KEED! I KEED!
152
152
  it %[should know it isn't the leader] do
153
- @palin.should_not be_leader
153
+ expect(@palin).not_to be_leader
154
154
  end
155
155
 
156
156
  it %[should not fire the winning callbacks] do
157
- @palin_won.should_not be_true
157
+ expect(@palin_won).not_to be(true)
158
158
  end
159
159
 
160
160
  it %[should fire the losing callbacks] do
161
- @palin_lost.should be_true
161
+ expect(@palin_lost).to be(true)
162
162
  end
163
163
 
164
164
  it %[should take over as leader when the current leader goes away] do
@@ -167,13 +167,13 @@ describe ZK::Election, :jruby => :broken do
167
167
  @obama.zk.close!
168
168
  wait_until { @palin_won }
169
169
 
170
- @palin_won.should be_true # god forbid
170
+ expect(@palin_won).to be(true) # god forbid
171
171
 
172
172
  wait_until { @zk2.exists?(@palin.leader_ack_path) }
173
173
 
174
- @zk2.exists?(@palin.leader_ack_path).should be_true
174
+ expect(@zk2.exists?(@palin.leader_ack_path)).to be(true)
175
175
 
176
- @zk2.get(@palin.leader_ack_path).first.should == @data2
176
+ expect(@zk2.get(@palin.leader_ack_path).first).to eq(@data2)
177
177
  end
178
178
 
179
179
  it %[should remain leader if the original leader comes back] do
@@ -193,9 +193,9 @@ describe ZK::Election, :jruby => :broken do
193
193
  newbama.vote!
194
194
  wait_until { newbama.voted? }
195
195
 
196
- newbama.should be_voted
197
- win_again.should be_false
198
- newbama.should_not be_leader
196
+ expect(newbama).to be_voted
197
+ expect(win_again).to be(false)
198
+ expect(newbama).not_to be_leader
199
199
  end
200
200
  end
201
201
  end
@@ -207,12 +207,12 @@ describe ZK::Election, :jruby => :broken do
207
207
  before do
208
208
  @zk3 = ZK.new(*connection_args)
209
209
 
210
- @zk3.exists?('/_zkelection/2012/leader_ack').should be_false
210
+ expect(@zk3.exists?('/_zkelection/2012/leader_ack')).to be(false)
211
211
 
212
212
  @obama = ZK::Election::Candidate.new(@zk, @election_name, :data => @data1)
213
213
  @palin = ZK::Election::Candidate.new(@zk2, @election_name, :data => @data2)
214
214
 
215
- @zk3.exists?('/_zkelection/2012/leader_ack').should be_false
215
+ expect(@zk3.exists?('/_zkelection/2012/leader_ack')).to be(false)
216
216
 
217
217
  @observer = ZK::Election::Observer.new(@zk3, @election_name)
218
218
  end
@@ -231,17 +231,17 @@ describe ZK::Election, :jruby => :broken do
231
231
 
232
232
  @observer.observe!
233
233
  wait_until { !@observer.leader_alive.nil? }
234
- @observer.leader_alive.should_not be_nil
235
- @zk3.exists?(@observer.root_election_node).should be_false
234
+ expect(@observer.leader_alive).not_to be_nil
235
+ expect(@zk3.exists?(@observer.root_election_node)).to be(false)
236
236
  end
237
237
 
238
238
  it %[should set leader_alive to false] do
239
- @observer.leader_alive.should be_false
239
+ expect(@observer.leader_alive).to be(false)
240
240
  end
241
241
 
242
242
  it %[should fire death callbacks] do
243
- @events.length.should == 1
244
- @events.first.should == :death
243
+ expect(@events.length).to eq(1)
244
+ expect(@events.first).to eq(:death)
245
245
  end
246
246
  end
247
247
 
@@ -263,19 +263,19 @@ describe ZK::Election, :jruby => :broken do
263
263
  end
264
264
 
265
265
  it %[should be obama that won] do
266
- @obama.should be_leader
266
+ expect(@obama).to be_leader
267
267
  end
268
268
 
269
269
  it %[should be palin that lost] do
270
- @palin.should_not be_leader
270
+ expect(@palin).not_to be_leader
271
271
  end
272
272
 
273
273
  it %[should set leader_alive to true] do
274
- @observer.leader_alive.should be_true
274
+ expect(@observer.leader_alive).to be(true)
275
275
  end
276
276
 
277
277
  it %[should fire the new leader callbacks] do
278
- @got_life_event.should be_true
278
+ expect(@got_life_event).to be(true)
279
279
  end
280
280
  end
281
281
 
@@ -286,7 +286,7 @@ describe ZK::Election, :jruby => :broken do
286
286
  wait_until { @obama.leader? }
287
287
 
288
288
  @palin.vote!
289
- @palin.should_not be_leader
289
+ expect(@palin).not_to be_leader
290
290
 
291
291
  @got_life_event = @got_death_event = false
292
292
 
@@ -297,23 +297,23 @@ describe ZK::Election, :jruby => :broken do
297
297
 
298
298
  wait_until { !@observer.leader_alive.nil? }
299
299
 
300
- @observer.leader_alive.should be_true
300
+ expect(@observer.leader_alive).to be(true)
301
301
  @zk.close!
302
302
  wait_until { !@zk.connected? && @palin.leader? && @palin.leader_acked? }
303
303
  end
304
304
 
305
305
  it %[should be palin who is leader] do
306
- @palin.should be_leader
306
+ expect(@palin).to be_leader
307
307
  end
308
308
 
309
309
  it %[should have seen both the death and life events] do
310
- pending 'this test is flapping'
311
- @got_life_event.should be_true
312
- @got_death_event.should be_true
310
+ # pending 'this test is flapping'
311
+ expect(@got_life_event).to be(true)
312
+ expect(@got_death_event).to be(true)
313
313
  end
314
314
 
315
315
  it %[should see the data of the new leader] do
316
- @observer.leader_data.should == 'palin'
316
+ expect(@observer.leader_data).to eq('palin')
317
317
  end
318
318
  end
319
319
  end
@@ -6,8 +6,8 @@ module ZK
6
6
 
7
7
  it %[should not barf if backtrace is nil] do
8
8
  exc = StandardError.new
9
- exc.backtrace.should be_nil
10
- lambda { exc.to_std_format }.should_not raise_error
9
+ expect(exc.backtrace).to be_nil
10
+ expect { exc.to_std_format }.not_to raise_error
11
11
  end
12
12
  end
13
13
  end