Sha256: 429fd15cecb25f1a4aae0f929fac2d54dd4fe39bbf616920d030296d00edcfd7

Contents?: true

Size: 1.03 KB

Versions: 56

Compression:

Stored size: 1.03 KB

Contents

require File.expand_path('../spec_helper', __FILE__) 

describe Zookeeper do
  describe :initialize, 'with watcher block' do
    before do
      @events = []
      @watch_block = lambda do |hash| 
        $stderr.puts "watch_block: #{hash.inspect}"
        @events << hash
      end

      @zk = Zookeeper.new('localhost:2181', 10, @watch_block)

      wait_until(2) { @zk.connected? }
      @zk.should be_connected
      $stderr.puts "connected!"

      wait_until(2) { !@events.empty? }
      $stderr.puts "got events!"
    end

    after do
      @zk.close if @zk.connected?
    end

    it %[should receive initial connection state events] do
      @events.should_not be_empty
      @events.length.should == 1
      @events.first[:state].should == Zookeeper::ZOO_CONNECTED_STATE
    end

    it %[should receive disconnection events] do
      pending "the C driver doesn't appear to deliver disconnection events (?)"
      @events.clear
      @zk.close
      wait_until(2) { !@events.empty? }
      @events.should_not be_empty
    end
  end
end

Version data entries

56 entries across 56 versions & 2 rubygems

Version Path
zookeeper-0.9.4 spec/default_watcher_spec.rb
zookeeper-0.9.4-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.9.4 spec/default_watcher_spec.rb
slyphon-zookeeper-0.9.4-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.9.3 spec/default_watcher_spec.rb
slyphon-zookeeper-0.9.3-java spec/default_watcher_spec.rb
zookeeper-0.9.3 spec/default_watcher_spec.rb
zookeeper-0.9.3-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.9.2 spec/default_watcher_spec.rb
slyphon-zookeeper-0.9.2-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.9.1 spec/default_watcher_spec.rb
slyphon-zookeeper-0.9.1-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.8.4 spec/default_watcher_spec.rb
slyphon-zookeeper-0.8.4-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.9.0 spec/default_watcher_spec.rb
slyphon-zookeeper-0.9.0-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.8.3 spec/default_watcher_spec.rb
slyphon-zookeeper-0.8.3-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.8.2 spec/default_watcher_spec.rb
slyphon-zookeeper-0.8.2-java spec/default_watcher_spec.rb