document and changelog run_test_request
Matt S Trout [Thu, 6 Oct 2011 21:55:47 +0000 (21:55 +0000)]
Changes
lib/Web/Simple.pm
lib/Web/Simple/Application.pm

diff --git a/Changes b/Changes
index 35d084e..dc11144 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
 Change log for Web::Simple
 
+  - Provide $app->run_test_request for use in test scripts
   - Preserve original env in Web::Dispatch so ParamParser can cache in there
     (stops HTTP::Body object getting destroyed early thereby losing uploads)
 
index b37ca27..0b7a1f7 100644 (file)
@@ -61,6 +61,10 @@ you'll get the "Hello world!" string output to your browser. At the same time
 this file will also act as a class module, so you can save it as HelloWorld.pm
 and use it as-is in test scripts or other deployment mechanisms.
 
+Note that you should retain the ->run_if_script even if your app is a
+module, since this additionally makes it valid as a .psgi file, which can
+be extremely useful during development.
+
 For more complex examples and non-CGI deployment, see
 L<Web::Simple::Deployment>. To get help with L<Web::Simple>, please connect to
 the irc.perl.org IRC network and join #web-simple.
index 88f025e..bd57c3b 100644 (file)
@@ -291,6 +291,25 @@ calls ->new, or as an object method ... in which case it doesn't.
 
 Used for running your application under stand-alone CGI and FCGI modes.
 
+I should document this more extensively but run_if_script will call it when
+you need it, so don't worry about it too much.
+
+=head2 run_test_request
+
+  my $res = $app->run_test_request(GET => '/');
+
+  my $res = $app->run_test_request(POST => '/' => %form);
+
+  my $res = $app->run_test_request($http_request);
+
+Accepts either an L<HTTP::Request> object or ($method, $path) and runs that
+request against the application, returning an L<HTTP::Response> object.
+
+If the HTTP method is POST or PUT, then a series of pairs can be passed after
+this to create a form style message body. If you need to test an upload, then
+create an L<HTTP::Request> object by hand or use the C<POST> subroutine
+provided by L<HTTP::Request::Common>.
+
 =head1 AUTHORS
 
 See L<Web::Simple> for authors.