File: | t/route-restful.t |
Coverage: | 100.0% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | #!/usr/bin/env perl -w | ||||||
2 | 1 1 1 | 103 10 11 | use strict; | ||||
3 | 1 1 1 | 110 6 18 | use Test::More tests => 15; | ||||
4 | |||||||
5 | 1 1 1 | 86 5 15 | use Railsish::Router; | ||||
6 | |||||||
7 | Railsish::Router->draw( | ||||||
8 | sub { | ||||||
9 | 1 | 6 | my ($map) = @_; | ||||
10 | 1 | 9 | $map->resources("photos"); | ||||
11 | } | ||||||
12 | 1 | 23 | ); | ||||
13 | |||||||
14 | 1 | 43 | my $m; | ||||
15 | |||||||
16 | 1 | 12 | $m = Railsish::Router->match("/photos/3")->mapping; | ||||
17 | 1 | 4 | is($m->{controller}, "photos"); | ||||
18 | 1 | 8 | is($m->{action}, "show"); | ||||
19 | 1 | 9 | is($m->{id}, 3); | ||||
20 | |||||||
21 | 1 | 11 | $m = Railsish::Router->match("/photos")->mapping; | ||||
22 | 1 | 4 | is($m->{controller}, "photos"); | ||||
23 | 1 | 9 | is($m->{action}, "index"); | ||||
24 | 1 | 12 | is($m->{id}, undef); | ||||
25 | |||||||
26 | 1 | 10 | $m = Railsish::Router->match("/photos/3/edit")->mapping; | ||||
27 | 1 | 3 | is($m->{controller}, "photos"); | ||||
28 | 1 | 9 | is($m->{action}, "edit"); | ||||
29 | 1 | 9 | is($m->{id}, 3); | ||||
30 | |||||||
31 | 1 | 10 | is(Railsish::Router->photos_path, "/photos"); | ||||
32 | 1 | 12 | is(Railsish::Router->photo_path( id => 3 ), "/photos/3"); | ||||
33 | 1 | 12 | is(Railsish::Router->edit_photo_path( id => 3 ), "/photos/3/edit"); | ||||
34 | |||||||
35 | |||||||
36 | 1 | 12 | $m = Railsish::Router->match("/photos/new")->mapping; | ||||
37 | 1 | 3 | is($m->{controller}, "photos"); | ||||
38 | 1 | 8 | is($m->{action}, "new"); | ||||
39 | 1 | 9 | is(Railsish::Router->new_photo_path, "/photos/new"); | ||||
40 | |||||||
41 |