Added recursive -r flag to prove example
[catagits/Catalyst-Runtime.git] / t / engine / response / cookies.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 => 10;
10 use Catalyst::Test 'TestApp';
11
12 use HTTP::Headers::Util 'split_header_words';
13
14
15 my $expected = { 
16     Catalyst => [ qw( Catalyst Cool path / ) ],
17     Cool     => [ qw( Cool Catalyst path / ) ]
18 };
19
20 {
21     ok( my $response = request('http://localhost/engine/response/cookies/one'), 'Request' );
22     ok( $response->is_success, 'Response Successful 2xx' );
23     is( $response->content_type, 'text/plain', 'Response Content-Type' );
24     is( $response->header('X-Catalyst-Action'), 'engine/response/cookies/one', 'Test Action' );
25
26     my $cookies = {};
27
28     for my $cookie ( split_header_words( $response->header('Set-Cookie') ) ) {
29         $cookies->{ $cookie->[0] } = $cookie;
30     }
31
32     is_deeply( $cookies, $expected, 'Response Cookies' );
33 }
34
35 {
36     ok( my $response = request('http://localhost/engine/response/cookies/two'), 'Request' );
37     ok( $response->is_redirect, 'Response Redirection 3xx' );
38     is( $response->code, 302, 'Response Code' );
39     is( $response->header('X-Catalyst-Action'), 'engine/response/cookies/two', 'Test Action' );
40
41     my $cookies = {};
42
43     for my $cookie ( split_header_words( $response->header('Set-Cookie') ) ) {
44         $cookies->{ $cookie->[0] } = $cookie;
45     }
46
47     is_deeply( $cookies, $expected, 'Response Cookies' );
48 }