Sha256: a1225bce05c537b913510ba5601033ef1c406e3d3529213588e7117a4f3510f8
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
require 'helper' require 'flipper/adapters/memoized' require 'flipper/adapters/memory' require 'flipper/spec/shared_adapter_specs' describe Flipper::Adapters::Memoized do let(:cache) { {} } let(:source) { {} } let(:adapter) { Flipper::Adapters::Memory.new(source) } subject { described_class.new(adapter, cache) } def read_key(key) source[key.to_s] end def write_key(key, value) source[key.to_s] = value end it_should_behave_like 'a flipper adapter' describe "#read" do before do source['foo'] = 'bar' subject.read('foo') end it "memoizes key" do cache['foo'].should eq(source['foo']) cache['foo'].should eq('bar') end end describe "#set_members" do before do source['foo'] = Set['1', '2'] subject.set_members('foo') end it "memoizes key" do cache['foo'].should eq(source['foo']) cache['foo'].should eq(Set['1', '2']) end end describe "#write" do before do source['foo'] = 'bar' @result = subject.read('foo') subject.write('foo', 'bar') end it "unmemoizes key" do cache.key?('foo').should be_false end end describe "#delete" do before do source['foo'] = 'bar' @result = subject.read('foo') subject.delete('foo') end it "unmemoizes key" do cache.key?('foo').should be_false end end describe "#set_add" do before do source['foo'] = Set['1', '2'] @result = subject.set_members('foo') subject.set_add('foo', '3') end it "unmemoizes key" do cache.key?('foo').should be_false end end describe "#set_delete" do before do source['foo'] = Set['1', '2'] subject.set_delete('foo', '2') end it "unmemoizes key" do cache.key?('foo').should be_false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flipper-0.4.0 | spec/flipper/adapters/memoized_spec.rb |