[Catalyst] Testing Catalyst::Controller::REST based controllers

Damon Snyder drsnyder at influxmedia.com
Tue Feb 26 23:09:44 GMT 2008


Hi Ash,
Ah!!! Ok, here is what ended up working:

$req = POST( "http://localhost/rest/something",
		   'X-Username' => 'xxxxx',
		   'X-Password' => 'xxxxx',
           	   'Content_Type' => 'text/json', 		   		
                    'Content' => to_json({ stuff }),
        );
$res = $t1->request( $req );
my $thisres = $res->previous; ## if you get $res->content it will  
cause another request to be issued

ok($thisres->code == 201);
$something = from_json($thisres->content);

Note the "$res->previous" above. I believe what was happening is that  
your POST suggestion may have been working when I first tried it, but  
when I did a $res->content to test the result, it was causing another  
request to be made to the catalyst app which was clobbering the  
request/response objects.

Somewhat unexpected behavior. Maybe it is something you have to look  
out for when using Test::WWW::Mechanize::Catalyst. Thanks for you help!

Damon



On Feb 26, 2008, at 2:31 PM, Ash Berlin wrote:

>
> On 26 Feb 2008, at 22:20, Damon Snyder wrote:
>
>> Hi Ash,
>> Tried that, but no luck. I'm starting to wonder if  
>> Test::WWW::Mechanize::Catalyst or Test::WWW::Mechanize is  
>> clobbering the content portion of the request...
>>
>> What versions of Test::WWW::Mechanize::Catalyst and  
>> Test::WWW::Mechanize are you using? I have 0.41 and 1.18  
>> respectively.
>>
>> Damon
>>
>
> Same versions,
>
> Try using the POST function from HTTP::Request::Common that I showed  
> since I *know* that works for me.
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/







More information about the Catalyst mailing list