X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fhttp_exceptions.t;h=5cb31175e0d63b69c127d2baef6007cf1612d5aa;hb=be7d405452053e8df328d5c97ccd63ba4b21683e;hp=c8fae7cf2a25e788bc140dc74ce376d970731301;hpb=660f9bb0ce5e5ccb7d126608cf8b908194167b59;p=catagits%2FCatalyst-Runtime.git diff --git a/t/http_exceptions.t b/t/http_exceptions.t index c8fae7c..5cb3117 100644 --- a/t/http_exceptions.t +++ b/t/http_exceptions.t @@ -12,6 +12,10 @@ use Plack::Test; { package MyApp::Exception; + use overload + # Use the overloading thet HTTP::Exception uses + bool => sub { 1 }, '""' => 'as_string', fallback => 1; + sub new { my ($class, $code, $headers, $body) = @_; return bless +{res => [$code, $headers, $body]}, $class; @@ -30,6 +34,8 @@ use Plack::Test; $responder->([$code, $headers, $body]); }; } + + sub as_string { 'bad stringy bad' } package MyApp::Controller::Root; @@ -64,15 +70,19 @@ use Plack::Test; die "I'm not dead yet"; } + sub end :Private { die "We should never hit end for HTTPExceptions" } + package MyApp; use Catalyst; + MyApp->config(abort_chain_on_error_fix=>1); + sub debug { 1 } MyApp->setup_log('fatal'); } -$INC{'MyApp/Controller/Root.pm'} = '1'; # sorry... +$INC{'MyApp/Controller/Root.pm'} = __FILE__; # sorry... MyApp->setup_log('error'); Test::More::ok(MyApp->setup); @@ -84,6 +94,7 @@ test_psgi $psgi, sub { my $res = $cb->(GET "/root/from_psgi_app"); is $res->code, 404; is $res->content, 'Not Found', 'NOT FOUND'; + unlike $res->content, qr'HTTPExceptions', 'HTTPExceptions'; }; test_psgi $psgi, sub { @@ -91,6 +102,7 @@ test_psgi $psgi, sub { my $res = $cb->(GET "/root/from_catalyst"); is $res->code, 403; is $res->content, 'Forbidden', 'Forbidden'; + unlike $res->content, qr'HTTPExceptions', 'HTTPExceptions'; }; test_psgi $psgi, sub { @@ -98,6 +110,7 @@ test_psgi $psgi, sub { my $res = $cb->(GET "/root/classic_error"); is $res->code, 500; like $res->content, qr'Ex Parrot', 'Ex Parrot'; + like $res->content, qr'HTTPExceptions', 'HTTPExceptions'; }; test_psgi $psgi, sub { @@ -105,6 +118,7 @@ test_psgi $psgi, sub { my $res = $cb->(GET "/root/just_die"); is $res->code, 500; like $res->content, qr'not dead yet', 'not dead yet'; + like $res->content, qr'HTTPExceptions', 'HTTPExceptions'; }; @@ -113,5 +127,5 @@ test_psgi $psgi, sub { # in the callbacks might never get run (thus all ran tests pass but not all # required tests run). -done_testing(10); +done_testing(14);