spec/flipper/adapters/memoizable_spec.rb in flipper-0.7.1 vs spec/flipper/adapters/memoizable_spec.rb in flipper-0.7.2
- old
+ new
@@ -1,11 +1,11 @@
require 'helper'
require 'flipper/adapters/memoizable'
require 'flipper/adapters/memory'
require 'flipper/spec/shared_adapter_specs'
-describe Flipper::Adapters::Memoizable do
+RSpec.describe Flipper::Adapters::Memoizable do
let(:features_key) { described_class::FeaturesKey }
let(:adapter) { Flipper::Adapters::Memory.new }
let(:flipper) { Flipper.new(adapter) }
let(:cache) { {} }
@@ -14,32 +14,32 @@
it_should_behave_like 'a flipper adapter'
describe "#memoize=" do
it "sets value" do
subject.memoize = true
- subject.memoizing?.should eq(true)
+ expect(subject.memoizing?).to eq(true)
subject.memoize = false
- subject.memoizing?.should eq(false)
+ expect(subject.memoizing?).to eq(false)
end
it "clears the local cache" do
subject.cache['some'] = 'thing'
subject.memoize = true
- subject.cache.should be_empty
+ expect(subject.cache).to be_empty
end
end
describe "#memoizing?" do
it "returns true if enabled" do
subject.memoize = true
- subject.memoizing?.should eq(true)
+ expect(subject.memoizing?).to eq(true)
end
it "returns false if disabled" do
subject.memoize = false
- subject.memoizing?.should eq(false)
+ expect(subject.memoizing?).to eq(false)
end
end
describe "#get" do
context "with memoization enabled" do
@@ -48,11 +48,11 @@
end
it "memoizes feature" do
feature = flipper[:stats]
result = subject.get(feature)
- cache[feature].should be(result)
+ expect(cache[feature]).to be(result)
end
end
context "with memoization disabled" do
before do
@@ -61,11 +61,11 @@
it "returns result" do
feature = flipper[:stats]
result = subject.get(feature)
adapter_result = adapter.get(feature)
- result.should eq(adapter_result)
+ expect(result).to eq(adapter_result)
end
end
end
describe "#enable" do
@@ -77,11 +77,11 @@
it "unmemoizes feature" do
feature = flipper[:stats]
gate = feature.gate(:boolean)
cache[feature] = {:some => 'thing'}
subject.enable(feature, gate, flipper.bool)
- cache[feature].should be_nil
+ expect(cache[feature]).to be_nil
end
end
context "with memoization disabled" do
before do
@@ -91,11 +91,11 @@
it "returns result" do
feature = flipper[:stats]
gate = feature.gate(:boolean)
result = subject.enable(feature, gate, flipper.bool)
adapter_result = adapter.enable(feature, gate, flipper.bool)
- result.should eq(adapter_result)
+ expect(result).to eq(adapter_result)
end
end
end
describe "#disable" do
@@ -107,11 +107,11 @@
it "unmemoizes feature" do
feature = flipper[:stats]
gate = feature.gate(:boolean)
cache[feature] = {:some => 'thing'}
subject.disable(feature, gate, flipper.bool)
- cache[feature].should be_nil
+ expect(cache[feature]).to be_nil
end
end
context "with memoization disabled" do
before do
@@ -121,11 +121,11 @@
it "returns result" do
feature = flipper[:stats]
gate = feature.gate(:boolean)
result = subject.disable(feature, gate, flipper.bool)
adapter_result = adapter.disable(feature, gate, flipper.bool)
- result.should eq(adapter_result)
+ expect(result).to eq(adapter_result)
end
end
end
describe "#features" do
@@ -136,21 +136,21 @@
it "memoizes features" do
flipper[:stats].enable
flipper[:search].disable
result = subject.features
- cache[:flipper_features].should be(result)
+ expect(cache[:flipper_features]).to be(result)
end
end
context "with memoization disabled" do
before do
subject.memoize = false
end
it "returns result" do
- subject.features.should eq(adapter.features)
+ expect(subject.features).to eq(adapter.features)
end
end
end
describe "#add" do
@@ -160,21 +160,21 @@
end
it "unmemoizes the known features" do
cache[features_key] = {:some => 'thing'}
subject.add(flipper[:stats])
- cache.should be_empty
+ expect(cache).to be_empty
end
end
context "with memoization disabled" do
before do
subject.memoize = false
end
it "returns result" do
- subject.add(flipper[:stats]).should eq(adapter.add(flipper[:stats]))
+ expect(subject.add(flipper[:stats])).to eq(adapter.add(flipper[:stats]))
end
end
end
describe "#remove" do
@@ -184,28 +184,28 @@
end
it "unmemoizes the known features" do
cache[features_key] = {:some => 'thing'}
subject.remove(flipper[:stats])
- cache.should be_empty
+ expect(cache).to be_empty
end
it "unmemoizes the feature" do
feature = flipper[:stats]
cache[feature] = {:some => 'thing'}
subject.remove(feature)
- cache[feature].should be_nil
+ expect(cache[feature]).to be_nil
end
end
context "with memoization disabled" do
before do
subject.memoize = false
end
it "returns result" do
- subject.remove(flipper[:stats]).should eq(adapter.remove(flipper[:stats]))
+ expect(subject.remove(flipper[:stats])).to eq(adapter.remove(flipper[:stats]))
end
end
end
describe "#clear" do
@@ -216,21 +216,21 @@
it "unmemoizes feature" do
feature = flipper[:stats]
cache[feature] = {:some => 'thing'}
subject.clear(feature)
- cache[feature].should be_nil
+ expect(cache[feature]).to be_nil
end
end
context "with memoization disabled" do
before do
subject.memoize = false
end
it "returns result" do
feature = flipper[:stats]
- subject.clear(feature).should eq(adapter.clear(feature))
+ expect(subject.clear(feature)).to eq(adapter.clear(feature))
end
end
end
end