Skip to content

Commit

Permalink
a few more format detection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 15, 2012
1 parent 0236a59 commit e9061b9
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion t/mojolicious/routes.t
@@ -1,6 +1,6 @@
use Mojo::Base -strict;

use Test::More tests => 435;
use Test::More tests => 447;

# "They're not very heavy, but you don't hear me not complaining."
use Mojolicious::Routes;
Expand Down Expand Up @@ -539,12 +539,23 @@ is $m->stack->[0]{action}, 'hello', 'right value';
is $m->stack->[0]{format}, undef, 'no value';
is $m->path_for, '/format2.html/hello', 'right path';
is @{$m->stack}, 1, 'right number of elements';
$m =
Mojolicious::Routes::Match->new(GET => '/format2.html/hello.txt')
->match($r);
is $m->stack->[0]{controller}, 'you', 'right value';
is $m->stack->[0]{action}, 'hello', 'right value';
is $m->stack->[0]{format}, 'txt', 'no value';
is $m->path_for, '/format2.html/hello', 'right path';
is @{$m->stack}, 1, 'right number of elements';
$m = Mojolicious::Routes::Match->new(GET => '/format2.json/hello')->match($r);
is $m->stack->[0]{controller}, 'you', 'right value';
is $m->stack->[0]{action}, 'hello_json', 'right value';
is $m->stack->[0]{format}, undef, 'no value';
is $m->path_for, '/format2.json/hello', 'right path';
is @{$m->stack}, 1, 'right number of elements';
$m =
Mojolicious::Routes::Match->new(GET => '/format2.html.ep/hello')->match($r);
is $m->stack->[0], undef, 'no value';

# Hardcoded format after placeholder in nested route
$m =
Expand All @@ -555,6 +566,15 @@ is $m->stack->[0]{format}, undef, 'no value';
is $m->stack->[0]{foo}, 'baz', 'right value';
is $m->path_for, '/format3/baz.html/bye', 'right path';
is @{$m->stack}, 1, 'right number of elements';
$m =
Mojolicious::Routes::Match->new(GET => '/format3/baz.html/bye.txt')
->match($r);
is $m->stack->[0]{controller}, 'me', 'right value';
is $m->stack->[0]{action}, 'bye', 'right value';
is $m->stack->[0]{format}, 'txt', 'no value';
is $m->stack->[0]{foo}, 'baz', 'right value';
is $m->path_for, '/format3/baz.html/bye', 'right path';
is @{$m->stack}, 1, 'right number of elements';
$m =
Mojolicious::Routes::Match->new(GET => '/format3/baz.json/bye')->match($r);
is $m->stack->[0]{controller}, 'me', 'right value';
Expand Down

0 comments on commit e9061b9

Please sign in to comment.