spec/reuser/role_spec.rb in reuser-3.1.0 vs spec/reuser/role_spec.rb in reuser-3.1.1
- old
+ new
@@ -1,37 +1,24 @@
require 'spec_helper'
describe ReUser::Role do
subject do
- role = ReUser::Role.new(:admin)
+ role = ReUser::Role.new
role.can(:read)
role
end
- it 'is initialized with a name, and optionally an array of permissions' do
- role = ReUser::Role.new :admin
- role.name.should == :admin
- role.permissions.should == []
-
- role = ReUser::Role.new :user
- role.name.should == :user
- role.permissions.should == []
-
- role = ReUser::Role.new :user, [:read, :write]
- role.name.should == :user
- role.permissions.should =~ [:read, :write]
+ it 'is initialized with an optional array of permissions' do
+ role = ReUser::Role.new :read, :write
+ role.should be_able_to :read
+ role.should be_able_to :write
end
- context 'shares its name and permissions' do
- its(:name) { should === :admin }
- its(:permissions) { should === [:read] }
- end
-
it 'permissions are added and checked with #can and #can?' do
- subject.can?(:read).should be_true
- subject.can?(:write).should be_false
+ subject.should be_able_to :read
+ subject.should_not be_able_to :write
subject.can(:write)
- subject.can?(:write).should be_true
+ subject.should be_able_to :write
end
it 'you need to supply #could with a test block' do
lambda { subject.could(:read) }.should raise_error
end