简体   繁体   中英

How to simulate Request Timeout in rspec with faraday

I use Faraday gem in app, and I want to test how my app works when Faraday connection fails by timeout. How can I stub request for this case?

I found a working method. May be it is not beautiful, but is works.

faraday_adapter.post('fail') do
  raise Faraday::TimeoutError
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM