Created
March 11, 2014 14:56
-
-
Save ericchernuka/9487484 to your computer and use it in GitHub Desktop.
Pundit Matchers for Rspec 3.0
This file contains hidden or 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
RSpec::Matchers.define :permit do |action| | |
match do |policy| | |
policy.public_send("#{action}?") | |
end | |
failure_message do |policy| | |
"#{policy.class} does not permit #{action} on #{policy.record} for #{policy.user.inspect}." | |
end | |
failure_message_when_negated do |policy| | |
"#{policy.class} does not forbid #{action} on #{policy.record} for #{policy.user.inspect}." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment