Sha256: fa5bbf279d1ceadc07f6760a44cd2cbc8a1bb4eb09f181a3e4450d169aa9c39e
Contents?: true
Size: 1.03 KB
Versions: 9
Compression:
Stored size: 1.03 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, example_group: { file_path: %r{spec/policies} } ) end
Version data entries
9 entries across 9 versions & 1 rubygems