Sha256: bc88a1f1b575a68b334972082717507feee976c814559b171236d19c482a5c17

Contents?: true

Size: 1.05 KB

Versions: 9

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

9 entries across 9 versions & 1 rubygems

Version Path
shamu-0.0.24 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.21 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.20 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.19 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.18 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.17 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.15 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.14 spec/lib/shamu/features/toggle_spec.rb
shamu-0.0.13 spec/lib/shamu/features/toggle_spec.rb