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
slyphon-zookeeper-0.2.4-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.2.4 spec/default_watcher_spec.rb
slyphon-zookeeper-0.2.3 spec/default_watcher_spec.rb
slyphon-zookeeper-0.2.3-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.2.1-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.2.1 spec/default_watcher_spec.rb
slyphon-zookeeper-0.2.0-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.2.0 spec/default_watcher_spec.rb
slyphon-zookeeper-0.1.7 spec/default_watcher_spec.rb
slyphon-zookeeper-0.1.7-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.1.6 spec/default_watcher_spec.rb
slyphon-zookeeper-0.1.6-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.1.4 spec/default_watcher_spec.rb
slyphon-zookeeper-0.1.4-java spec/default_watcher_spec.rb
slyphon-zookeeper-0.1.0 spec/default_watcher_spec.rb
slyphon-zookeeper-0.1.0-java spec/default_watcher_spec.rb