I have operationnal tests to check that the right message is displayed in a Rails UJS/ajax modal for error 404, 500... Here is an example below (the test below passes; I'm using puffing billy gem to stub the ajax response)
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
But I fail to test that the correct message is displayed when the problem is a timeout: indeed i don't stub inside rspec that the response sent by ajax is a timeout because Chrome/webkit actually does not send headers nor an "easy" code like 500 but sends the status (canceled).
I tried with no success:
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)')
Note: not sure it's related to the same chrome/webkit behavior but I saw this post: What does status=canceled for a resource mean in Chrome Developer Tools?