我经常在我的应用程序中看到RestClient::GatewayTimeout。我正在尝试弄清楚如何正确地测试这一点,以确保我的应用程序能够优雅地处理它。
我看到的最接近这一点的是stub_request(:any, 'www.example.net').to_timeout
然而,这会引发RestClient::RequestTimeout,而不是RestClient::GatewayTimeout。模拟后一种情况的最佳方法是什么?
发布于 2011-10-25 18:38:32
stub_request(:any, 'www.example.net').to_raise(RestClient::GatewayTimeout)
这显然只适用于RestClient,如果您将RestClient更改为其他库,您也必须更改您的测试。
https://stackoverflow.com/questions/7884514
复制相似问题