Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
module PunditExampleGroup
extend ::RSpec::Matchers::DSL
matcher :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
end
RSpec.configure do |config|
config.include(PunditExampleGroup, {
:type => :policy,
:file_path => /spec\/policies/,
})
end
@daksis

This comment has been minimized.

Copy link

daksis commented Nov 29, 2014

Hey Brad - thanks for writing this up. I'll add this to my "todo" list.

@bradgessler

This comment has been minimized.

Copy link
Owner Author

bradgessler commented Dec 11, 2014

Great! Thanks for writing the original article. It was super helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.