remove usage of vcr cassettes; delete unused fixtures; fix some broken unit tests

This commit is contained in:
Albert Yi
2016-12-28 15:43:52 -08:00
parent b2296cab70
commit 0ea7d78584
110 changed files with 182 additions and 113327 deletions

View File

@@ -2,12 +2,6 @@ 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"
@@ -32,38 +26,28 @@ module Downloads
end
should "stream a file from an HTTP source" 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")
end
@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")
end
end
should "throw an exception when the file is larger than the maximum" do
assert_raise(Downloads::File::Error) do
VCR.use_cassette("downloads-file-test/http", :record => @vcr_record_option) do
@download.http_get_streaming(@source, {}, :max_size => 1) do |resp|
end
@download.http_get_streaming(@source, {}, :max_size => 1) do |resp|
end
end
end
should "store the file in the tempfile path" do
VCR.use_cassette("downloads-file-test/http", :record => @vcr_record_option) do
@download.download!
end
@download.download!
assert_equal(@source, @download.source)
assert(::File.exists?(@tempfile.path), "temp file should exist")
assert(::File.size(@tempfile.path) > 0, "should have data")
end
should "initialize the content type" do
VCR.use_cassette("downloads-file-test/http", :record => @vcr_record_option) do
@download.download!
end
@download.download!
assert_match(/image\/gif/, @download.content_type)
end
end
@@ -80,11 +64,9 @@ module Downloads
end
should "stream a file from an HTTPS source" 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")
end
@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")
end
end
end