File Coverage

File:t/route.t
Coverage:86.0%

linestmtbrancondsubpodtimecode
1#!/usr/bin/env perl -w
2
1
1
1
97
9
11
use strict;
3
1
1
1
111
4
20
use Test::More tests => 9;
4
5
1
1
1
85
5
15
use Railsish::Router;
6
7Railsish::Router->draw(
8    sub {
9
1
4
        my ($map) = @_;
10
11
1
10
        $map->connect(
12            "/dashboard/:year/:month/:date",
13            controller => "users",
14            action => "dashboard"
15        );
16
17
1
110
        $map->connect("/:controller/:action/:id");
18    }
19
1
21
);
20
21
1
18
my $uri = Railsish::Router->uri_for(
22    controller => "users",
23    action => "dashboard",
24    year => "3009",
25    month => "12",
26    date => "23"
27);
28
29
1
1518
is($uri, "dashboard/3009/12/23");
30
31{
32
1
1
4
9
    my $matched = Railsish::Router->match("/admin/show/123");
33
34
1
767
    if ($matched) {
35
1
9
        my $mapping = $matched->mapping;
36
1
23
        is $mapping->{controller}, "admin";
37
1
9
        is $mapping->{action}, "show";
38
1
8
        is $mapping->{id}, "123";
39    } else {
40
0
0
0
0
        fail "Not maching /admin/show/123" for 1..3;
41    }
42}
43
44{
45
1
1
54
9
    my $matched = Railsish::Router->match("/dashboard/1234/12/21");
46
47
1
739
    if ($matched) {
48
1
8
        my $mapping = $matched->mapping;
49
1
21
        is $mapping->{controller}, "users";
50
1
8
        is $mapping->{action}, "dashboard";
51
1
9
        is $mapping->{year}, "1234";
52
1
10
        is $mapping->{month}, "12";
53
1
9
        is $mapping->{date}, "21";
54    } else {
55
0
0
0
0
        fail "Not maching /dashboard/1234/12/21" for 1..3;
56    }
57}