Sha256: 7822501f0c2445e6ad6e83ea8183abab7cafcd791cc823c191ef9dd5bcb6e8dd
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
require 'helper' require 'flipper/instrumenters/memory' describe Flipper::Gates::Group do let(:adapter) { double('Adapter', :set_members => []) } let(:feature) { double('Feature', :name => :search, :adapter => adapter) } let(:instrumenter) { Flipper::Instrumenters::Memory.new } subject { described_class.new(feature, :instrumenter => instrumenter) } describe "instrumentation" do it "is recorded for open" do thing = Struct.new(:flipper_id).new('22') subject.open?(thing) event = instrumenter.events.last event.should_not be_nil event.name.should eq('gate_operation.flipper') event.payload.should eq({ :thing => thing, :operation => :open?, :result => false, :gate_name => :group, :feature_name => :search, }) end end describe "#description" do context "with groups in set" do before do adapter.stub(:set_members => Set['bacon', 'ham']) end it "returns text" do subject.description.should eq("groups (bacon, ham)") end end context "with no groups in set" do before do adapter.stub(:set_members => Set.new) end it "returns disabled" do subject.description.should eq('disabled') end end end describe "#open?" do context "with a group in adapter, but not registered" do before do Flipper.register(:staff) { |thing| true } adapter.stub(:set_members => Set[:newbs, :staff]) end it "ignores group" do thing = Struct.new(:flipper_id).new('5') subject.open?(thing).should be_true end end context "thing that does not respond to method in group block" do before do Flipper.register(:stinkers) { |thing| thing.stinker? } adapter.stub(:set_members => Set[:stinkers]) end it "raises error" do expect { subject.open?(Object.new) }.to raise_error(NoMethodError) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flipper-0.4.0 | spec/flipper/gates/group_spec.rb |