Sha256: 451eac50822e32cb54fe57d371b7a3f9a0a7625b1dbd9b5020ba41ef1ec2358d

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'helper'
require 'flipper/adapters/memory'
require 'flipper/adapters/dalli'
require 'flipper/spec/shared_adapter_specs'

RSpec.describe Flipper::Adapters::Dalli do
  let(:memory_adapter) { Flipper::Adapters::Memory.new }
  let(:cache)   { Dalli::Client.new(ENV["BOXEN_MEMCACHED_URL"] || '127.0.0.1:11211') }
  let(:adapter) { Flipper::Adapters::Dalli.new(memory_adapter, cache) }
  let(:flipper) { Flipper.new(adapter) }

  subject { described_class.new(adapter, cache) }

  before do
    cache.flush
  end

  it_should_behave_like 'a flipper adapter'

  describe "#remove" do
    it "expires feature" do
      feature = flipper[:stats]
      adapter.get(feature)
      adapter.remove(feature)
      expect(cache.get(described_class.key_for(feature))).to be(nil)
    end
  end

  describe "#get_multi" do
    it "warms uncached features" do
      stats = flipper[:stats]
      search = flipper[:search]
      other = flipper[:other]
      stats.enable
      search.enable

      adapter.get(stats)
      expect(cache.get(described_class.key_for(search))).to be(nil)
      expect(cache.get(described_class.key_for(other))).to be(nil)

      adapter.get_multi([stats, search, other])

      expect(cache.get(described_class.key_for(search))[:boolean]).to eq("true")
      expect(cache.get(described_class.key_for(other))[:boolean]).to be(nil)
    end
  end

  describe "#name" do
    it "is dalli" do
      expect(subject.name).to be(:dalli)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flipper-dalli-0.10.2 spec/flipper/adapters/dalli_spec.rb