spec/flipper/feature_spec.rb in flipper-0.4.0 vs spec/flipper/feature_spec.rb in flipper-0.5.0

- old
+ new

@@ -15,11 +15,11 @@ feature.name.should eq(:search) end it "sets adapter" do feature = described_class.new(:search, adapter) - feature.adapter.should eq(Flipper::Adapter.wrap(adapter)) + feature.adapter.should eq(adapter) end it "defaults instrumenter" do feature = described_class.new(:search, adapter) feature.instrumenter.should be(Flipper::Instrumenters::Noop) @@ -32,17 +32,10 @@ feature = described_class.new(:search, adapter, { :instrumenter => instrumenter, }) feature.instrumenter.should be(instrumenter) end - - it "passes overridden instrumenter to adapter wrapping" do - feature = described_class.new(:search, adapter, { - :instrumenter => instrumenter, - }) - feature.adapter.instrumenter.should be(instrumenter) - end end end describe "#gate_for" do context "with percentage of actors" do @@ -65,16 +58,39 @@ end instance.gates.size.should be(5) end end + describe "#gate" do + context "with symbol name" do + it "returns gate by name" do + boolean_gate = subject.gates.detect { |gate| gate.name == :boolean } + subject.gate(:boolean).should eq(boolean_gate) + end + end + + context "with string name" do + it "returns gate by name" do + boolean_gate = subject.gates.detect { |gate| gate.name == :boolean } + subject.gate('boolean').should eq(boolean_gate) + end + end + + context "with name that does not exist" do + it "returns nil" do + subject.gate(:poo).should be_nil + end + end + end + describe "#inspect" do it "returns easy to read string representation" do string = subject.inspect string.should include('Flipper::Feature') string.should include('name=:search') string.should include('state=:off') + string.should include('description="Disabled"') string.should include("adapter=#{subject.adapter.name.inspect}") end end describe "instrumentation" do @@ -189,10 +205,10 @@ subject.enable Flipper::Types::PercentageOfRandom.new(5) subject.enable actor end it "returns text" do - subject.description.should eq('Enabled for actors (5), 5% of the time') + subject.description.should eq('Enabled for actors ("5"), 5% of the time') end end end end