factor out run_test_request method
[catagits/Web-Simple.git] / t / env.t
CommitLineData
298a02df 1use strict;
2use warnings FATAL => 'all';
3
30e2c525 4use Test::More 'no_plan';
5use Plack::Test;
298a02df 6
7{
8 use Web::Simple 'EnvTest';
9 package EnvTest;
a61c443e 10 sub dispatch_request {
298a02df 11 sub (GET) {
a61c443e 12 my $env = $_[PSGI_ENV];
298a02df 13 [ 200,
14 [ "Content-type" => "text/plain" ],
15 [ 'foo' ]
16 ]
17 },
18 }
19}
20
21use HTTP::Request::Common qw(GET POST);
22
23my $app = EnvTest->new;
24
25sub run_request {
26 my $request = shift;
30e2c525 27 return test_psgi $app->to_psgi_app, sub { shift->($request) };
298a02df 28}
29
c7b1c57f 30ok run_request(GET 'http://localhost/')->is_success;