We have intermittently failing tests due to Net::ReadTimeout
errors.
We have yet to figure out a permanent fix. For right now we want to try rescuing that specific error and re-running the test. Not a ideal solution or true fix but we need something in the short term.
How can we re-run the rspec test that failed? I mean how can the test suite do this automatically for that test?
We can catch the error like this:
# spec/support/capybara.rb
def rescue_net_read_timeout(max_tries = 1, tries = 0, &block)
yield
rescue Net::ReadTimeout => e
Rails.logger.error e.message
end
but how do we make it try re-running that test? We want to try re-running the test and then if the re-run passes move on with no error (ideally log it though), else fail for real and consider the test and hence the suite to have failed.