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