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

Matt S Trout dbix-class at trout.me.uk
Sun Oct 5 11:20:50 BST 2008


On Fri, Oct 03, 2008 at 01:33:00PM -0400, Jason Gottshall wrote:
> Now that I think about it, what would/should happen if the test 
> specifies a complete white-label domain and you've got 
> $ENV{CATALYST_SERVER} set to run tests on a "remote" server?

We should send a request to the host in that env var, with a Host: header
of whatever is specified in the test code.
 
> I'm happy to implement the full white-labeling piece as well, but it 
> seems to have some caveats...

With the above approach, does it?

> >>  ok( request( '/foo/' )->is_success, 'foo succeeds for fizzle' );
> >>  ok( request( '/foo/', { subdomain => 'snazzle' } )->is_redirect, 'foo 
> >>redirects for snazzle');
> >>
> >>It would be nice, though, to have a mechanism for changing the "default" 
> >>at some point, so one could run groups of tests on a single subdomain 
> >>without having to pass it explicitly with each request. Of course, one 
> >>could always just wrap a set of tests for a specific subdomain in its 
> >>own test file, but that's not quite as cool...
> >
> >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' );
> >
> >};
> 
> Why doesn't my brain come up with lovely stuff like that?

Insufficient lisp.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst-dev mailing list