[rspec-users] Testing Sub-domains with Cucumber

Stephen Eley sfeley at gmail.com
Wed Jan 14 09:51:16 EST 2009


On Tue, Jan 13, 2009 at 8:46 PM, Tom Hoen <lists at ruby-forum.com> wrote:
>
> When I say 'visits "/login"' in a step, I want it to have know to go to
> harvey.localhost:3000 for this feature/scenario. In another
> feature/scenario, I will want it to go to humbel.localhost:3000 etc.

Have you tried telling it "visits http://harvey.localhost:3000/login"
instead of just /login?

If that doesn't work: I remember having to spec some subdomain stuff
for a prior project.  Digging into the Rails code, I found the
TestRequest class, and saw in its initializer that by default it sets
the host to 'test.host'.  But it also sets up host as an accessor, so
you can set it to something else after the request gets created.

I'd leave off the :3000 port, though, unless you intend that to be
used in production as well.  If you're in the test environment and
making TestRequests you don't need it.

(And if you're in development mode and need to hit against a real
server, I've found my life got a whole lot simpler after I set up
Passenger.  No need to worry about starting up script/server or
hitting different ports, ever.)


-- 
Have Fun,
   Steve Eley (sfeley at gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org


More information about the rspec-users mailing list