ported tests to make use of run_test_request
Christian Walde [Wed, 5 Oct 2011 13:57:45 +0000 (15:57 +0200)]
t/env.t
t/post.t
t/sub-dispatch-args.t

diff --git a/t/env.t b/t/env.t
index 47bde37..0045f01 100644 (file)
--- a/t/env.t
+++ b/t/env.t
@@ -18,13 +18,6 @@ use Plack::Test;
   }
 }
 
-use HTTP::Request::Common qw(GET POST);
-
 my $app = EnvTest->new;
 
-sub run_request {
-  my $request = shift;
-  return test_psgi $app->to_psgi_app, sub { shift->($request) };
-}
-
-ok run_request(GET 'http://localhost/')->is_success;
+ok $app->run_test_request(GET => 'http://localhost/')->is_success;
index 805e57b..0981858 100644 (file)
--- a/t/post.t
+++ b/t/post.t
@@ -23,36 +23,31 @@ use Test::More qw(no_plan);
   }
 }
 
-use Plack::Test;
 use HTTP::Request::Common qw(GET POST);
 
 my $app = PostTest->new;
+sub run_request { $app->run_test_request(@_); }
 
-sub run_request {
-  my $request = shift;
-  return test_psgi $app->to_psgi_app, sub { shift->($request) };
-}
-
-my $get = run_request(GET 'http://localhost/');
+my $get = run_request(GET => 'http://localhost/');
 
 cmp_ok($get->code, '==', 404, '404 on GET');
 
-my $no_body = run_request(POST 'http://localhost/');
+my $no_body = run_request(POST => 'http://localhost/');
 
 cmp_ok($no_body->code, '==', 404, '404 with empty body');
 
-my $no_foo = run_request(POST 'http://localhost/' => [ bar => 'BAR' ]);
+my $no_foo = run_request(POST => 'http://localhost/' => [ bar => 'BAR' ]);
 
 cmp_ok($no_foo->code, '==', 404, '404 with no foo param');
 
-my $no_bar = run_request(POST 'http://localhost/' => [ foo => 'FOO' ]);
+my $no_bar = run_request(POST => 'http://localhost/' => [ foo => 'FOO' ]);
 
 cmp_ok($no_bar->code, '==', 200, '200 with only foo param');
 
 is($no_bar->content, 'FOO EMPTY', 'bar defaulted');
 
 my $both = run_request(
-  POST 'http://localhost/' => [ foo => 'FOO', bar => 'BAR' ]
+  POST => 'http://localhost/' => [ foo => 'FOO', bar => 'BAR' ]
 );
 
 cmp_ok($both->code, '==', 200, '200 with both params');
@@ -73,7 +68,7 @@ cmp_ok($upload->code, '==', 200, '200 with multipart');
 is($upload->content, 'FOO BAR', 'both params returned');
 
 my $upload_wrongtype = run_request(
-  POST 'http://localhost'
+  POST => 'http://localhost'
     => [ baz => 'fleem' ]
 );
 
index c68b059..8812595 100644 (file)
@@ -68,14 +68,9 @@ use Plack::Test;
 ok my $app = t::Web::Simple::SubDispatchArgs->new,
   'made app';
 
-sub run_request {
-  my $request = shift;
-  return test_psgi $app->to_psgi_app, sub { shift->($request) };
-}
-
-use HTTP::Request::Common qw(GET POST);
+sub run_request { $app->run_test_request(@_); }
 
-ok my $get_landing = run_request(GET 'http://localhost/' ),
+ok my $get_landing = run_request(GET => 'http://localhost/' ),
   'got landing';
 
 cmp_ok $get_landing->code, '==', 200, 
@@ -91,7 +86,7 @@ no strict 'refs';
     is ref($env), 'HASH', 'Got hashref';
 }
 
-ok my $get_users = run_request(GET 'http://localhost/user'),
+ok my $get_users = run_request(GET => 'http://localhost/user'),
   'got user';
 
 cmp_ok $get_users->code, '==', 200, 
@@ -104,7 +99,7 @@ cmp_ok $get_users->code, '==', 200,
     is ref($env), 'HASH', 'Got hashref';
 }
 
-ok my $get_user = run_request(GET 'http://localhost/user/42'),
+ok my $get_user = run_request(GET => 'http://localhost/user/42'),
   'got user';
 
 cmp_ok $get_user->code, '==', 200, 
@@ -117,7 +112,7 @@ cmp_ok $get_user->code, '==', 200,
     is ref($env), 'HASH', 'Got hashref';
 }
 
-ok my $post_user = run_request(POST 'http://localhost/user/42', [id => '99'] ),
+ok my $post_user = run_request(POST => 'http://localhost/user/42', [id => '99'] ),
   'post user';
 
 cmp_ok $post_user->code, '==', 200,