Files
danbooru/test/test_helpers/download_test_helper.rb
evazion 83a8468ee9 tests: remove unnecessary rescueing of Net::OpenTimeout errors.
These exceptions are no longer thrown now that we've switched from
HTTParty to http.rb. Swallowing unexpected exceptions during testing was
a bad practice anyway.
2020-06-23 03:12:44 -05:00

18 lines
654 B
Ruby

module DownloadTestHelper
def assert_downloaded(expected_filesize, source, referer = nil)
strategy = Sources::Strategies.find(source, referer)
file = strategy.download_file!
assert_equal(expected_filesize, file.size, "Tested source URL: #{source}")
end
def assert_rewritten(expected_source, test_source, test_referer = nil)
strategy = Sources::Strategies.find(test_source, test_referer)
rewritten_source = strategy.image_url
assert_match(expected_source, rewritten_source, "Tested source URL: #{test_source}")
end
def assert_not_rewritten(source, referer = nil)
assert_rewritten(source, source, referer)
end
end