Sha256: 1f9d2f1098335e0011b73742376c17777930faeb79f830f7c5538dd608716b1c
Contents?: true
Size: 1.25 KB
Versions: 3
Compression:
Stored size: 1.25 KB
Contents
require 'helper' require 'flipper/instrumenters/memory' describe Flipper::Gates::PercentageOfRandom do let(:instrumenter) { Flipper::Instrumenters::Memory.new } let(:feature_name) { :search } subject { described_class.new(feature_name, :instrumenter => instrumenter) } describe "instrumentation" do it "is recorded for open" do thing = Struct.new(:flipper_id).new('22') subject.open?(thing, 0) event = instrumenter.events.last event.should_not be_nil event.name.should eq('gate_operation.flipper') event.payload[:thing].should eq(thing) event.payload[:operation].should eq(:open?) event.payload[:gate_name].should eq(:percentage_of_random) event.payload[:feature_name].should eq(:search) # random so don't test value event.payload.key?(:result).should be_true event.payload[:result].should_not be_nil end end describe "#description" do context "when enabled" do it "returns text" do subject.description(22).should eq('22% of the time') end end context "when disabled" do it "returns disabled" do subject.description(nil).should eq('disabled') subject.description(0).should eq('disabled') end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
flipper-0.6.1 | spec/flipper/gates/percentage_of_random_spec.rb |
flipper-0.6.0 | spec/flipper/gates/percentage_of_random_spec.rb |
flipper-0.5.0 | spec/flipper/gates/percentage_of_random_spec.rb |