Sha256: c9cba21648f50305b765a76f7639f1489d119ba524a199da69cdbeba1d403694

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

require 'flapjack/redis_proxy'

describe Flapjack::RedisProxy do

  let(:options) { double('options') }

  it "does not initialize the Redis connection immediately" do
    expect(Redis).not_to receive(:new)

    Flapjack::RedisProxy.new
  end

  it "proxies commands through to the underlying Redis connection" do
    expect(Flapjack::RedisProxy).to receive(:config).and_return(options)

    redis = double(Redis)
    expect(redis).to receive(:info).and_return({'redis_version' => '2.8.17'})
    expect(redis).to receive(:keys).with('*')
    expect(Redis).to receive(:new).with(options).and_return(redis)

    proxy = Flapjack::RedisProxy.new
    proxy.keys('*')
  end

  it "throws an exception when redis is too old" do
    expect(Flapjack::RedisProxy).to receive(:config).and_return(options)

    redis = double(Redis)
    expect(redis).to receive(:info).and_return({'redis_version' => '2.1.1'})
    expect(Redis).to receive(:new).with(options).and_return(redis)

    proxy = Flapjack::RedisProxy.new
    expect {proxy.keys('*')}.to raise_exception(RuntimeError, 'Redis too old - Flapjack requires 2.6.12 but 2.1.1 is running')
  end

  it "does not initialize the Redis connection on quit if never used" do
    expect(Redis).not_to receive(:new)

    proxy = Flapjack::RedisProxy.new
    proxy.quit
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flapjack-2.0.0 spec/lib/flapjack/redis_proxy_spec.rb
flapjack-2.0.0rc1 spec/lib/flapjack/redis_proxy_spec.rb
flapjack-2.0.0b1 spec/lib/flapjack/redis_proxy_spec.rb