pundit-matchers icon indicating copy to clipboard operation
pundit-matchers copied to clipboard

Exceptions in policy creation

Open mkamensky opened this issue 7 years ago • 1 comments

Hi,

I followed the advice in the pundit docs regarding closed systems, i.e., raising an exception when initializing the policy class. With this, a forbid_actions test fails, but I think it should pass. I currently use is_expected.to raise_error, but could be nicer if I didn't have to worry how exactly the action was forbidden

Thanks!

mkamensky avatar Nov 04 '17 08:11 mkamensky

Yes I agree that Pundit Matchers should support exceptions in policies. We will need to prepare a PR to include support for failure by exception in the matchers. The permit matchers, along with forbid matchers, should have tests for this feature.

chrisalley avatar Nov 26 '17 07:11 chrisalley

The solution proposed in https://github.com/punditcommunity/pundit-matchers/issues/39#issuecomment-1352644741 is to add support for multiple ways of failing, with "any" being the default. This would be a breaking change, requiring a major version bump. I'll close this issue and we can move further discussion to #39.

chrisalley avatar Apr 14 '23 12:04 chrisalley