- Fixed CAT_BENCH_ITERS :)
[catagits/Catalyst-Runtime.git] / t / live / component / controller / action / path.t
CommitLineData
dd4e6fd2 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
9770ad56 7use lib "$FindBin::Bin/../../../lib";
dd4e6fd2 8
232fd394 9our $iters;
10
11BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
12
13use Test::More tests => 12*$iters;
dd4e6fd2 14use Catalyst::Test 'TestApp';
15
232fd394 16if ( $ENV{CAT_BENCHMARK} ) {
17 require Benchmark;
5a6c7ff6 18 Benchmark::timethis( $iters, \&run_tests );
232fd394 19}
20else {
21 for ( 1 .. $iters ) {
22 run_tests();
23 }
24}
25
26sub run_tests {
d8c66af5 27 {
28 ok(
29 my $response =
30 request('http://localhost/action/path/a path with spaces'),
31 'Request'
32 );
33 ok( $response->is_success, 'Response Successful 2xx' );
34 is( $response->content_type, 'text/plain', 'Response Content-Type' );
35 is(
36 $response->header('X-Catalyst-Action'),
37 'action/path/a path with spaces',
38 'Test Action'
39 );
40 is(
41 $response->header('X-Test-Class'),
42 'TestApp::Controller::Action::Path',
43 'Test Class'
44 );
45 like(
46 $response->content,
47 qr/^bless\( .* 'Catalyst::Request' \)$/s,
48 'Content is a serialized Catalyst::Request'
49 );
50 }
dd4e6fd2 51
d8c66af5 52 {
53 ok( my $response = request('http://localhost/action/path/åäö'),
54 'Request' );
55 ok( $response->is_success, 'Response Successful 2xx' );
56 is( $response->content_type, 'text/plain', 'Response Content-Type' );
57 is( $response->header('X-Catalyst-Action'),
58 'action/path/åäö', 'Test Action' );
59 is(
60 $response->header('X-Test-Class'),
61 'TestApp::Controller::Action::Path',
62 'Test Class'
63 );
64 like(
65 $response->content,
66 qr/^bless\( .* 'Catalyst::Request' \)$/s,
67 'Content is a serialized Catalyst::Request'
68 );
69 }
dd4e6fd2 70}