多域应用。在本地使用POW服务器。黄瓜测试
在其中一个步骤中我设置了app_host(子域名属于帐户并且每次都是伪造的):
def set_current_subdomain(subdomain)
Capybara.app_host = "http://#{subdomain}.example.com:#{Capybara.server_port}"
end
在黄瓜环境中:
Capybara.run_server = true
Capybara.server_port = 8200
Capybara.javascript_driver = :selenium #default driver when you using @javascript tag
Capybara.app = Rack::ShowExceptions.new(MyApp::Application)
Capybara.default_driver = :rack_test
步骤示例
visit(new_user_session_url(subdomain: @account.subdomain, port: Capybara.server_port))
Cucumber测试通过:rack_test但不包括:webkit或:selenium
Unable to load URL: http://veumbogan8d11d7feca.example.com:8200/signin because of error loading http://veumbogan8d11d7feca.example.com:8200/signin: Unknown error (Capybara::Webkit::InvalidResponseError)
webkit_debug输出:
Finished "EnableLogging" with response "Success()"
Wrote response true ""
Received "Visit"
Started "Visit"
Load started
"Visit" started page load
Started request to "http://kuphal375cb65167.example.com:8200/signin"
Finished "Visit" with response "Success()"
Received 0 from "http://kuphal375cb65167.example.com:8200/signin"
Page finished with false
Load finished
Page load from command finished
Wrote response false "{"class":"InvalidResponseError","message":"Unable to load URL: http://kuphal375cb65167.example.com:8200/signin because of error loading http://kuphal375cb65167.example.com:8200/signin: Unknown error"}"
使用selenium时,将打开firefox,其中"找不到服务器"
test.log中没有任何可疑:帐户已创建,通知电子邮件已发送等
非常感谢如何调试此问题以及可能存在的问题
PS:database_cleaner setup:
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "mongoid"
Before { DatabaseCleaner.clean }