On Tue, Dec 28, 2010 at 4:47 PM, James Russo <[email protected]> wrote:

>        Does anyone there some examples of unit tests for a controller which
> is based on Catalyst::Controller::REST? There was some discussion on the
> list a few years ago, and I think the conclusion was to use LWP directly and
> not Test::WWW::Mechanize::Catalyst. It seems that using the methods do not
> give you access to passing actual body content and content-type headers?
> There are getting overridden somewhere along the line. I'm going to continue
> to research it, but figured I'd ask here before I spend too much time on it.
>

Are you asking how to make requests with specific HTTP methods (GET, PUT,
POST, DELETE)?

I use a module that basically does this:

$cookie_jar->add_cookie_header( $request );
my $cgi = HTTP::Request::AsCGI->new( $request, %ENV )->setup;
$app_name->handle_request;
my $response = $cgi->restore->response;
$response->request( $request );
$cookie_jar->extract_cookies( $response );


where $request is an HTTP::Request.  I wrap that with some utility methods
to make creating the requests easier and to encode/decode json and set
headers to emulate AJAX, etc.


-- 
Bill Moseley
[email protected]
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to