How to write Pundit policy specs
11 March 2022 (Updated 23 April 2022)
On this page
Setup
Add the following to your rails_helper.rb
:
Example spec
Let’s suppose we have a QuotePolicy
that should only allow the owner/creator of a quote to edit the quote. We might write a spec at spec/policies/quote_policy_spec.rb
that looks like this:
Tagged:
Rails testing
Thanks for your comment . Once it's approved, it will appear here.
Leave a comment