Sha256: 28ec3e088d7acb368b9ec1c6f0220d8cf7eea817b3c762d91c032e17f57e2417

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'helper'
require 'flipper/instrumenters/memory'

describe Flipper::Gates::Boolean do
  let(:adapter) { double('Adapter', :read => nil) }
  let(:feature) { double('Feature', :name => :search, :adapter => adapter) }
  let(:instrumenter) { Flipper::Instrumenters::Memory.new }

  subject {
    described_class.new(feature, :instrumenter => instrumenter)
  }

  describe "#description" do
    context "for enabled" do
      before do
        subject.stub(:enabled? => true)
      end

      it "returns Enabled" do
        subject.description.should eq('Enabled')
      end
    end

    context "for disabled" do
      before do
        subject.stub(:enabled? => false)
      end

      it "returns Disabled" do
        subject.description.should eq('Disabled')
      end
    end
  end

  describe "instrumentation" do
    it "is recorded for open" do
      thing = nil
      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 => :boolean,
        :feature_name => :search,
      })
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flipper-0.4.0 spec/flipper/gates/boolean_spec.rb