Sha256: 9268c8d8c2d5406cde2d6115f7089d2b7704277de1f81e72a8cf7ccd1d86ea17
Contents?: true
Size: 1.31 KB
Versions: 4
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true module Pundit module Matchers module Utils module AllActions # Adds #message method which generates failed assertion message # for *_all_actions matchers. # # Expects methods to be defined: # * matcher - instance which has `AllActions::ActionsMatcher` as a parent class # * expected_kind - string with expected actions type (can be "forbidden" or "permitted") # * opposite_kind - string with oposite then expected actions type (can be "permitted" or "forbidden") module ErrorMessageFormatter def message "#{policy_name} expected to have all actions #{expected_kind}, " \ "but #{mismatches_are(missed_expected_actions)} #{opposite_kind}" end private attr_reader :matcher, :expected_kind, :opposite_kind def policy matcher.policy end def missed_expected_actions matcher.missed_expected_actions end def policy_name policy.class.name end def mismatches_are(mismatches) if mismatches.count == 1 "#{mismatches} is" else "#{mismatches} are" end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems