summaryrefslogtreecommitdiff
path: root/spec/support/matchers/policy_matchers.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/matchers/policy_matchers.rb')
-rw-r--r--spec/support/matchers/policy_matchers.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/support/matchers/policy_matchers.rb b/spec/support/matchers/policy_matchers.rb
new file mode 100644
index 00000000000..020c5ce2baf
--- /dev/null
+++ b/spec/support/matchers/policy_matchers.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+RSpec::Matchers.define :allow_action do |action|
+ match do |policy|
+ expect(policy).to be_allowed(action)
+ end
+
+ failure_message do |policy|
+ policy.debug(action, debug_output = +'')
+ "expected #{policy} to allow #{action}\n\n#{debug_output}"
+ end
+
+ failure_message_when_negated do |policy|
+ policy.debug(action, debug_output = +'')
+ "expected #{policy} not to allow #{action}\n\n#{debug_output}"
+ end
+end