~ubuntu-branches/ubuntu/wily/librouter-simple-perl/wily

« back to all changes in this revision

Viewing changes to t/09_on_match.t

  • Committer: Package Import Robot
  • Author(s): Florian Schlichting
  • Date: 2012-06-04 21:31:28 UTC
  • Revision ID: package-import@ubuntu.com-20120604213128-tmi08jxwpq0mnuh5
Tags: upstream-0.09
ImportĀ upstreamĀ versionĀ 0.09

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use strict;
 
2
use warnings;
 
3
use Router::Simple;
 
4
use Test::More;
 
5
 
 
6
my $r = Router::Simple->new()
 
7
            ->connect('/hi/:user', { action => 'hello_who' },
 
8
                      { on_match => sub { my($path, $m) = @_; return $m->{user} ne 'foo' } })
 
9
            ->connect('/hi/{user:.*}', { action => 'hi' } );
 
10
 
 
11
is_deeply(
 
12
    $r->match('/hi/miyagawa'),
 
13
    {
 
14
        action => 'hello_who',
 
15
        user   => 'miyagawa',
 
16
    }
 
17
);
 
18
 
 
19
is_deeply(
 
20
    $r->match('/hi/foo'),
 
21
    {
 
22
        action => 'hi',
 
23
        user => 'foo',
 
24
    }
 
25
);
 
26
 
 
27
done_testing;