From 16a51533bcef4ec2a97109c4a37b4f30a6c3768f Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 21 Jun 2017 11:08:04 -0500 Subject: [PATCH] tests: refactor tumblr tests to use assert_downloaded. --- test/unit/downloads/tumblr_test.rb | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/test/unit/downloads/tumblr_test.rb b/test/unit/downloads/tumblr_test.rb index acfb77fb3..afc8a85eb 100644 --- a/test/unit/downloads/tumblr_test.rb +++ b/test/unit/downloads/tumblr_test.rb @@ -3,32 +3,17 @@ require 'test_helper' module Downloads class TumblrTest < ActiveSupport::TestCase context "a download for a tumblr 500 sample" do - setup do - @source = "http://24.media.tumblr.com/fc328250915434e66e8e6a92773f79d0/tumblr_mf4nshfibc1s0oswoo1_500.jpg" - @tempfile = Tempfile.new("danbooru-test") - @download = Downloads::File.new(@source, @tempfile.path) - @download.download! - end - - should "instead change the source to the 1280 version" do - assert_equal("http://24.media.tumblr.com/fc328250915434e66e8e6a92773f79d0/tumblr_mf4nshfibc1s0oswoo1_1280.jpg", @download.source) - end - should "instead download the 1280 version" do - assert_equal(196_617, ::File.size(@tempfile.path)) + @source = "http://24.media.tumblr.com/fc328250915434e66e8e6a92773f79d0/tumblr_mf4nshfibc1s0oswoo1_500.jpg" + assert_rewritten("http://24.media.tumblr.com/fc328250915434e66e8e6a92773f79d0/tumblr_mf4nshfibc1s0oswoo1_1280.jpg", @source) + assert_downloaded(196_617, @source) end end context "a download for a tumblr 500 image without a larger size" do - setup do - @source = "http://25.media.tumblr.com/tumblr_lxbzel2H5y1r9yjhso1_500.jpg" - @tempfile = Tempfile.new("danbooru-test") - @download = Downloads::File.new(@source, @tempfile.path) - @download.download! - end - should "download the 500 version" do - assert_equal(90_122, ::File.size(@tempfile.path)) + @source = "http://25.media.tumblr.com/tumblr_lxbzel2H5y1r9yjhso1_500.jpg" + assert_downloaded(90_122, @source) end end end