Add failing test for a jpeg

This commit is contained in:
Marc-Andre Lafortune 2014-01-28 21:39:17 -05:00
parent 622131a9ea
commit be4db4a6af
2 changed files with 20 additions and 19 deletions

BIN
test/fixtures/test4.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

@ -18,6 +18,7 @@ GoodFixtures = {
"test.png"=>[:png, [30, 20]],
"test2.jpg"=>[:jpeg, [250, 188]],
"test3.jpg"=>[:jpeg, [630, 367]],
"test4.jpg"=>[:jpeg, [1485, 1299]],
"test.tiff"=>[:tiff, [85, 67]],
"test2.tiff"=>[:tiff, [333, 225]],
"exif_orientation.jpg"=>[:jpeg, [2448, 3264]],
@ -59,13 +60,13 @@ class FastImageTest < Test::Unit::TestCase
GoodFixtures.each do |fn, info|
assert_equal info[1], FastImage.size(TestUrl + fn)
assert_equal info[1], FastImage.size(TestUrl + fn, :raise_on_failure=>true)
end
end
end
def test_should_return_nil_on_fetch_failure
assert_nil FastImage.size(TestUrl + "does_not_exist")
end
def test_should_return_nil_for_faulty_jpeg_where_size_cannot_be_found
assert_nil FastImage.size(TestUrl + "faulty.jpg")
end
@ -73,11 +74,11 @@ class FastImageTest < Test::Unit::TestCase
def test_should_return_nil_when_image_type_not_known
assert_nil FastImage.size(TestUrl + "test.ico")
end
def test_should_return_nil_if_timeout_occurs
assert_nil FastImage.size("http://example.com/does_not_exist", :timeout=>0.001)
end
def test_should_raise_when_asked_to_when_size_cannot_be_found
assert_raises(FastImage::SizeNotFound) do
FastImage.size(TestUrl + "faulty.jpg", :raise_on_failure=>true)
@ -101,17 +102,17 @@ class FastImageTest < Test::Unit::TestCase
FastImage.size(TestUrl + "test.ico", :raise_on_failure=>true)
end
end
def test_should_report_type_correctly_for_local_files
GoodFixtures.each do |fn, info|
assert_equal info[0], FastImage.type(File.join(FixturePath, fn))
end
end
end
def test_should_report_size_correctly_for_local_files
GoodFixtures.each do |fn, info|
assert_equal info[1], FastImage.size(File.join(FixturePath, fn))
end
end
end
def test_should_report_type_correctly_for_ios
@ -121,7 +122,7 @@ class FastImageTest < Test::Unit::TestCase
end
end
end
def test_should_report_size_correctly_for_ios
GoodFixtures.each do |fn, info|
File.open(File.join(FixturePath, fn), "r") do |io|
@ -129,7 +130,7 @@ class FastImageTest < Test::Unit::TestCase
end
end
end
def test_should_report_size_correctly_on_io_object_twice
GoodFixtures.each do |fn, info|
File.open(File.join(FixturePath, fn), "r") do |io|
@ -144,11 +145,11 @@ class FastImageTest < Test::Unit::TestCase
assert_equal GoodFixtures["test.bmp"][1], FastImage.size(File.join("fixtures", "folder with spaces", "test.bmp"))
end
end
def test_should_return_nil_on_fetch_failure_for_local_path
assert_nil FastImage.size("does_not_exist")
end
def test_should_return_nil_for_faulty_jpeg_where_size_cannot_be_found_for_local_file
assert_nil FastImage.size(File.join(FixturePath, "faulty.jpg"))
end
@ -156,13 +157,13 @@ class FastImageTest < Test::Unit::TestCase
def test_should_return_nil_when_image_type_not_known_for_local_file
assert_nil FastImage.size(File.join(FixturePath, "test.ico"))
end
def test_should_raise_when_asked_to_when_size_cannot_be_found_for_local_file
assert_raises(FastImage::SizeNotFound) do
FastImage.size(File.join(FixturePath, "faulty.jpg"), :raise_on_failure=>true)
end
end
def test_should_handle_permanent_redirect
url = "http://example.com/foo.jpeg"
register_redirect(url, TestUrl + GoodFixtures.keys.first)
@ -189,7 +190,7 @@ class FastImageTest < Test::Unit::TestCase
FastImage.size(first_url, :raise_on_failure=>true)
end
end
def test_should_handle_permanent_redirect_with_relative_url
url = "http://example.nowhere/foo.jpeg"
register_redirect(url, "/" + GoodFixtures.keys.first)
@ -201,7 +202,7 @@ class FastImageTest < Test::Unit::TestCase
resp['Location'] = to
FakeWeb.register_uri(:get, from, :response=>resp)
end
def test_should_fetch_info_of_large_image_faster_than_downloading_the_whole_thing
time = Time.now
size = FastImage.size(LargeImage)
@ -214,7 +215,7 @@ class FastImageTest < Test::Unit::TestCase
assert type_time - time < LargeImageFetchLimit
assert_equal LargeImageInfo[0], type
end
# This test doesn't actually test the proxy function, but at least
# it excercises the code. You could put anything in the http_proxy and it would still pass.
# Any ideas on how to actually test this?
@ -226,9 +227,9 @@ class FastImageTest < Test::Unit::TestCase
ENV['http_proxy'] = nil
assert_equal actual_size, size
end
def test_should_handle_https_image
size = FastImage.size(HTTPSImage)
assert_equal HTTPSImageInfo[1], size
assert_equal HTTPSImageInfo[1], size
end
end