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

Bill Moseley moseley at hank.org
Wed Dec 29 03:44:05 GMT 2010


On Tue, Dec 28, 2010 at 4:47 PM, James Russo <jr at halo3.net> wrote:

>        Does anyone there some examples of unit tests for a controller whi=
ch
> 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 conti=
nue
> 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 =3D HTTP::Request::AsCGI->new( $request, %ENV )->setup;
$app_name->handle_request;
my $response =3D $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
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101228/df547=
854/attachment.htm


More information about the Catalyst mailing list