Sekisho.Test (Sekisho v0.1.0-dev)

Copy Markdown View Source

Assertions for your tests, whose failures say why (explain/3):

use Sekisho.Test, permissions: MyApp.Permissions

assert_allowed scope, :update, post
refute_allowed scope, :delete, post
assert_where_allowed Post, scope, :read, [published, mine]

and a test that your policies are valid together:

test "the permissions are valid" do
  assert MyApp.Permissions.validate!() == :ok
end

Summary

Functions

Asserts the scope has the permission on the resource.

Asserts where_allowed/3 gives exactly these records, in any order.

Asserts the scope does not have the permission on the resource.

Functions

assert_allowed(scope, permission, resource)

(macro)

Asserts the scope has the permission on the resource.

assert_where_allowed(queryable, scope, permission, records)

(macro)

Asserts where_allowed/3 gives exactly these records, in any order.

refute_allowed(scope, permission, resource)

(macro)

Asserts the scope does not have the permission on the resource.