5 ms·
Thank you for the link. This is inspiring. Do you have any resources you could link to that would explain some or all of the style for these tests? The general
by HumanOstrich 3y ago
Thank you for the link. This is inspiring. Do you have any resources you could link to that would explain some or all of the style for these tests? The general approach I mean.
- ezekg 3y agoHonestly, I don't have many resources to provide. I read a lot of policy tests via GitHub search (e.g. path:spec/policies/*/*.rb), but couldn't find anything that looked like what I wanted. I wrote the DSL as-needed in order to fully test my app's authz while migrating from Pundit to ActionPolicy (while also introducing fine-grained permissions). It's not the prettiest when you actually look beneath the covers [0], but it does what I wanted -- providing an easy way to write exhaustive authz tests. Without the DSL, I probably wouldn't have written the tests. The PR for said migration was massive [1], and was a prerequisite to going open source [2]. [0]: https://github.com/keygen-sh/keygen-api/blob/master/spec/support/helpers/authorization_helper.rb https://github.com/keygen-sh/keygen-api/blob/master/spec/sup... [1]: https://github.com/keygen-sh/keygen-api/pull/647 https://github.com/keygen-sh/keygen-api/pull/647 [2]: https://github.com/keygen-sh/keygen-api/issues/644 https://github.com/keygen-sh/keygen-api/issues/644
- HumanOstrich 3y agoThanks! I'll dig around in the pull request and issue as well.