summaryrefslogtreecommitdiff
path: root/t/cookie.t
blob: d88bd62f31bec09b8f6a1e64dee79617539c1acb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env perl

use strict;
use warnings;

use Test::More;
use Plack::Test::Agent;
use HTTP::Cookies;

my $app = sub
{
    return
    [
        200,
        [
            'Content-Type' => 'text/html',
            'Set-Cookie'   => "ID=123; path=/"
        ],
        [ "Hi" ]
    ];
};

my $agent = Plack::Test::Agent->new( app => $app );
my $res   = $agent->get( '/' );

my $cookie_jar = HTTP::Cookies->new;
$cookie_jar->extract_cookies($res);

my @cookies;
$cookie_jar->scan( sub { @cookies = @_ });

ok @cookies;
is $cookies[1], 'ID';

done_testing;