Question

I often see RestClient::GatewayTimeout in my application. I'm trying to figure out how to properly test for this, to make sure my application handles it gracefully.

The closest thing to this that I see is stub_request(:any, 'www.example.net').to_timeout

That raises RestClient::RequestTimeout however and not RestClient::GatewayTimeout. What's the best way to simulate the latter?

Was it helpful?

Solution

stub_request(:any, 'www.example.net').to_raise(RestClient::GatewayTimeout)

This will obviously work only for RestClient and if you change RestClient to some other library, you'll have to change your test too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top