Poltergeist無法連接到服務器。下面是我得到的錯誤:使用路徑助手時,水豚Poltergeist被迫通過https
Failure/Error: visit root_path
Capybara::Poltergeist::StatusFailError:
Request to 'http://127.0.0.1:58638/' failed to reach server, check DNS and/or server status
我已經上了phantomjs調試輸出,這裏是什麼樣子的相關線路對我說:
2016-12-14T14:24:47 [DEBUG] WebpageCallbacks - getJsConfirmCallback
{"command_id":"5eab3091-26bd-47b7-b779-95ec9523fb5b","response":true}
{"id":"1069af41-1b7c-4f5b-a9c7-258185aa8c73","name":"visit","args":["http://127.0.0.1:58638/"]}
2016-12-14T14:24:47 [DEBUG] WebPage - updateLoadingProgress: 10
2016-12-14T14:24:48 [DEBUG] Network - Resource request error: QNetworkReply::NetworkError(ConnectionRefusedError) ("Connection refused") URL: "https://127.0.0.1/"
2016-12-14T14:24:48 [DEBUG] WebPage - updateLoadingProgress: 100
2016-12-14T14:24:48 [DEBUG] WebPage - setupFrame ""
2016-12-14T14:24:48 [DEBUG] WebPage - setupFrame ""
2016-12-14T14:24:48 [DEBUG] WebPage - evaluateJavaScript "(function() { return (function() {\n return typeof __poltergeist;\n })(); })()"
2016-12-14T14:24:48 [DEBUG] WebPage - evaluateJavaScript result QVariant(QString, "undefined")
{"command_id":"1069af41-1b7c-4f5b-a9c7-258185aa8c73","error":{"name":"Poltergeist.StatusFailError","args":["http://127.0.0.1:58638/",null]}}
{"id":"cbe42cdc-58db-49c5-a230-4a1f4634d830","name":"reset","args":[]}
這一點似乎是一個線索Network - Resource request error: QNetworkReply::NetworkError(ConnectionRefusedError) ("Connection refused") URL: "https://127.0.0.1/"
並且它可能是一個ssl錯誤,所以我添加了phantomjs選項--ignore-ssl-errors=true
,但它對響應沒有任何影響。
我切換到capybara-webkit
看看是否會提供更多的信息,因爲有些人推薦。我得到一個非常類似的錯誤:
"Visit(http://127.0.0.1:64341/)" started page load
Started request to "http://127.0.0.1:64341/"
Finished "Visit(http://127.0.0.1:64341/)" with response "Success()"
Started request to "https://127.0.0.1/"
Received 301 from "http://127.0.0.1:64341/"
Received 0 from "https://127.0.0.1/"
Page finished with false
Load finished
Page load from command finished
Wrote response false "{"class":"InvalidResponseError","message":"Unable to load URL: http://127.0.0.1:64341/ because of error loading https://127.0.0.1/: Unknown error"}"
Received "Reset()"
Started "Reset()"
undefined|0|SECURITY_ERR: DOM Exception 18: An attempt was made to break through the security policy of the user agent.
與托馬斯 - 沃波爾@幫助我意識到,如果我具體的非HTTPS URL中水豚考察,它的工作原理。例如visit "http://localhost:3000"
它的工作原理。使用visit root_url
的作品,但使用visit root_path
我被定向到https和上面的錯誤。
config.force_ssl
不正確。我在config/environments/test.rb
中設置了config.force_ssl = false
,並且在測試環境中也使用pry來檢查Application.config
。
任何想法爲什麼通過https發送路徑助手將不勝感激。
如果相關,我可以在命令行上使用phantomjs連接'http://127.0.0.1:3000 /'。 – equivalentideas