Added a failing test for args passed to default
[catagits/Catalyst-Runtime.git] / t / live / component / controller / action / default.t
CommitLineData
dd4e6fd2 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
9770ad56 7use lib "$FindBin::Bin/../../../lib";
dd4e6fd2 8
746380d1 9use Test::More tests => 120;
dd4e6fd2 10use Catalyst::Test 'TestApp';
11
d8c66af5 12for ( 1 .. 10 ) {
13 {
14 my @expected = qw[
15 TestApp::Controller::Action::Default->begin
16 TestApp::Controller::Action::Default->default
17 TestApp::View::Dump::Request->process
18 ];
19
20 my $expected = join( ", ", @expected );
21
22 ok( my $response = request('http://localhost/action/default'),
23 'Request' );
24 ok( $response->is_success, 'Response Successful 2xx' );
25 is( $response->content_type, 'text/plain', 'Response Content-Type' );
26 is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
27 is(
28 $response->header('X-Test-Class'),
29 'TestApp::Controller::Action::Default',
30 'Test Class'
31 );
32 is( $response->header('X-Catalyst-Executed'),
33 $expected, 'Executed actions' );
34 like(
35 $response->content,
36 qr/^bless\( .* 'Catalyst::Request' \)$/s,
37 'Content is a serialized Catalyst::Request'
38 );
39
40 ok( $response = request('http://localhost/foo/bar/action'), 'Request' );
41 is( $response->code, 404, 'Invalid URI returned 404' );
42 }
746380d1 43
44 # test that args are passed properly to default
45 {
46 my $creq;
47 my $expected = [ qw/action default arg1 arg2/ ];
48
49 ok( my $response = request('http://localhost/action/default/arg1/arg2'), 'Request' );
50 ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
51 is_deeply( $creq->{arguments}, $expected, 'Arguments ok' );
52 }
dd4e6fd2 53}