Sha256: 9fa4112743c53a524bc8674d07c08c2fbd72fb2dbbfe1dd43950ff336fbee353

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

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)
      config == other.config if other.is_a?(ConnectionPoolSpy)
    end

    ConnectionCall = Struct.new(:block)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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