Created
October 11, 2012 08:55
-
-
Save ktat/3871091 to your computer and use it in GitHub Desktop.
Router Simple regexp with parentheses test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/t/01_simple.t b/t/01_simple.t | |
index 1c6e110..2fd5dd7 100644 | |
--- a/t/01_simple.t | |
+++ b/t/01_simple.t | |
@@ -7,6 +7,7 @@ my $r = Router::Simple->new(); | |
$r->connect('home', '/' => {controller => 'Root', action => 'show'}, {method => 'GET', host => 'localhost'}); | |
$r->connect('blog_monthly', '/blog/{year}/{month}', {controller => 'Blog', action => 'monthly'}, {method => 'GET'}); | |
$r->connect('/blog/{year:\d{1,4}}/{month:\d{2}}/{day:\d\d}', {controller => 'Blog', action => 'daily'}, {method => 'GET'}); | |
+$r->connect('/regexp/{year:(\d{1,4})}/{month:(\d{2})}/{day:(\d\d)}', {controller => 'Blog', action => 'daily'}, {method => 'GET'}); | |
$r->connect('/comment', {controller => 'Comment', 'action' => 'create'}, {method => 'POST'}); | |
$r->connect('/', {controller => 'Root', 'action' => 'show_sub'}, {method => 'GET', host => 'sub.localhost'}); | |
$r->connect(qr{^/belongs/([a-z]+)/([a-z]+)$}, {controller => 'May', action => 'show'}); | |
@@ -51,6 +52,15 @@ is_deeply( | |
undef | |
); | |
is_deeply( | |
+ $r->match( +{ PATH_INFO => '/regexp/2010/03/04', HTTP_HOST => 'localhost', REQUEST_METHOD => 'GET' } ) || undef, | |
+ { | |
+ controller => 'Blog', | |
+ action => 'daily', | |
+ year => 2010, month => '03', day => '04', | |
+ }, | |
+ 'daily' | |
+); | |
+is_deeply( | |
$r->match( +{ PATH_INFO => '/comment', HTTP_HOST => 'localhost', REQUEST_METHOD => 'POST' } ) || undef, | |
{ | |
controller => 'Comment', |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok 1
ok 2 - empty PATH_INFO is same as "/"
ok 3 - blog monthly
ok 4 - daily
ok 5
not ok 6 - daily
Failed test 'daily'
at t/01_simple.t line 54.
Structures begin differing at:
$got->{month} = '2010'
$expected->{month} = '03'
ok 7
ok 8
ok 9
ok 10
1..10
Looks like you failed 1 test of 10.