File: | t/route-named.t |
Coverage: | 100.0% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | #!/usr/bin/env perl -w | ||||||
2 | 1 1 1 | 101 10 11 | use strict; | ||||
3 | 1 1 1 | 111 5 18 | use Test::More tests => 7; | ||||
4 | |||||||
5 | 1 1 1 | 88 5 15 | use Railsish::Router; | ||||
6 | 1 1 1 | 10 3 14 | use Railsish::PathHelpers; | ||||
7 | |||||||
8 | Railsish::Router->draw( | ||||||
9 | sub { | ||||||
10 | 1 | 5 | my ($map) = @_; | ||||
11 | |||||||
12 | 1 | 24 | $map->login("/login", controller => "login"); | ||||
13 | 1 | 20 | $map->user("/users/:id", controller => "users", action => "show"); | ||||
14 | } | ||||||
15 | 1 | 23 | ); | ||||
16 | |||||||
17 | 1 | 15 | is(Railsish::Router->login_path, "/login", "urlish with variables"); | ||||
18 | 1 | 12 | is(Railsish::Router->user_path(id => 3), "/users/3", "urlish with variables"); | ||||
19 | 1 | 15 | is(Railsish::Router->uri_for(controller => "users", action => "show", id => 3), "/users/3", "retrivie the uri with using names"); | ||||
20 | |||||||
21 | 1 | 14 | Railsish::PathHelpers->install_helpers(__PACKAGE__); | ||||
22 | |||||||
23 | 1 | 8 | is(login_path(), "/login", "as helper"); | ||||
24 | 1 | 12 | is(user_path(id => 3), "/users/3", "as helper"); | ||||
25 | |||||||
26 | 1 | 13 | my $helpers = Railsish::PathHelpers->hash_for_helpers; | ||||
27 | 1 | 8 | is( ref($helpers->{login_path}), "CODE", 'retrieved helpers as a hash' ); | ||||
28 | 1 | 10 | is( ref($helpers->{user_path}), "CODE", 'retrieved heplers as a hash' ); | ||||
29 | |||||||
30 |