Sha256: 69776479823f5938cdb3e48646a995ddae1b98af61b0d6c9ced2d9fdf5b2cc8b
Contents?: true
Size: 1.43 KB
Versions: 15
Compression:
Stored size: 1.43 KB
Contents
require 'flipper/adapters/redis' RSpec.describe Flipper::Adapters::Redis do let(:client) do options = {} options[:url] = ENV['REDIS_URL'] if ENV['REDIS_URL'] Redis.raise_deprecations = true Redis.new(options) end subject { described_class.new(client) } before do skip_on_error(Redis::CannotConnectError, 'Redis not available') do client.flushdb end end it_should_behave_like 'a flipper adapter' it 'configures itself on load' do Flipper.configuration = nil Flipper.instance = nil silence { load 'flipper/adapters/redis.rb' } expect(Flipper.adapter.adapter).to be_a(Flipper::Adapters::Redis) end describe 'with a key_prefix' do let(:subject) { described_class.new(client, key_prefix: "lockbox:") } let(:feature) { Flipper::Feature.new(:search, subject) } it_should_behave_like 'a flipper adapter' it 'namespaces feature-keys' do subject.add(feature) expect(client.smembers("flipper_features")).to eq([]) expect(client.exists?("search")).to eq(false) expect(client.smembers("lockbox:flipper_features")).to eq(["search"]) expect(client.hgetall("lockbox:search")).not_to eq(nil) end it "can remove namespaced keys" do subject.add(feature) expect(client.smembers("lockbox:flipper_features")).to eq(["search"]) subject.remove(feature) expect(client.smembers("lockbox:flipper_features")).to be_empty end end end
Version data entries
15 entries across 15 versions & 1 rubygems