2010-04-27 77 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