Catalyst-Runtime

 view release on metacpan or  search on metacpan

t/http_exceptions_backcompat.t  view on Meta::CPAN

  sub just_die :Local {
    my ($self, $c) = @_;
    die "I'm not dead yet";
  }

  package MyApp;
  use Catalyst;

  MyApp->config(
      abort_chain_on_error_fix=>1,
      always_catch_http_exceptions=>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, 500;
    like $res->content, qr/MyApp::Exception=HASH/;
};

test_psgi $psgi, sub {
    my $cb = shift;
    my $res = $cb->(GET "/root/from_catalyst");
    is $res->code, 500;
    like $res->content, qr/MyApp::Exception=HASH/;
};

test_psgi $psgi, sub {
    my $cb = shift;
    my $res = $cb->(GET "/root/from_code_type");
    is $res->code, 500;
    like $res->content, qr/MyApp::AnotherException=HASH/;
};

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';
};

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';
};

# 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(12);



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