Pundit: Add support for testing

Created on 5 Jan 2018  路  4Comments  路  Source: varvet/pundit

Would it be possible for us to include something like this gem?
https://github.com/ksimmons/policy-assertions

It would be fantastic if pundit came with test assertions out of the box.

Most helpful comment

:wave: user for a while of pundit. i can see how some would prefer that approach, to me though policies are pretty straight up ruby objects and adding a DSL on top of rspec/minitest would add more maintenance than benefit to the entire community. I like that there is a side gem that can do what is needed though, maybe mentioning that those exist in the readme would be enough.

All 4 comments

:wave: user for a while of pundit. i can see how some would prefer that approach, to me though policies are pretty straight up ruby objects and adding a DSL on top of rspec/minitest would add more maintenance than benefit to the entire community. I like that there is a side gem that can do what is needed though, maybe mentioning that those exist in the readme would be enough.

@Austio I agree. The gem is quite small, so I don't think maintenance would ever be an issue since as you said, policies are POROs.

I would definitely be for adding it to the readme at least!

I wrote an article about this and in there is a custom matcher for Pundit, maybe its helpful for you.

https://medium.com/@toddbaur/using-devise-and-pundit-with-rails-5-to-delegate-authorization-to-users-22f2c83d0244

I don't think we will add anything for this at the moment. Perhaps we can revisit this in the future.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabrielecirulli picture gabrielecirulli  路  4Comments

ghost picture ghost  路  5Comments

cthielen picture cthielen  路  5Comments

jdwolk picture jdwolk  路  3Comments

DannyBen picture DannyBen  路  6Comments