Fixed index test to work around HTTP::Response bug
[catagits/Catalyst-Runtime.git] / t / live / component / controller / action / index.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 => 19;
10 use Catalyst::Test 'TestApp';
11     
12 for ( 1 .. 1 ) {
13     # test root index
14     {
15         ok( my $response = request('http://localhost/'), 'root index' );
16         is( $response->content, 'root index', 'root index ok' );
17         
18         ok( $response = request('http://localhost'), 'root index no slash' );
19         is( $response->content, 'root index', 'root index no slash ok' );
20     }
21     
22     # test first-level controller index
23     {
24         my @expected = qw[
25           TestApp::Controller::Index->index
26         ];
27     
28         my $expected = join( ", ", @expected );
29         
30         ok( my $response = request('http://localhost/index/'), 'first-level controller index' );
31         is( $response->header('X-Catalyst-Executed'),
32             $expected, 'Executed actions' );
33         is( $response->content, 'Index index', 'first-level controller index ok' );
34         
35         ok( $response = request('http://localhost/index'), 'first-level controller index no slash' );
36         is( $response->header('X-Catalyst-Executed'),
37             $expected, 'Executed actions' );
38         is( $response->content, 'Index index', 'first-level controller index no slash ok' );        
39     }    
40     
41     # test second-level controller index
42     {
43         my @expected = qw[
44           TestApp::Controller::Action::Index->begin
45           TestApp::Controller::Action::Index->index
46         ];
47     
48         my $expected = join( ", ", @expected );
49         
50         ok( my $response = request('http://localhost/action/index/'), 'second-level controller index' );
51         is( $response->header('X-Catalyst-Executed'),
52             $expected, 'Executed actions' );
53         is( $response->content, 'Action-Index index', 'second-level controller index ok' );
54         
55         ok( $response = request('http://localhost/action/index'), 'second-level controller index no slash' );
56         is( $response->header('X-Catalyst-Executed'),
57             $expected, 'Executed actions' );
58         is( $response->content, 'Action-Index index', 'second-level controller index no slash ok' );        
59     }
60     
61     # test controller default when index is present
62     {
63         my @expected = qw[
64           TestApp::Controller::Action::Index->begin
65           TestApp::Controller::Action::Index->default
66         ];
67     
68         my $expected = join( ", ", @expected );
69         
70         ok( my $response = request('http://localhost/action/index/foo'), 'default with index' );
71         is( $response->header('X-Catalyst-Executed'),
72             $expected, 'Executed actions' );
73         is( $response->content, "Error - TestApp::Controller::Action\n", 'default with index ok' );
74     }
75 }