2016-10-26 94 views
0

我想用puffing-billy寶石與poltergeist,我有一些問題。我capybara_helper.rb包含下面的代碼:水豚:: Poltergeist :: StatusFailError

Billy.configure do |c| 
    c.cache = true 
    c.cache_request_headers = false 
    c.path_blacklist = [] 
    c.persist_cache = true 
    c.ignore_cache_port = true 
    c.non_successful_cache_disabled = false 
    c.non_successful_error_level = :warn 
    c.non_whitelisted_requests_disabled = false 
end 

我的測試是:

scenario 'Add new address', driver: :poltergeist_billy do 
    proxy.stub("https://maps.googleapis.com/maps/api/js?callback=window.initializeGmaps&key=#{MyApiKeyGoesHere}&libraries=places&language=en"). 
      and_return(code: 500) 
    visit new_address_path 

    expect(page).to have_text('Service unavailable') 
end 

我收到一個錯誤:

Failure/Error: new_address_path 

    Capybara::Poltergeist::StatusFailError: 
     Request to 'http://127.0.0.1:33173/addresses/new' failed to reach server, check DNS and/or server status - Timed out with the following resources still waiting https://maps.googleapis.com/maps/api/js?callback=window.initializeGmaps&key=#{MyApiKeyGoesHere}-qk&libraries=places 

如果更改驅動程序selenium_billy,這樣的錯誤是:

Failure/Error: example.run 
    Net::ReadTimeout: 
    Net::ReadTimeout 

謝謝!

回答

0

它掛在的資源url並不完全匹配你在膨化比利中存留的資源 - 你可能想要用正則表達式來存根,以確保對地圖的所有請求都被截斷。

proxy.stub(%r{^https://maps.googleapis.com/maps}).and_return(code: 500) 
+0

我試過了,並且收到了同樣的錯誤,「無法到達服務器......」。 – verrom

相關問題