2

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?

randombits
  • 47,058
  • 76
  • 251
  • 433

1 Answers1

2

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.

Bartosz Blimke
  • 6,498
  • 3
  • 24
  • 19