Browse files

adding documentation for testing abilities - closes #6

  • Loading branch information...
ryanb committed Nov 17, 2009
1 parent 1edf583 commit df276536abf2377e23f2e165bb270d4d5d0678a6
Showing with 12 additions and 0 deletions.
  1. +12 −0 README.rdoc
@@ -191,6 +191,18 @@ For example, let's assume that each user has_many :permissions, and each permiss
The actual details will depend largely on your application requirements, but hopefully you can see how it's possible to define permissions in the database and use them with CanCan.
+== Testing Abilities
+It is very easy to test the Ability model since you can call "can?" directly on it as you would in the view or controller.
+def test "user can only destroy projects which he owns"
+ user =
+ ability =
+ assert ability.can?(:destroy, => user))
+ assert !ability.can?(:destroy,
== Special Thanks
CanCan was inspired by declarative_authorization[] and aegis[]. Many thanks to the authors and contributors.

0 comments on commit df27653

Please sign in to comment.