tests: move test/helpers to test/test_helpers.
The Rails convention is for test/helpers to be used for testing the view helpers in app/helpers. We were using it to store certain utility methods instead. Move these to test/test_helpers so that test/helpers can be used for its intended purpose.
This commit is contained in:
24
test/test_helpers/download_helper.rb
Normal file
24
test/test_helpers/download_helper.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
module DownloadTestHelper
|
||||
def assert_downloaded(expected_filesize, source)
|
||||
tempfile = Tempfile.new("danbooru-test")
|
||||
download = Downloads::File.new(source, tempfile.path)
|
||||
|
||||
assert_nothing_raised(Downloads::File::Error) do
|
||||
download.download!
|
||||
end
|
||||
|
||||
assert_equal(expected_filesize, tempfile.size, "Tested source URL: #{source}")
|
||||
end
|
||||
|
||||
def assert_rewritten(expected_source, test_source)
|
||||
tempfile = Tempfile.new("danbooru-test")
|
||||
download = Downloads::File.new(test_source, tempfile.path)
|
||||
|
||||
rewritten_source, _, _ = download.before_download(test_source, {})
|
||||
assert_equal(expected_source, rewritten_source, "Tested source URL: #{test_source}")
|
||||
end
|
||||
|
||||
def assert_not_rewritten(source)
|
||||
assert_rewritten(source, source)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user