Sha256: ef62c4bf2e96aa47c4293057fab3137ed2813bb8554012c8ef05df3b164d8fe4

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'helper'

describe Flipper::Toggles::Value do
  let(:key) { double('Key') }
  let(:adapter) { double('Adapter', :read => '22') }
  let(:gate) { double('Gate', :adapter => adapter, :key => key) }

  subject {
    toggle = described_class.new(gate)
    toggle.stub(:value => 22)
    toggle
  }

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

      it "returns false" do
        subject.enabled?.should be_false
      end
    end

    context "for integer" do
      before do
        subject.stub(:value => 22)
      end

      it "returns true" do
        subject.enabled?.should be_true
      end
    end

    context "for string integer" do
      before do
        subject.stub(:value => '22')
      end

      it "returns true" do
        subject.enabled?.should be_true
      end
    end

    context "for zero" do
      before do
        subject.stub(:value => 0)
      end

      it "returns false" do
        subject.enabled?.should be_false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flipper-0.4.0 spec/flipper/toggles/value_spec.rb