Skip to content

Commit

Permalink
added 2 tests for errors in hook
Browse files Browse the repository at this point in the history
  • Loading branch information
dams authored and ambs committed Jun 28, 2011
1 parent 6d4a99a commit 9ac895a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
25 changes: 25 additions & 0 deletions t/22_hooks/10_error_in_hook.t
@@ -0,0 +1,25 @@
use strict;
use warnings;

use Test::More tests => 7, import => ['!pass'];
use Dancer ':syntax';
use Dancer::Test;
use Time::HiRes qw/gettimeofday tv_interval/;

my ($t0, $elapsed);

ok(
before_template sub {
die "plop";
}
);

setting views => path( 't', '22_hooks', 'views' );

get '/' => sub {
template 'index', { foo => 'baz' };
};

route_exists [ GET => '/' ];
response_content_like( [ GET => '/' ], qr/Unable to process your query/ );
response_status_is( [ GET => '/' ], 500 => "We get a 500 status" );
24 changes: 24 additions & 0 deletions t/22_hooks/11_error_in_hook.t
@@ -0,0 +1,24 @@
use strict;
use warnings;

use Test::More tests => 7, import => ['!pass'];
use Dancer ':syntax';
use Dancer::Test;
use Time::HiRes qw/gettimeofday tv_interval/;

ok(
before_template sub {
status 500;
halt({error => "This is some error"});
}
);

setting views => path( 't', '22_hooks', 'views' );

get '/' => sub {
template 'index', { foo => 'baz' };
};

route_exists [ GET => '/' ];
response_content_like( [ GET => '/' ], qr/Unable to process your query/ );
response_status_is( [ GET => '/' ], 500 => "We get a 500 status" );

0 comments on commit 9ac895a

Please sign in to comment.