Reputation: 1304
So, I have a Rails webapp that utilizes subdomains for separating the admin functionality from the public functionality using subdomain-fu.
So there is functionality(that I want to test!) contained within two urls(eg admin.example.com
and www.example.com
). I want some scenarios to run against the admin domain, and some against the www domain.
My problem is that I cant figure out how to change the domain that selenium uses at any time after startup. I can put something like this in my env.rb:
Webrat.configure do |config|
config.mode = :selenium
config.application_address = "admin.example.com"
end
And it will work, but only for the scenarios that need the admin domain. If I try something like:
host! "www.example.com"
inside my steps, well it seems to just be ignored by selenium, which goes on using "admin.example.com"
Any ideas? Or if its not possible, any ideas for a workaround?
Upvotes: 1
Views: 1399
Reputation: 11
I haven't got this working using Webrat but with Cabybara the following works for me.
Given /^I visit subdomain "(.+)"$/ do |sub|
# host! "#{sub}.example.com" #for webrat
Capybara.default_host = "#{sub}.example.com" #for Rack::Test
Capybara.app_host = "http://#{sub}.example.com:9887" if Capybara.current_driver == :selenium
################################################################################
# As far as I know, you have to put all the {sub}.example.com entries that you're
# using in your /etc/hosts file for the Culerity tests. This didn't seem to be
# required for Rack::Test
################################################################################
end
Upvotes: 1
Reputation: 22418
I have never used webrat but in a normal test if you were to put a full path instead of a relative path in the open it.
so
selenium.open("http://foo/bar");
will make the test go to the full url
Upvotes: 0