Class: Pundit::Matchers::ForbidAllActionsMatcher
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- Pundit::Matchers::ForbidAllActionsMatcher
- Defined in:
- lib/pundit/matchers/forbid_all_actions_matcher.rb
Overview
This matcher tests whether a policy forbids all actions.
Constant Summary
Constants inherited from BaseMatcher
BaseMatcher::AMBIGUOUS_NEGATED_MATCHER_ERROR
Instance Method Summary collapse
-
#description ⇒ String
A description of the matcher.
-
#does_not_match?(_policy) ⇒ void
Raises a NotImplementedError.
-
#failure_message ⇒ String
Returns a failure message if the matcher fails.
-
#matches?(policy) ⇒ Boolean
Checks if the given policy forbids all actions.
Instance Method Details
#description ⇒ String
A description of the matcher.
12 13 14 |
# File 'lib/pundit/matchers/forbid_all_actions_matcher.rb', line 12 def description 'forbid all actions' end |
#does_not_match?(_policy) ⇒ void
This method returns an undefined value.
Raises a NotImplementedError
29 30 31 |
# File 'lib/pundit/matchers/forbid_all_actions_matcher.rb', line 29 def does_not_match?(_policy) raise NotImplementedError, format(AMBIGUOUS_NEGATED_MATCHER_ERROR, name: 'forbid_all_actions') end |
#failure_message ⇒ String
Returns a failure message if the matcher fails.
36 37 38 39 40 |
# File 'lib/pundit/matchers/forbid_all_actions_matcher.rb', line 36 def = "expected '#{policy_info}' to forbid all actions," << " but permitted #{policy_info.permitted_actions}" << end |
#matches?(policy) ⇒ Boolean
Checks if the given policy forbids all actions.
20 21 22 23 24 |
# File 'lib/pundit/matchers/forbid_all_actions_matcher.rb', line 20 def matches?(policy) setup_policy_info! policy policy_info.permitted_actions.empty? end |