Sha256: d9c80e00297197e4b1be47ab4fcc0c185c85c66c6a32320523329f431d9ddbb9

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require 'helper'

describe Flipper::Gate do
  let(:adapter) { double('Adapter', :name => 'memory', :read => '22') }
  let(:feature) { double('Feature', :name => :search, :adapter => adapter) }

  subject {
    gate = described_class.new(feature)
    # implemented in subclass
    gate.stub({
      :key => :actors,
      :description => 'enabled',
    })
    gate
  }

  describe "#initialize" do
    it "sets feature" do
      gate = described_class.new(feature)
      gate.feature.should be(feature)
    end

    it "defaults instrumenter" do
      gate = described_class.new(feature)
      gate.instrumenter.should be(Flipper::Instrumenters::Noop)
    end

    it "allows overriding instrumenter" do
      instrumenter = double('Instrumentor')
      gate = described_class.new(feature, :instrumenter => instrumenter)
      gate.instrumenter.should be(instrumenter)
    end
  end

  describe "#inspect" do
    it "returns easy to read string representation" do
      string = subject.inspect
      string.should include('Flipper::Gate')
      string.should include('feature=:search')
      string.should include('description="enabled"')
      string.should include("adapter=#{subject.adapter.name.inspect}")
      string.should include('adapter_key=#<Flipper::Key:')
      string.should include('toggle_class=Flipper::Toggles::Value')
      string.should include('toggle_value="22"')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flipper-0.4.0 spec/flipper/gate_spec.rb