Sha256: 0c2f4871ae1558592c7fb89b4d77b371320d9d4b80d1ff142f94ac3e5d8f742b

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

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

describe Flipper::Gates::Actor 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, Set.new)

      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
      it "returns text" do
        values = Set['bacon', 'ham']
        subject.description(values).should eq('actors ("bacon", "ham")')
      end
    end

    context "with no actors in set" do
      it "returns disabled" do
        subject.description(Set.new).should eq('disabled')
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flipper-0.6.3 spec/flipper/gates/actor_spec.rb
flipper-0.6.2 spec/flipper/gates/actor_spec.rb
flipper-0.6.1 spec/flipper/gates/actor_spec.rb
flipper-0.6.0 spec/flipper/gates/actor_spec.rb
flipper-0.5.0 spec/flipper/gates/actor_spec.rb