Sha256: 925e62ef96ca8b4f2d3935023310afc64aeb4e165f18e6a198eef86931f01f09

Contents?: true

Size: 747 Bytes

Versions: 4

Compression:

Stored size: 747 Bytes

Contents

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

describe Credentials::Rulebook do
  it "should be empty when created" do
    Credentials::Rulebook.new(Animal).should be_empty
  end
  
  it "should duplicate on inheritance" do
    Animal.credentials.should_not == Carnivore.credentials
    Animal.credentials.rules.should_not == Carnivore.credentials.rules
  end
  
  describe "created for an instance" do
    before :all do
      @penguin = Bird.new("Penguin")
      @penguin.metaclass.credentials do |penguin|
        penguin.can :swim
      end
      @emu = Bird.new("Emu")
    end
    
    it "should grant permissions only for that instance" do
      @penguin.should be_able_to(:swim)
      @emu.should_not be_able_to(:swim)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
credentials-2.4.3 spec/rulebook_spec.rb
credentials-2.4.2 spec/rulebook_spec.rb
credentials-2.4.1 spec/rulebook_spec.rb
credentials-2.4.0 spec/rulebook_spec.rb