Sha256: 928fdb75616fc7d9e95d9755211b19dd7e03fa35545126406cd7a759247384b3
Contents?: true
Size: 1.01 KB
Versions: 29
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module ActionPolicy module RSpec # Adds Pundit-style syntax for testing policies module PunditSyntax # :nodoc: all module Matchers extend ::RSpec::Matchers::DSL matcher :permit do |user, record| match do |policy| permissions.all? do |permission| policy.new(record, user: user).apply(permission) end end end end module DSL def permissions(*list, &block) describe list.to_sentence do let(:permissions) { list } instance_eval(&block) end end end module PolicyExampleGroup include Matchers def self.included(base) base.metadata[:type] = :policy base.extend DSL super end end end end end RSpec.configure do |config| config.include( ActionPolicy::RSpec::PunditSyntax::PolicyExampleGroup, type: :policy, file_path: %r{spec/policies} ) end
Version data entries
29 entries across 29 versions & 1 rubygems