Subject: | Catalyst::Test wishes |
Date: | Wed, 14 May 2008 16:36:19 -0400 |
To: | bug-Catalyst-Runtime [...] rt.cpan.org |
From: | Darin London <darin.london [...] duke.edu> |
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 = ($ENV{CATALYST_SERVER}) ? $ENV{CATALYST_SERVER}
: 'http://localhost';
< $request = URI->new( $host . $request );
---
Show quoted text
> $request = 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;
---
Show quoted text > 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