summary refs log tree commit diff
path: root/t/01_basic.t
blob: d03d55e17aa007fbb897a352d8326d33570fb42f (plain) (blame)
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
use strict;
use warnings;
use Test::More;
use Plack::Builder;
use Plack::Test;
use HTTP::Request::Common;

my $handler = builder {
    enable "i18n";
    sub {
        my $env = shift;
        [   '200',
            ['Content-Type' => 'text/html',],
            ['locale is ' . $env->{'psgix.locale'}]
        ];
    };
};

test_psgi
  app    => $handler,
  client => sub {
    my $cb = shift;
    {
        my $req = GET "http://localhost/";
        $req->header('Accept-Language' => 'fr-FR,de;q=0.8');
        ok my $res = $cb->($req);
        is $res->content, 'locale is fr';
    }
  };

done_testing();