From 01d2005b4ba7c5e88b83ddc3d9eed87fb1bc8f1e Mon Sep 17 00:00:00 2001 From: sdsykes Date: Tue, 23 Feb 2010 10:46:58 +0100 Subject: [PATCH] Work around for ruby 1.8.7p248 bug in net/http --- lib/fastimage.rb | 2 ++ test/test.rb | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib/fastimage.rb b/lib/fastimage.rb index a0c0d41..c9e2ac0 100644 --- a/lib/fastimage.rb +++ b/lib/fastimage.rb @@ -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 diff --git a/test/test.rb b/test/test.rb index b8d7e92..c569eb4 100644 --- a/test/test.rb +++ b/test/test.rb @@ -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)