skip tests that throw an net::opentimeout error

This commit is contained in:
Albert Yi
2018-05-14 10:00:52 -07:00
parent ca61985bd9
commit 8d5db3723b
6 changed files with 63 additions and 22 deletions

View File

@@ -3,7 +3,18 @@ require 'ptools'
module DownloadTestHelper
def assert_downloaded(expected_filesize, source)
download = Downloads::File.new(source)
tempfile = download.download!
@retry_count = 0
begin
tempfile = download.download!
rescue Net::OpenTimeout
@retry_count += 1
if @retry_count == 3
skip "Remote connection to #{source} failed"
else
sleep(@retry_count ** 2)
retry
end
end
assert_equal(expected_filesize, tempfile.size, "Tested source URL: #{source}")
end