Sha256: fc01057a04aecffe0e1c0df38c46d80040661ac841748f8be693b7e1e530c9b2

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

require "spec_helper"

describe Shamu::Features::Toggle do
  let( :path )    { File.expand_path( "../features.yml", __FILE__ ) }
  let( :toggles ) { Shamu::Features::Toggle.load( path ) }

  it "collapses path to name" do
    expect( toggles ).to have_key "shopping/buy_now"
  end

  it "imports relative files" do
    expect( toggles ).to have_key "shopping/offers/at_checkout"
  end

  context "with toggle" do
    let( :toggle ) { toggles[ "shopping/buy_now" ] }

    it "creates the toggle" do
      expect( toggle ).to be_a Shamu::Features::Toggle
    end

    it "parses selectors LIFO" do
      expect( toggle.selectors.count ).to eq 2
    end

    it "parses selector conditions" do
      expect( toggle.selectors.last.conditions.count ).to eq 7
    end
  end

  it "requires a retire_at date" do
     expect do
      Shamu::Features::Toggle.new( {} )
     end.to raise_error ArgumentError, /retire_at/
  end

  it "requires a type" do
     expect do
      Shamu::Features::Toggle.new( "retire_at" => Time.now )
     end.to raise_error ArgumentError, /Type/
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shamu-0.0.11 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.9 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.8 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.7 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.5 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.4 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.3 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.2 spec/lib/shamu/features/toggle_spec.rb