[Catalyst] Unit tests for controllers based on Catalyst::Controller::REST?

James Russo jr at halo3.net
Wed Dec 29 04:03:24 GMT 2010

On Dec 28, 2010, at 10:44 PM, Bill Moseley wrote:
> 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.

Right. I suppose the only option is to create my own HTTP::Request object, set content and content-type header and then send it to $mech->request(...). It would be nice if post_ok() would somehow allow us to specify the actual content of the request and headers like Content-Type. As implemented right now post_ok() only allows you to specify content for form fields which are form-urlencoded into the body of the request.  Would be nice to have a request_ok() method similar to the post_ok() methods which allow us to specify our own HTTP::Request objects. This would be in Test::WWW::Mechanize though..



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101228/1904ba4d/attachment.htm

More information about the Catalyst mailing list