Subdomains, SubdomainFu, and Cucumber

by Justin Blake on June 10, 2009

In order to use Cucumber to test a site that uses subdomains to scope things like user accounts, add something like this to your relevant step:

Given /^An account$/ do
  account = Factory(:account)
  host! "#{account.subdomain}.example.com"
end

and if you’re using SubdomainFu, make sure the tld_size for your test environment is set to 1 (or whatever is appropriate). By default it is set to 0. You can do this in features/support/env.rb:

SubdomainFu.tld_size = 1

Now any path built after that Given will use the account’s subdomdain in the request.host.

Bookmark and Share

Other Posts That Might Interest You

  1. ADS Wins Contact with SaySwap
  2. LinkedIn Uses Rails, Why Don’t You?
  3. Business Checklist for Selling a SaaS Application
blog comments powered by Disqus

Previous post:

Next post: