我有operationnal測試,以檢查正確的消息顯示在Rails UJS/ajax模態的錯誤404,500 ...這裏低於一個例子(以下測試通過;我使用puffing billy gem末梢Ajax響應)水豚 - 識別阿賈克斯超時響應代碼(rspec /水豚/ webkit /膨化比利)
it " displays correct modal message appears correctly after relevant 500 xhr/ajax response is received" do
visit deal_page_path(deal)
proxy.stub("http://127.0.0.1:59533/deals/dealname/thrill").and_return(:code => 500)
first('a.button').click
wait_for_ajax
within('ul.messenger') do
expect(page).to have_content('So sorry, we had a bug, try again')
end
end
但我不測試顯示正確的消息時,問題是超時:確實我不t stub在rspec裏面,由ajax發送的響應是一個超時,因爲Chrome/webkit實際上不會發送頭文件,也不是像500那樣的「簡單」代碼,而是發送狀態(取消)。
我嘗試沒有成功:
proxy.stub("http://127.0.0.1:59533/deals/dealname/thrill").and_return(:status => 'canceled')
proxy.stub("http://127.0.0.1:59533/deals/dealname/thrill").and_return(:status => '(canceled)')
注:不知道它與同一鉻/ WebKit的行爲,但我看到了這個帖子:What does status=canceled for a resource mean in Chrome Developer Tools?