[Catalyst-dev] subdomain hook for Catalyst::Test

Jason Gottshall jgottshall at capwiz.com
Wed Oct 8 17:03:07 BST 2008


Matt S Trout wrote:
> On Tue, Oct 07, 2008 at 10:07:32AM -0400, Jason Gottshall wrote:
>> 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.
> 
> You could. But isn't that gonna get kinda gross if you want to make lots
> of requests each to a different domain?

Yeah, I see what you mean. We're basically talking about

   ok( request('/foo/', {domain => 'bar.com'})->is_success,  'bar/foo' );
   ok( request('/baz/', {domain => 'qux.com'})->is_redirect, 'qux/baz' );
   ok( request('/abc/', {domain => 'xyz.com'})->is_error,    'xyz/abc' );

versus

   local Catalyst::Test::default_domain = 'bar.com';
   ok( request('/foo/')->is_success,  'bar/foo' );
   local Catalyst::Test::default_domain = 'qux.com';
   ok( request('/baz/')->is_redirect, 'qux/baz' );
   local Catalyst::Test::default_domain = 'xyz.com';
   ok( request('/abc/')->is_error,    'xyz/abc' );

There are certainly plenty of cases where one will be simpler to use 
than the other, and it's not that much more effort to make both of them 
work. *Sigh* :-)

Thanks for helping me refine this idea, Matt!






More information about the Catalyst-dev mailing list