1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
  
     | 
    
      use strict;
use warnings;
use Test::More;
use Test::Fatal;
use Path::Dispatcher;
my $dispatcher = Path::Dispatcher->new(
    rules => [
        Path::Dispatcher::Rule::Regex->new(
            regex   => qr/^(\w+)$/,
            payload => 'all the money',
        ),
    ],
);
my $dispatch = $dispatcher->dispatch('hello');
ok($dispatch->has_matches);
my $match = $dispatch->first_match;
ok($match->rule->isa('Path::Dispatcher::Rule::Regex'));
ok($match->rule->payload, 'all the money');
ok($match->payload, 'all the money');
like(exception {
    $dispatch->run
}, qr/Payload is not a coderef/);
like(exception {
    $dispatcher->run('bye')
}, qr/Payload is not a coderef/);
done_testing;
 
     |