refactor source pixiv test

refactor pixiv download tests
refactor upload test
refactor nico seiga test
refactor twitter tests
This commit is contained in:
r888888888
2016-09-27 16:22:54 -07:00
parent 4fa2741ed2
commit fc7afd44ea
134 changed files with 66158 additions and 70930 deletions

View File

@@ -2,6 +2,12 @@ require 'test_helper'
module Downloads
class FileTest < ActiveSupport::TestCase
def setup
super
@record = false
setup_vcr
end
context "A post download" do
setup do
@source = "http://www.google.com/intl/en_ALL/images/logo.gif"
@@ -26,7 +32,7 @@ module Downloads
end
should "stream a file from an HTTP source" do
VCR.use_cassette("download-file-http", :record => :none) do
VCR.use_cassette("downloads-file-test/http", :record => @vcr_record_option) do
@download.http_get_streaming(@source) do |resp|
assert_equal("200", resp.code)
assert(resp["Content-Length"].to_i > 0, "File should be larger than 0 bytes")
@@ -36,7 +42,7 @@ module Downloads
should "throw an exception when the file is larger than the maximum" do
assert_raise(Downloads::File::Error) do
VCR.use_cassette("download-file-http", :record => :none) do
VCR.use_cassette("downloads-file-test/http", :record => @vcr_record_option) do
@download.http_get_streaming(@source, {}, :max_size => 1) do |resp|
end
end
@@ -44,7 +50,7 @@ module Downloads
end
should "store the file in the tempfile path" do
VCR.use_cassette("download-file-http", :record => :none) do
VCR.use_cassette("downloads-file-test/http", :record => @vcr_record_option) do
@download.download!
end
@@ -54,7 +60,7 @@ module Downloads
end
should "initialize the content type" do
VCR.use_cassette("download-file-http", :record => :once) do
VCR.use_cassette("downloads-file-test/http", :record => @vcr_record_option) do
@download.download!
end
@@ -74,7 +80,7 @@ module Downloads
end
should "stream a file from an HTTPS source" do
VCR.use_cassette("download-file-https", :record => :none) do
VCR.use_cassette("downloads-file-test/https", :record => @vcr_record_option) do
@download.http_get_streaming(@source) do |resp|
assert_equal("200", resp.code)
assert(resp["Content-Length"].to_i > 0, "File should be larger than 0 bytes")