2010-04-27 16 views
1

因此,我有一个Rails web应用程序,它利用子域将admin功能与使用子域fu的公共功能分开。 因此,有两个网址(例如admin.example.comwww.example.com)中包含的功能(我想测试!)。我想要一些场景针对管理域运行,还有一些针对www域运行。在黄瓜场景内更改硒域/子域

我的问题是,我无法弄清楚如何改变硒在启动后随时使用的域。我可以把这样的事情在我env.rb:

Webrat.configure do |config| 
    config.mode = :selenium 
    config.application_address = "admin.example.com" 
end 

,它会工作,但只适用于需要管理域的方案。如果我尝试类似:

host! "www.example.com" 

在我的步骤,以及它似乎只是硒被忽略,其继续使用“admin.example.com”

任何想法?或者,如果它不可能,解决方法的任何想法?

回答

0

我从来没有使用webrat,但在正常的测试中,如果你打开一个完整的路径而不是相对路径的话。

所以

selenium.open("http://foo/bar");将测试到的完整URL

1

使用Webrat我没有得到这方面的工作,但与Cabybara以下为我工作。

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