spec/flipper/adapters/memoizable_spec.rb in flipper-0.10.1 vs spec/flipper/adapters/memoizable_spec.rb in flipper-0.10.2
- old
+ new
@@ -64,11 +64,11 @@
end
it "memoizes feature" do
feature = flipper[:stats]
result = subject.get(feature)
- expect(cache[feature]).to be(result)
+ expect(cache[feature.key]).to be(result)
end
end
context "with memoization disabled" do
before do
@@ -82,22 +82,54 @@
expect(result).to eq(adapter_result)
end
end
end
+ describe "#get_multi" do
+ context "with memoization enabled" do
+ before do
+ subject.memoize = true
+ end
+
+ it "memoizes feature" do
+ names = %i{stats shiny}
+ features = names.map { |name| flipper[name] }
+ results = subject.get_multi(features)
+ features.each do |feature|
+ expect(cache[feature.key]).to_not be(nil)
+ expect(cache[feature.key]).to be(results[feature.key])
+ end
+ end
+ end
+
+ context "with memoization disabled" do
+ before do
+ subject.memoize = false
+ end
+
+ it "returns result" do
+ names = %i{stats shiny}
+ features = names.map { |name| flipper[name] }
+ result = subject.get_multi(features)
+ adapter_result = adapter.get_multi(features)
+ expect(result).to eq(adapter_result)
+ end
+ end
+ end
+
describe "#enable" do
context "with memoization enabled" do
before do
subject.memoize = true
end
it "unmemoizes feature" do
feature = flipper[:stats]
gate = feature.gate(:boolean)
- cache[feature] = {:some => 'thing'}
+ cache[feature.key] = {:some => 'thing'}
subject.enable(feature, gate, flipper.bool)
- expect(cache[feature]).to be_nil
+ expect(cache[feature.key]).to be_nil
end
end
context "with memoization disabled" do
before do
@@ -121,13 +153,13 @@
end
it "unmemoizes feature" do
feature = flipper[:stats]
gate = feature.gate(:boolean)
- cache[feature] = {:some => 'thing'}
+ cache[feature.key] = {:some => 'thing'}
subject.disable(feature, gate, flipper.bool)
- expect(cache[feature]).to be_nil
+ expect(cache[feature.key]).to be_nil
end
end
context "with memoization disabled" do
before do
@@ -205,13 +237,13 @@
expect(cache).to be_empty
end
it "unmemoizes the feature" do
feature = flipper[:stats]
- cache[feature] = {:some => 'thing'}
+ cache[feature.key] = {:some => 'thing'}
subject.remove(feature)
- expect(cache[feature]).to be_nil
+ expect(cache[feature.key]).to be_nil
end
end
context "with memoization disabled" do
before do
@@ -230,12 +262,12 @@
subject.memoize = true
end
it "unmemoizes feature" do
feature = flipper[:stats]
- cache[feature] = {:some => 'thing'}
+ cache[feature.key] = {:some => 'thing'}
subject.clear(feature)
- expect(cache[feature]).to be_nil
+ expect(cache[feature.key]).to be_nil
end
end
context "with memoization disabled" do
before do