Sha256: 61789e254bb7360e6f43f17611e231e6f7a51becab96f0820d96161f50660ad7

Contents?: true

Size: 993 Bytes

Versions: 4

Compression:

Stored size: 993 Bytes

Contents

require 'spec_helper'
require 'fixtures/models'

shared_examples_for CanTango::Ability::Mode::Base do
  before do
    @user = User.new 'admin', 'admin@mail.ru'
    @ability = CanTango::Ability::Base.new @user
  end

  describe 'Can be built from a candidate' do
    before do
      @user = User.new 'admin', 'admin@mail.ru'
    end
    subject { mode_class.build @user }
    
    specify do
      subject.ability.should be_a CanTango::Ability::Base
    end
  end

  subject { mode_class.new @ability }

  describe 'Does NOT execute on instantiation' do
    specify do
      subject.rules.should == []
    end
  end

  describe 'execute will calculate rules' do
    before do
      subject.execute
    end
    specify { subject.rules.should_not be_empty }
    specify { subject.rules.size.should == 1 }
    specify { subject.rules.first.should be_a CanCan::Rule }
    
    specify { subject.can?(:read, Post).should be_true }
    specify { subject.should be_allowed_to(:read, Post) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cantango-core-0.1.9.3 spec/cantango/ability/mode/base_example.rb
cantango-core-0.1.9.2 spec/cantango/ability/mode/base_example.rb
cantango-core-0.1.9.1 spec/cantango/ability/mode/base_example.rb
cantango-core-0.1.9 spec/cantango/ability/mode/base_example.rb