Skip to content

Commit

Permalink
a few more pattern tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 18, 2016
1 parent d5cf353 commit fa61c14
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions t/mojolicious/routes.t
Expand Up @@ -216,6 +216,11 @@ my $similar = $r->route('/similar')->via(qw(DELETE GET PATCH))->inline(1);
$similar->route('/:something')->via('GET')->to('similar#get');
$similar->route('/too')->via('PATCH')->to('similar#post');

# /custom_pattern/test_*_test
my $custom = $r->get->to('custom#pattern');
$custom->pattern->quote_start('{')->quote_end('}')->placeholder_start('.');
$custom->parse('/custom_pattern/test_{.custom}_test');

# Cached lookup
my $fast = $r->route('/fast');
is $r->find('fast'), $fast, 'fast route found';
Expand Down Expand Up @@ -938,4 +943,12 @@ $m = Mojolicious::Routes::Match->new(root => $r);
$m->find($c => {method => 'DELETE', path => '/similar/too'});
is_deeply $m->stack, [], 'empty stack';

# Custom pattern
$m = Mojolicious::Routes::Match->new(root => $r);
$m->find($c => {method => 'GET', path => '/custom_pattern/test_123_test'});
is_deeply $m->stack,
[{controller => 'custom', action => 'pattern', 'custom' => 123}],
'right structure';
is $m->path_for->{path}, '/custom_pattern/test_123_test', 'right path';

done_testing();

0 comments on commit fa61c14

Please sign in to comment.