package Plack::Test; use strict; use warnings; use parent
qw(Exporter); our @EXPORT = qw(test_psgi); our $Impl; $Impl ||=
$ENV{PLACK_TEST_IMPL} || "MockHTTP"; sub test_psgi { eval
"require Plack::Test::$Impl;"; die $@ if $@; no strict 'refs';
if (ref $_[0] && @_ == 2) { @_ = (app => $_[0], client =>
$_[1]); } &{"Plack::Test::$Impl\::test_psgi"}(@_); } 1; __END__
=head1 NAME Plack::Test - Test PSGI applications with various
backends =head1 SYNOPSIS use Plack::Test; # named params
test_psgi app => sub { my $env = shift; return [ 200, [
'Content-Type' => 'text/plain' ], [ "Hello World" ] ], }, client
=> sub { my $cb = shift; my $req = HTTP::Request->new(GET =>
"http://localhost/hello"); my $res = $cb->($req); like
$res->content, qr/Hello World/; }; use HTTP::Request::Common; #
positional params (app, client) my $app = sub { return [ 200,
[], [ "Hello "] ] }; test_psgi $app, sub { my $cb = shift; my
$res = $cb->(GET "/"); is $res->content, "Hello"; }; =head1
DESCRIPTION Plack::Test is a unified interface to test