[Catalyst-dev] Catalyst::Test Wishes

Darin London dmlond at gmail.com
Tue May 27 13:19:58 GMT 2008


This is the text of a bug request, which was really a feature request.
Anyway, here is the text again in its original format.

Hi Catalyst developers,
I just wanted you to know how awesome Catalyst is. I really enjoy
developing with it. Just a couple of minor annoyances that I discovered
today when I went to start using Catalyst::Test framework.

First of all, I am using Catalyst version 5.7012 installed from CPAN on
fedora-core 5 with perl 5.8.8 compiled from source to get around that
stupid bug that popped up in the rpm version.

I want to test against the site that I have written, which is hosted on
an external server. The Catalyst::Test documentation states that there
is a CATALYST_SERVER shell variable that I can set to force the
Catalyst::Test::request method to use remote_request against that host
instead of a local request against the MyApp object itself. However,
when I did this, I noticed that the Catalyst::Utils::request method that
is used by the Catalyst::Test::remote_request method uses a hard-coded
'http://localhost' value in the HTTP::Request object that it returns. I
would have wanted this to test the presence of CATALYST_SERVER, and use
that instead of localhost, as it precludes me from making a remote
request against the server set in CATALYST_SERVER. I changed my version
to work how I wanted it to work. In case you are interested here is a
dif between the my new version of Catalyst::Utils and the original
Catalyst::Utils

227,228c227
< my $host =3D ($ENV{CATALYST_SERVER}) ? $ENV{CATALYST_SERVER}
: 'http://localhost';
< $request =3D URI->new( $host . $request );
---
> $request =3D URI->new( 'http://localhost' . $request );

Once I made that change, I wanted to use a cookie to authenticate the
test user against our system. However, I found that there was no way to
override the agent that Catalyst::Test::remote_request uses. It looked
as if it was thought that this would be possible, because there is an if
($agent) test before it is actually instantiated, but because the $agent
variable is a my variable, it cannot be overridden in the caller using
$Catalyst::Test::agent. I added a use vars qw($agent); and made the
$agent an our variable, and now I can do this. Here is a diff between
my Catalyst::Test and the original Catalyst::Test

9d8
< use vars qw($agent);
78c77
< our $agent;
---
> my $agent;


With this in place, I can set the CATALYST_SERVER shell variable, have
the test code make its own $Catalyst::Test::agent, and then, and run the
test using things like request('/'), request('/foo'), etc. Anyway, it
would be nice if the code worked this way. Keep up the good work.

Thanks,
Darin London
Duke University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst-dev/attachments/20080527/0=
41355d2/attachment.htm


More information about the Catalyst-dev mailing list