Skip to content

Commit

Permalink
Calling #could without a block raises an error
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Sanders committed Feb 3, 2012
1 parent f897275 commit 096c78a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/reuser/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def can? permission
end

def could permission, &block
raise "#could requires a block" unless block_given?
@permissions[permission] = block
end

Expand Down
4 changes: 4 additions & 0 deletions spec/reuser/role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit 096c78a

Please sign in to comment.