Authorize-Rule

 view release on metacpan or  search on metacpan

t/api/basic.t  view on Meta::CPAN

#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 4;
use Test::Fatal;
use Authorize::Rule;

like(
    exception { Authorize::Rule->new },
    qr/^You must provide rules/,
    'Cannot instantiate Authorize::Rule without rules',
);

my $auth = Authorize::Rule->new(
    rules => {
        Person => {
            Place => [
                [ 1, { name => ['error'] } ]
            ]
        }
    },
);

isa_ok( $auth, 'Authorize::Rule' );
can_ok( $auth, qw<allowed is_allowed> );

like(
    exception { $auth->allowed( 'Person', 'Place', { name => 'blah' } ) },
    qr/^Rule keys can only be strings, regexps, or code/,
    'We fail on unknown reference in key value in params',
);



( run in 1.794 second using v1.01-cache-2.11-cpan-54e63673c56 )