lib/pundit/matchers.rb in pundit-matchers-3.0.0.beta3 vs lib/pundit/matchers.rb in pundit-matchers-3.0.0.beta4
- old
+ new
@@ -64,14 +64,14 @@
end
end
# Creates a matcher that tests if the policy permits a given action.
#
- # @param [Symbol] action the action to be tested.
+ # @param [String|Symbol] action the action to be tested.
# @return [PermitActionsMatcher] the matcher object.
def permit_action(action)
- PermitActionsMatcher.new(action)
+ PermitActionsMatcher.new(action).ensure_single_action!
end
# @!macro [attach] RSpec::Matchers.define_negated_matcher
# @!method $1
#
@@ -80,11 +80,11 @@
# Same as +expect(policy).not_to $2(*args)+.
RSpec::Matchers.define_negated_matcher :forbid_action, :permit_action, &NEGATED_DESCRIPTION
# Creates a matcher that tests if the policy permits a set of actions.
#
- # @param [Array<Symbol>] actions the actions to be tested.
+ # @param [Array<String, Symbol>] actions the actions to be tested.
# @return [PermitActionsMatcher] the matcher object.
def permit_actions(*actions)
PermitActionsMatcher.new(*actions)
end
@@ -133,29 +133,29 @@
# Creates a matcher that tests if the policy permits only a set of actions.
#
# @note The negative form +not_to permit_only_actions+ is not supported
# since it creates ambiguity. Instead use +to forbid_only_actions+.
#
- # @param [Array<Symbol>] actions the actions to be tested.
+ # @param [Array<String, Symbol>] actions the actions to be tested.
# @return [PermitOnlyActionsMatcher] the matcher object.
def permit_only_actions(*actions)
PermitOnlyActionsMatcher.new(*actions)
end
# Creates a matcher that tests if the policy forbids only a set of actions.
#
# @note The negative form +not_to forbid_only_actions+ is not supported
# since it creates ambiguity. Instead use +to permit_only_actions+.
#
- # @param [Array<Symbol>] actions the actions to be tested.
+ # @param [Array<String, Symbol>] actions the actions to be tested.
# @return [ForbidOnlyActionsMatcher] the matcher object.
def forbid_only_actions(*actions)
ForbidOnlyActionsMatcher.new(*actions)
end
# Creates a matcher that tests if the policy permits mass assignment of a set of attributes.
#
- # @param [Array<Symbol>] attributes the attributes to be tested.
+ # @param [Array<String, Symbol, Hash>] attributes the attributes to be tested.
# @return [PermitAttributesMatcher] the matcher object.
def permit_mass_assignment_of(*attributes)
PermitAttributesMatcher.new(*attributes)
end