Skip to content

Commit

Permalink
Two more
Browse files Browse the repository at this point in the history
  • Loading branch information
ambs authored and fcuny committed Jun 1, 2011
1 parent 26c507e commit 6a5d870
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
13 changes: 4 additions & 9 deletions t/03_route_handler/24_named_captures.t
Expand Up @@ -5,20 +5,15 @@ use Test::More import => ['!pass'];
use Dancer ':syntax';
use Dancer::Test;

plan tests => 3;
plan tests => 2;

SKIP: {
skip "Need perl >= 5.10", 3 unless $] >= 5.010;

my $route_regex =
"/(?<class> user | content | post )/(?<action> delete | find )/(?<id> \\d+ )";

ok( get(qr{
$route_regex
}x, sub {captures}
),
'first route set'
);
get qr{$route_regex}x => sub {captures};

for my $test (
{ path => '/user/delete/234',
Expand All @@ -30,8 +25,8 @@ SKIP: {
my $path = $test->{path};
my $expected = $test->{expected};
my $request = [GET => $path];
response_exists $request;
response_content_is_deeply $request, $expected;
response_status_is $request => 200;
response_content_is_deeply $request => $expected;
}
}

Expand Down
28 changes: 14 additions & 14 deletions t/03_route_handler/29_forward.t
Expand Up @@ -32,20 +32,20 @@ get '/go_to_post/' => sub {
return forward '/simple_post_route/', { foo => 'bar' }, { method => 'post' };
};

response_exists [ GET => '/' ];
response_content_is [ GET => '/' ], 'home:';
response_status_is [ GET => '/' ] => 200;
response_content_is [ GET => '/' ] => 'home:';

response_exists [ GET => '/bounce/' ];
response_content_is [ GET => '/bounce/' ], 'home:';
response_status_is [ GET => '/bounce/' ] => 200;
response_content_is [ GET => '/bounce/' ] => 'home:';

response_exists [ GET => '/bounce/thesethings/' ];
response_content_is [ GET => '/bounce/thesethings/' ], 'home:withparams,thesethings';
response_status_is [ GET => '/bounce/thesethings/' ] => 200;
response_content_is [ GET => '/bounce/thesethings/' ] => 'home:withparams,thesethings';

response_exists [ GET => '/bounce2/adding_params/' ];
response_content_is [ GET => '/bounce2/adding_params/' ], 'home:withparams,foo';
response_status_is [ GET => '/bounce2/adding_params/' ] => 200;
response_content_is [ GET => '/bounce2/adding_params/' ] => 'home:withparams,foo';

response_exists [ GET => '/go_to_post/' ];
response_content_is [ GET => '/go_to_post/' ], 'post:foo,bar';
response_status_is [ GET => '/go_to_post/' ] => 200;
response_content_is [ GET => '/go_to_post/' ] => 'post:foo,bar';

my $expected_headers = [
'Content-Length' => 5,
Expand All @@ -62,11 +62,11 @@ post '/bounce/' => sub {
return forward('/');
};

response_exists [ POST => '/' ];
response_content_is [ POST => '/' ], 'post-home';
response_status_is [ POST => '/' ] => 200;
response_content_is [ POST => '/' ] => 'post-home';

response_exists [ POST => '/bounce/' ];
response_content_is [ POST => '/bounce/' ], 'post-home';
response_status_is [ POST => '/bounce/' ] => 200;
response_content_is [ POST => '/bounce/' ] => 'post-home';

$expected_headers->[1] = 9;
response_headers_are_deeply [ POST => '/bounce/' ], $expected_headers;
Expand Down

0 comments on commit 6a5d870

Please sign in to comment.