Subject: | Return value of test_psgi should be clarified |
The Plack::Test docs don't specify what test_psgi returns.
From inspecting the code (incl ::MockHTTP) it returns the return value of the callback
(including passing through the context).
That's very handy! It enables the tests to be moved outside the callback.
In my test script I now define a utility wrapper like this:
sub make_psgi_req {
my ($req) = @_;
return test_psgi $app, sub { shift->($req) } # returns HTTP::Response object
}
and do tests like this:
$resp = make_psgi_req( HTTP::Request->new(GET => "...") );
... tests on $resp go here ...
Thanks great, but I'm nervous of building on an undocumented aspect of the API.
p.s. Thanks for PSGI/Plack!