spec/flipper/dsl_spec.rb in flipper-0.4.0 vs spec/flipper/dsl_spec.rb in flipper-0.5.0
- old
+ new
@@ -6,17 +6,14 @@
subject { Flipper::DSL.new(adapter) }
let(:source) { {} }
let(:adapter) { Flipper::Adapters::Memory.new(source) }
- let(:admins_feature) { Flipper::Feature.new(:admins, adapter) }
-
describe "#initialize" do
- it "wraps adapter" do
+ it "sets adapter" do
dsl = described_class.new(adapter)
- dsl.adapter.should be_instance_of(Flipper::Adapter)
- dsl.adapter.adapter.should eq(adapter)
+ dsl.adapter.should_not be_nil
end
it "defaults instrumenter to noop" do
dsl = described_class.new(adapter)
dsl.instrumenter.should be(Flipper::Instrumenters::Noop)
@@ -35,58 +32,36 @@
dsl.adapter.instrumenter.should be(instrumenter)
end
end
end
- describe "#enabled?" do
- before do
- subject.stub(:feature => admins_feature)
- end
-
- it "passes arguments to feature enabled check and returns result" do
- admins_feature.should_receive(:enabled?).with(:foo).and_return(true)
- subject.should_receive(:feature).with(:stats).and_return(admins_feature)
- subject.enabled?(:stats, :foo).should be_true
- end
- end
-
- describe "#enable" do
- before do
- subject.stub(:feature => admins_feature)
- end
-
- it "calls enable for feature with arguments" do
- admins_feature.should_receive(:enable).with(:foo)
- subject.should_receive(:feature).with(:stats).and_return(admins_feature)
- subject.enable :stats, :foo
- end
- end
-
- describe "#disable" do
- before do
- subject.stub(:feature => admins_feature)
- end
-
- it "calls disable for feature with arguments" do
- admins_feature.should_receive(:disable).with(:foo)
- subject.should_receive(:feature).with(:stats).and_return(admins_feature)
- subject.disable :stats, :foo
- end
- end
-
describe "#feature" do
it_should_behave_like "a DSL feature" do
+ let(:method_name) { :feature }
let(:instrumenter) { double('Instrumentor', :instrument => nil) }
- let(:feature) { dsl.feature(:stats) }
+ let(:feature) { dsl.send(method_name, :stats) }
let(:dsl) { Flipper::DSL.new(adapter, :instrumenter => instrumenter) }
end
end
describe "#[]" do
it_should_behave_like "a DSL feature" do
+ let(:method_name) { :[] }
let(:instrumenter) { double('Instrumentor', :instrument => nil) }
- let(:feature) { dsl[:stats] }
+ let(:feature) { dsl.send(method_name, :stats) }
let(:dsl) { Flipper::DSL.new(adapter, :instrumenter => instrumenter) }
+ end
+ end
+
+ describe "#boolean" do
+ it_should_behave_like "a DSL boolean method" do
+ let(:method_name) { :boolean }
+ end
+ end
+
+ describe "#bool" do
+ it_should_behave_like "a DSL boolean method" do
+ let(:method_name) { :bool }
end
end
describe "#group" do
context "for registered group" do