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 | package t::Util; use strict; use warnings; use lib qw( ./local/perl5 ); use Plack::Test qw(test_psgi); use Plack::Util (); use File::Spec (); use Exporter 'import'; our @EXPORT = qw/apptest/; my $psgi_file = File::Spec->catfile('script', 'app.psgi'); my $app = Plack::Util::load_psgi($psgi_file); sub apptest { my ($req, $test_code) = @_; test_psgi $app, sub { my $cb = shift; my $res = $cb->($req); $test_code->($res); }; } 1; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #!perl -w use strict; use Test::More; use t::Util; use HTTP::Request::Common; subtest 'GET /' => sub { my $req = GET '/'; apptest $req, sub { my $res = shift; is $res->code, 200; }; }; done_testing; |
Authorization加えたいとかopensocial_viewer_id加えたいとかはt::Util#apptest変えればオッケーすね。

hisaichi5518がPerlを書いて、つついて、イチャイチャするブログ。最近はnode.jsもやってる。



最近の記事
最近のコメント
リンク
ページ
カテゴリ
アーカイブ
タグ一覧