Sha256: 3a16aeed6579b2fd49266951a02ceb8f3e93d9663360807b6d851ddf9280f657

Contents?: true

Size: 703 Bytes

Versions: 2

Compression:

Stored size: 703 Bytes

Contents

# frozen_string_literal: true

require_relative 'utils/policy_info'

module Pundit
  module Matchers
    # This is the base class for all matchers in the Pundit Matchers library.
    class BaseMatcher
      include ::RSpec::Matchers::Composable

      # Error message when an ambiguous negated matcher is used.
      AMBIGUOUS_NEGATED_MATCHER_ERROR = <<~MSG
        `expect().not_to %<name>s` is not supported since it creates ambiguity.
      MSG

      private

      attr_reader :policy_info

      def setup_policy_info!(policy)
        @policy_info = Pundit::Matchers::Utils::PolicyInfo.new(policy)
      end

      def user_message
        " for '#{policy_info.user}'"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pundit-matchers-4.0.0 lib/pundit/matchers/base_matcher.rb
pundit-matchers-3.1.2 lib/pundit/matchers/base_matcher.rb