Skip to content

Commit

Permalink
Fix tests to pass on 5.14.0, mac OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
ambs committed Aug 24, 2011
1 parent d5ba676 commit 72d3776
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions t/dispatcher.t
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ my @tests = (
REQUEST_METHOD => 'GET', REQUEST_METHOD => 'GET',
PATH_INFO => '/error', PATH_INFO => '/error',
}, },
expected => [500, [], [qq{Internal Server Error\n\nCan't locate object method "fail" via package "Fail" (perhaps you forgot to load "Fail"?) at t/dispatcher.t line 26.\n\n}]] expected => [500, [], qr{^Internal Server Error\n\nCan't locate object method "fail" via package "Fail" \(perhaps you forgot to load "Fail"\?\) at t/dispatcher\.t line 26.*$}s]
}, },
{ env => { { env => {
REQUEST_METHOD => 'GET', REQUEST_METHOD => 'GET',
Expand All @@ -92,7 +92,7 @@ my @tests = (


# simulates a redirect with halt # simulates a redirect with halt
$app->add_hook(Dancer::Core::Hook->new( $app->add_hook(Dancer::Core::Hook->new(
name => 'before', name => 'before',
code => sub { code => sub {
my $ctx = shift; my $ctx = shift;
if ($ctx->request->path_info eq '/haltme') { if ($ctx->request->path_info eq '/haltme') {
Expand All @@ -105,7 +105,7 @@ $app->add_hook(Dancer::Core::Hook->new(


my $was_in_second_filter = 0; my $was_in_second_filter = 0;
$app->add_hook(Dancer::Core::Hook->new( $app->add_hook(Dancer::Core::Hook->new(
name => 'before', name => 'before',
code => sub { code => sub {
my $ctx = shift; my $ctx = shift;
if ($ctx->request->path_info eq '/haltme') { if ($ctx->request->path_info eq '/haltme') {
Expand All @@ -121,15 +121,22 @@ $app->add_route(
); );
$app->compile_hooks; $app->compile_hooks;


plan tests => scalar(@tests) + 1; plan tests => scalar(@tests) * 3 + 1;


my $dispatcher = Dancer::Core::Dispatcher->new(apps => [$app]); my $dispatcher = Dancer::Core::Dispatcher->new(apps => [$app]);
foreach my $test (@tests) { foreach my $test (@tests) {
my $env = $test->{env}; my $env = $test->{env};
my $expected = $test->{expected}; my $expected = $test->{expected};


my $resp = $dispatcher->dispatch($env); my $resp = $dispatcher->dispatch($env);
is_deeply $resp, $expected;
is $resp->[0] => $expected->[0], "Return code ok.";
is_deeply $resp->[1] => $expected->[1], "Headers ok.";
if (ref($expected->[2]) eq "Regexp") {
like $resp->[2][0] => $expected->[2], "Contents ok.";
} else {
is_deeply $resp->[2] => $expected->[2], "Contents ok.";
}
} }


is $was_in_second_filter, 0, "didnt enter the second filter, because of halt"; is $was_in_second_filter, 0, "didnt enter the second filter, because of halt";

0 comments on commit 72d3776

Please sign in to comment.