No commit activity in last 3 years
No release in over 3 years
Test::Unit support for Pundit
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

= 5.3.2
= 4.1.0

Runtime

>= 0.3.0
>= 3.0.0
 Project Readme

Test Unit Pundit

Adds rake test sub task.

rake test:policies

Generate test/policies directory, when running policy:install.

New generator template of policy test.

Provides some test helpers.

Installation

gem 'test_unit_pundit'

Test

Put your policy test in test/policies:

require 'test_helper'

class PostPolicyTest < Pundit::TestCase
  test "update? should deny access if post is published" do
    assert_forbidden User.new(admin: false), Post.new(published: true), :update?
  end

  test "update? should grant access if post is published and user is an admin" do
    assert_permitted User.new(admin: true), Post.new(published: true), :update?
  end

  test "update? should grant access if post is unpublished" do
    assert_permitted User.new(admin: false), Post.new(published: false), :update?
  end
end

Note: test:policies can't run until original test tasks don't have error or failture, when running rake test. Now you should run rake test:policies to test policies.