Sha256: 13a93adb9d872cf55a68b06a6903c7ebacc8727b4a29f207b637e5f3687e0228

Contents?: true

Size: 1.06 KB

Versions: 32

Compression:

Stored size: 1.06 KB

Contents

require 'logstash-logger'
require 'redis'

describe LogStashLogger::Device::Redis do
  include_context 'device'

  let(:redis) { double("Redis") }

  before(:each) do
    allow(Redis).to receive(:new) { redis }
    allow(redis).to receive(:connect)
  end

  it "writes to a Redis list" do
    expect(redis).to receive(:rpush)
    redis_device.write "foo"
  end

  it "defaults the Redis list to 'logstash'" do
    expect(redis_device.list).to eq('logstash')
  end

  describe "initializer" do
    let(:redis_options) { { host: HOST, port: 6379 } }
    subject { LogStashLogger::Device::Redis.new(redis_options).connect }

    context "path is not blank" do
      before do
        redis_options[:path] = "/0"
      end

      it "sets the db" do
        expect(Redis).to receive(:new).with(hash_including(db: 0))
        subject
      end

    end

    context "path is blank" do
      before do
        redis_options[:path] = ""
      end

      it "does not set the db" do
        expect(Redis).to receive(:new).with(hash_excluding(:db))
        subject
      end
    end

  end

end

Version data entries

32 entries across 32 versions & 3 rubygems

Version Path
logstash-logger-p-0.26.1 spec/device/redis_spec.rb
logstash-logger-yajl-0.27.0 spec/device/redis_spec.rb
logstash-logger-0.26.1 spec/device/redis_spec.rb
logstash-logger-0.26.0 spec/device/redis_spec.rb
logstash-logger-0.25.1 spec/device/redis_spec.rb
logstash-logger-0.25.0 spec/device/redis_spec.rb
logstash-logger-0.24.1 spec/device/redis_spec.rb
logstash-logger-0.24.0 spec/device/redis_spec.rb
logstash-logger-0.23.0 spec/device/redis_spec.rb
logstash-logger-0.22.1 spec/device/redis_spec.rb
logstash-logger-0.22.0 spec/device/redis_spec.rb
logstash-logger-0.21.0 spec/device/redis_spec.rb
logstash-logger-0.20.1 spec/device/redis_spec.rb
logstash-logger-0.20.0 spec/device/redis_spec.rb
logstash-logger-0.19.2 spec/device/redis_spec.rb
logstash-logger-0.19.1 spec/device/redis_spec.rb
logstash-logger-0.19.0 spec/device/redis_spec.rb
logstash-logger-0.18.1 spec/device/redis_spec.rb
logstash-logger-0.18.0 spec/device/redis_spec.rb
logstash-logger-0.17.0 spec/device/redis_spec.rb