Sha256: ce63311019d3a98ea5e512ba6541f344a07909ac36196c6f3257dd8cb5731f33

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

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

describe Flipper::Gates::Actor 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 => :actor,
        :feature_name => :search,
      })
    end
  end

  describe "#description" do
    context "with actors in set" do
      before do
        adapter.stub(:set_members => Set['bacon', 'ham'])
      end

      it "returns text" do
        subject.description.should eq("actors (bacon, ham)")
      end
    end

    context "with no actors in set" do
      before do
        adapter.stub(:set_members => Set.new)
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

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