Work around for ruby 1.8.7p248 bug in net/http

This commit is contained in:
sdsykes 2010-02-23 10:46:58 +01:00
parent 304b99d5c6
commit 01d2005b4b
2 changed files with 8 additions and 0 deletions

View File

@ -147,6 +147,8 @@ class FastImage
raise ImageFetchFailure if options[:raise_on_failure]
rescue Errno::ENOENT
raise ImageFetchFailure if options[:raise_on_failure]
rescue NoMethodError # 1.8.7p248 can raise this due to a net/http bug
raise ImageFetchFailure if options[:raise_on_failure]
rescue UnknownImageType
raise UnknownImageType if options[:raise_on_failure]
end

View File

@ -74,6 +74,12 @@ class FastImageTest < Test::Unit::TestCase
end
end
def test_should_raise_when_asked_to_when_domain_does_not_exist
assert_raises(FastImage::ImageFetchFailure) do
FastImage.size("http://www.google.com/does_not_exist_at_all", :raise_on_failure=>true)
end
end
def test_should_raise_when_asked_when_image_type_not_known
assert_raises(FastImage::UnknownImageType) do
FastImage.size(TestUrl + "test.ico", :raise_on_failure=>true)