Created
January 20, 2010 10:36
-
-
Save pietern/281750 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add config.include(Matchers) to your spec_helper.rb | |
# ability.should allow_to(:manage, Post) | |
# | |
module Matchers | |
class CanCanMatcher | |
def initialize(action, noun) | |
@action, @noun = action, noun | |
end | |
def matches?(ability) | |
ability.can?(@action, @noun) | |
end | |
def failure_message | |
"expected ability to allow #{@action} on #{@noun}" | |
end | |
def negative_failure_message | |
"expected ability to disallow #{@action} on #{@noun}" | |
end | |
end | |
def allow_to(*args) | |
CanCanMatcher.new(*args) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment