Sha256: badd2eaf7de38963d05a065530f9036b009c3c12706aaac495552409acf22596

Contents?: true

Size: 1.12 KB

Versions: 83

Compression:

Stored size: 1.12 KB

Contents

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

gem 'evented-spec', '~> 0.9.0'
require 'evented-spec'


describe 'ZookeeperEM' do
  describe 'Client' do
    include EventedSpec::SpecHelper
    default_timeout 3.0

    def setup_zk
      @zk = ZookeeperEM::Client.new(Zookeeper.default_cnx_str)
      em do
        @zk.on_attached do
          yield
        end
      end
    end

    def teardown_and_done
      @zk.close do 
        logger.debug { "TEST: about to call done" }
        EM.next_tick do
          done
        end
      end
    end

    describe 'callbacks' do
      it %[should be called on the reactor thread] do
        cb = lambda do |h|
          EM.reactor_thread?.should be_true
          logger.debug { "called back on the reactor thread? #{EM.reactor_thread?}" }
          teardown_and_done
        end

        setup_zk do
          @zk.on_attached do |*|
            logger.debug { "on_attached called" }
            rv = @zk.get(:path => '/', :callback => cb) 
            logger.debug { "rv from @zk.get: #{rv.inspect}" }
          end
        end
      end
    end
  end
end


Version data entries

83 entries across 83 versions & 2 rubygems

Version Path
zookeeper-1.2.10-java spec/em_spec.rb
zookeeper-1.2.9 spec/em_spec.rb
zookeeper-1.2.9-java spec/em_spec.rb
zookeeper-1.2.8 spec/em_spec.rb
zookeeper-1.2.8-java spec/em_spec.rb
zookeeper-1.2.7 spec/em_spec.rb
zookeeper-1.2.7-java spec/em_spec.rb
zookeeper-1.2.6 spec/em_spec.rb
zookeeper-1.2.6-java spec/em_spec.rb
zookeeper-1.2.5 spec/em_spec.rb
zookeeper-1.2.5-java spec/em_spec.rb
zookeeper-1.2.4 spec/em_spec.rb
zookeeper-1.2.4-java spec/em_spec.rb
zookeeper-1.2.3 spec/em_spec.rb
zookeeper-1.2.3-java spec/em_spec.rb
zookeeper-1.2.2 spec/em_spec.rb
zookeeper-1.2.2-java spec/em_spec.rb
zookeeper-1.2.1 spec/em_spec.rb
zookeeper-1.2.1-java spec/em_spec.rb
zookeeper-1.1.3 spec/em_spec.rb