Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Calling #could without a block raises an error

  • Loading branch information...
commit 096c78a8f4c928447fcce5cc7f2b0477a212fc13 1 parent f897275
Isaac Sanders authored
Showing with 5 additions and 0 deletions.
  1. +1 −0  lib/reuser/role.rb
  2. +4 −0 spec/reuser/role_spec.rb
View
1  lib/reuser/role.rb
@@ -23,6 +23,7 @@ def can? permission
end
def could permission, &block
+ raise "#could requires a block" unless block_given?
@permissions[permission] = block
end
View
4 spec/reuser/role_spec.rb
@@ -33,6 +33,10 @@
subject.can?(:write).should be_true
end
+ it 'you need to supply #could with a test block' do
+ lambda { subject.could(:read) }.should raise_error
+ end
+
it 'conditional permissions are added and checked with #could and #could?' do
subject.can?(:write).should be_false
subject.could :write do |language|
Please sign in to comment.
Something went wrong with that request. Please try again.