Ruby on Rails Quickly test an ability


If you'd like to quickly test if an ability class is giving the correct permissions, you can initialize an ability in the console or on another context with the rails environment loaded, just pass an user instance to test against:

test_ability =
test_ability.can?(:show, Post) #=> true
other_ability =
other_ability.cannot?(:show, Post) #=> true

More information: