<br><br><div class="gmail_quote">On Tue, Dec 28, 2010 at 4:47 PM, James Russo <span dir="ltr">&lt;<a href="mailto:jr@halo3.net">jr@halo3.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

       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&#39;m going to continue to research it, but figured I&#39;d ask here before I spend too much time on it.<br>

</blockquote><div><br></div><div>Are you asking how to make requests with specific HTTP methods (GET, PUT, POST, DELETE)? </div><div><br></div><div>I use a module that basically does this:</div><div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">

<div class="gmail_quote"><div>$cookie_jar-&gt;add_cookie_header( $request );</div><div>my $cgi = HTTP::Request::AsCGI-&gt;new( $request, %ENV )-&gt;setup;</div></div><div class="gmail_quote"><div><div>$app_name-&gt;handle_request;</div>

</div></div><div class="gmail_quote"><div>my $response = $cgi-&gt;restore-&gt;response;</div></div><div class="gmail_quote"><div>$response-&gt;request( $request );</div><div>$cookie_jar-&gt;extract_cookies( $response );</div>

</div></blockquote><div class="gmail_quote"><div><br></div><div>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.</div>

<div> </div></div><br>-- <br>Bill Moseley<br><a href="mailto:moseley@hank.org" target="_blank">moseley@hank.org</a><br>