Sha256: 0d2413491de45e7c316e2fe6a77a49cba3721f9059a774ce17c1732853d96aef

Contents?: true

Size: 970 Bytes

Versions: 2

Compression:

Stored size: 970 Bytes

Contents

require 'helper'
require 'flipper/adapters/memory'
require 'flipper/ui/decorators/gate'

describe Flipper::UI::Decorators::Gate do
  let(:source)  { {} }
  let(:adapter) { Flipper::Adapters::Memory.new(source) }
  let(:flipper) { Flipper.new(adapter) }
  let(:feature) { flipper[:some_awesome_feature] }
  let(:gate) { feature.gate(:boolean) }

  subject {
    described_class.new(gate, false)
  }

  describe "#initialize" do
    it "sets gate" do
      subject.gate.should be(gate)
    end

    it "sets value" do
      subject.value.should eq(false)
    end
  end

  describe "#as_json" do
    before do
      @result = subject.as_json
    end

    it "returns Hash" do
      @result.should be_instance_of(Hash)
    end

    it "includes key" do
      @result['key'].should eq('boolean')
    end

    it "includes pretty name" do
      @result['name'].should eq('boolean')
    end

    it "includes value" do
      @result['value'].should be(false)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flipper-ui-0.2.0.beta2 spec/flipper/ui/decorators/gate_spec.rb
flipper-ui-0.2.0.beta1 spec/flipper/ui/decorators/gate_spec.rb