Catalyst-Runtime

 view release on metacpan or  search on metacpan

t/http_exceptions.t  view on Meta::CPAN

  package MyApp;
  use Catalyst;

  MyApp->config(abort_chain_on_error_fix=>1);

  sub debug { 1 }

  MyApp->setup_log('fatal');
}

$INC{'MyApp/Controller/Root.pm'} = __FILE__; # sorry...
MyApp->setup_log('error');

Test::More::ok(MyApp->setup);

ok my $psgi = MyApp->psgi_app;

test_psgi $psgi, sub {
    my $cb = shift;
    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 {
    my $cb = shift;
    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 {
    my $cb = shift;
    my $res = $cb->(GET "/root/from_code_type");
    is $res->code, 400;
    is $res->content, 'bad stringy bad', 'bad stringy bad';
    unlike $res->content, qr'HTTPExceptions', 'HTTPExceptions';
};

test_psgi $psgi, sub {
    my $cb = shift;
    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 {
    my $cb = shift;
    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';
};



# We need to specify the number of expected tests because tests that live
# in the callbacks might never get run (thus all ran tests pass but not all
# required tests run).

done_testing(17);



( run in 1.207 second using v1.01-cache-2.11-cpan-39bf76dae61 )