Merged 5.49_01 (r1339) from refactored branch to trunk
[catagits/Catalyst-Runtime.git] / t / live / engine / response / errors.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use FindBin;
7 use lib "$FindBin::Bin/../../lib";
8
9 use Test::More tests => 18;
10 use Catalyst::Test 'TestApp';
11
12 close STDERR; # i'm naughty :)
13
14 {
15     ok( my $response = request('http://localhost/engine/response/errors/one'), 'Request' );
16     ok( $response->is_error, 'Response Server Error 5xx' );
17     is( $response->code, 500, 'Response Code' );
18     is( $response->content_type, 'text/html', 'Response Content-Type' );
19     is( $response->header('X-Catalyst-Action'), 'engine/response/errors/one', 'Test Action' );
20     like( $response->header('X-Catalyst-Error'), qr/^Caught exception/, 'Catalyst Error' );
21 }
22
23 {
24     ok( my $response = request('http://localhost/engine/response/errors/two'), 'Request' );
25     ok( $response->is_error, 'Client Error 4xx' );
26     is( $response->code, 404, 'Response Code' );
27     is( $response->content_type, 'text/html', 'Response Content-Type' );
28     is( $response->header('X-Catalyst-Action'), 'engine/response/errors/two', 'Test Action' );
29     like( $response->header('X-Catalyst-Error'), qr/^Couldn't forward to/, 'Catalyst Error' );
30 }
31
32 {
33     ok( my $response = request('http://localhost/engine/response/errors/three'), 'Request' );
34     ok( $response->is_error, 'Response Server Error 5xx' );
35     is( $response->code, 500, 'Response Code' );
36     is( $response->content_type, 'text/html', 'Response Content-Type' );
37     is( $response->header('X-Catalyst-Action'), 'engine/response/errors/three', 'Test Action' );
38     like( $response->header('X-Catalyst-Error'), qr/^Caught exception "I'm going to die!"$/, 'Catalyst Error' );
39 }