Sha256: 222a8449502314b088d43e648699f62886778dfe41f91375afc6a2a868bf753d

Contents?: true

Size: 808 Bytes

Versions: 1

Compression:

Stored size: 808 Bytes

Contents

require 'redis'
require 'hella-redis/connection_pool'
require 'hella-redis/connection_spy'

module HellaRedis

  class ConnectionPoolSpy

    attr_reader :config, :connection_spy, :connection_calls

    def initialize(config)
      @config           = config
      @connection_spy   = ConnectionSpy.new(config)
      @connection_calls = []
    end

    def calls
      @connection_spy.calls
    end

    def connection(&block)
      @connection_calls << ConnectionCall.new(block)
      block.call(@connection_spy)
    end

    def reset!
      @connection_calls     = []
      @connection_spy.calls = []
    end

    def ==(other_pool_spy)
      if other_pool_spy.kind_of?(ConnectionPoolSpy)
        self.config == other_pool_spy.config
      end
    end

    ConnectionCall = Struct.new(:block)

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hella-redis-0.4.0 lib/hella-redis/connection_pool_spy.rb