Sha256: 8bc6feee074604ba69f217367b63e5b74c649ebe60b5ba512b412155098b95b4

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Walruz do

  it "should have a policies method" do
    Walruz.should respond_to(:policies)
  end
  
  describe '.policies' do
    
    it "should return all the policies created that have a label" do
      Walruz.policies.should_not be_nil
      Walruz.policies[:author_policy].should be_nil
      Walruz.policies[:in_colaboration].should == AuthorInColaborationPolicy
      Walruz.policies[:colaborating_with_john_policy].should == ColaboratingWithJohnPolicy
    end
    
  end
  
  describe ".fetch_policy" do
    
    it "should grab the policy if this is registered" do
      Walruz.fetch_policy(:in_colaboration).should == AuthorInColaborationPolicy
    end
    
    it "should raise an Walruz::ActionNotFound exception if the policy is not registered" do
      lambda do
        Walruz.fetch_policy(:author_in_colaboration_policy)
      end.should raise_error(Walruz::ActionNotFound)
    end

    it 'should fetch anonymous policies with a specified label' do
      new_policy = Walruz::Utils.any(AuthorInColaborationPolicy, 
                                     ColaboratingWithJohnPolicy)
      new_policy.set_policy_label(:crazy_policy)
      Walruz.fetch_policy(:crazy_policy).should_not be_nil
      Walruz.fetch_policy(:crazy_policy).should == new_policy
    end

    it 'should fetch composed policies with a specified label' do
      NewPolicy = Walruz::Utils.any(AuthorInColaborationPolicy, 
                                     ColaboratingWithJohnPolicy)
      NewPolicy.set_policy_label(:crazy_policy)
      Walruz.fetch_policy(:crazy_policy).should_not be_nil
      Walruz.fetch_policy(:crazy_policy).should == NewPolicy
    end
    
  end

  describe ".version" do

    it "should return a string representing the current version" do
      require 'yaml'
      version = ::YAML.load_file(File.dirname(__FILE__) + "/../../VERSION.yml")
      Walruz.version.should == "#{version[:major]}.#{version[:minor]}.#{version[:patch]}"
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
walruz-0.0.16 spec/walruz/walruz_spec.rb
walruz-0.0.15 spec/walruz/walruz_spec.rb