Add failing test for ENV feature
nperez [Thu, 17 Jun 2010 22:51:13 +0000 (17:51 -0500)]
t/env.t [new file with mode: 0644]

diff --git a/t/env.t b/t/env.t
new file mode 100644 (file)
index 0000000..7a97658
--- /dev/null
+++ b/t/env.t
@@ -0,0 +1,36 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Test::More (
+  eval { require HTTP::Request::AsCGI }
+    ? 'no_plan'
+    : (skip_all => 'No HTTP::Request::AsCGI')
+);
+
+{
+  use Web::Simple 'EnvTest';
+  package EnvTest;
+  dispatch {
+    sub (GET) {
+      my $env = @_[ENV];
+      [ 200,
+        [ "Content-type" => "text/plain" ],
+        [ 'foo' ]
+      ]
+    },
+  }
+}
+
+use HTTP::Request::Common qw(GET POST);
+
+my $app = EnvTest->new;
+
+sub run_request {
+  my $request = shift;
+  my $c = HTTP::Request::AsCGI->new($request)->setup;
+  $app->run;
+  $c->restore;
+  return $c->response;
+}
+
+run_request(GET 'http://localhost/');