new test suit
[catagits/Catalyst-Runtime.git] / t / 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 no_plan => 1;
10 use Catalyst::Test 'TestApp';
11
12 {
13     ok( my $response = request('http://localhost/engine/response/errors/one'), 'Request' );
14     ok( $response->is_error, 'Response Server Error 5xx' );
15     is( $response->code, 500, 'Response Code' );
16     is( $response->content_type, 'text/html', 'Response Content-Type' );
17     is( $response->header('X-Catalyst-Action'), 'engine/response/errors/one', 'Test Action' );
18     like( $response->header('X-Catalyst-Error'), qr/^Caught exception/, 'Catalyst Error' );
19 }
20
21 {
22     ok( my $response = request('http://localhost/engine/response/errors/two'), 'Request' );
23     ok( $response->is_error, 'Client Error 4xx' );
24     is( $response->code, 404, 'Response Code' );
25     is( $response->content_type, 'text/html', 'Response Content-Type' );
26     is( $response->header('X-Catalyst-Action'), 'engine/response/errors/two', 'Test Action' );
27     like( $response->header('X-Catalyst-Error'), qr/^Unknown resource/, 'Catalyst Error' );
28 }
29
30 {
31     ok( my $response = request('http://localhost/engine/response/errors/three'), 'Request' );
32     ok( $response->is_error, 'Response Server Error 5xx' );
33     is( $response->code, 500, 'Response Code' );
34     is( $response->content_type, 'text/html', 'Response Content-Type' );
35     is( $response->header('X-Catalyst-Action'), 'engine/response/errors/three', 'Test Action' );
36     like( $response->header('X-Catalyst-Error'), qr/^Caught exception "I'm going to die!"$/, 'Catalyst Error' );
37 }