FAQ

On Tue, Dec 28, 2010 at 4:47 PM, James Russo 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
moseley@hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101228/df547854/attachment.htm

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 8 | next ›
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedDec 29, '10 at 12:47a
activeJan 1, '11 at 4:16p
posts8
users4
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase