class Pundit::Matchers::ForbidAllActionsMatcher

This matcher tests whether a policy forbids all actions.

Public Instance Methods

description() click to toggle source

A description of the matcher.

@return [String] Description of the matcher.

# File lib/pundit/matchers/forbid_all_actions_matcher.rb, line 12
def description
  'forbid all actions'
end
does_not_match?(_policy) click to toggle source

Raises a NotImplementedError @raise NotImplementedError @return [void]

# 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() click to toggle source

Returns a failure message if the matcher fails.

@return [String] Failure message.

# File lib/pundit/matchers/forbid_all_actions_matcher.rb, line 36
def failure_message
  message = +"expected '#{policy_info}' to forbid all actions,"
  message << " but permitted #{policy_info.permitted_actions}"
  message << user_message
end
matches?(policy) click to toggle source

Checks if the given policy forbids all actions.

@param policy [Object] The policy to test. @return [Boolean] True if the policy forbids all actions, false otherwise.

# File lib/pundit/matchers/forbid_all_actions_matcher.rb, line 20
def matches?(policy)
  setup_policy_info! policy

  policy_info.permitted_actions.empty?
end