[Catalyst-dev] subdomain hook for Catalyst::Test
Jason Gottshall
jgottshall at capwiz.com
Tue Oct 7 15:07:32 BST 2008
Matt S Trout wrote:
> On Tue, Sep 30, 2008 at 11:25:10AM -0400, Jason Gottshall wrote:
>> ok( request( '/foo/' )->is_success, 'foo succeeds for fizzle' );
>> ok( request( '/foo/', { subdomain => 'snazzle' } )->is_redirect, 'foo
>> redirects for snazzle');
>
> how about $Catalyst::Test::default_domain or something, and then you can do
>
> sub with_domain {
> my ($domain, $code) = @_;
> local $Catalyst::Test::default_domain = $domain;
> $code->();
> }
>
> with_domain 'foo.com' => sub {
>
> ok( request ('/foo/' )->is_success, 'w00t' );
>
> };
Here's a thought: if the (optional) alternate domain info is stored in a
package var, and therefore localizable, couldn't I then dispense with
the added argument to request() altogether? It certainly simplifies the
code; I don't have to mess with @_ anywhere. Tests can just localize the
defaults as necessary. Done.
More information about the Catalyst-dev
mailing list