From: Matt S Trout Date: Thu, 6 Oct 2011 21:55:47 +0000 (+0000) Subject: document and changelog run_test_request X-Git-Tag: v0.010~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FWeb-Simple.git;a=commitdiff_plain;h=ca30a01761cb64b38f8fa01dba50ddceffedec29 document and changelog run_test_request --- diff --git a/Changes b/Changes index 35d084e..dc11144 100644 --- 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) diff --git a/lib/Web/Simple.pm b/lib/Web/Simple.pm index b37ca27..0b7a1f7 100644 --- a/lib/Web/Simple.pm +++ b/lib/Web/Simple.pm @@ -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. To get help with L, please connect to the irc.perl.org IRC network and join #web-simple. diff --git a/lib/Web/Simple/Application.pm b/lib/Web/Simple/Application.pm index 88f025e..bd57c3b 100644 --- a/lib/Web/Simple/Application.pm +++ b/lib/Web/Simple/Application.pm @@ -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 object or ($method, $path) and runs that +request against the application, returning an L 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 object by hand or use the C subroutine +provided by L. + =head1 AUTHORS See L for authors.