before(:each) do
switch_to_subdomain("#{test_company.subdomain}")
end
after(:each) do
switch_to_main_domain # keeps everything working fine with random test order
end
and then whatever you want to test on the subdomains
lvh.me and other services redirect to localhost or 127.0.0.1 for testing - work great for testing subdomains. if you aren't working directly on machine (I work on a VM sometimes.) Then just add the subdomains you work with to your hosts file.
subdomain.lvh.me:3000
You should also add whatever loopback service you use to your CI server's host file so any outages don't cause CI problems
models and attributes aren't magic, use whatever you like.
files are named with dashes in place of slashes just in case you're super fresh. The first time I picked up subdomains from railscast I was two weeks in to rails and not familiar - hopefully that helps someone.