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