diff --git a/lib/fastimage.rb b/lib/fastimage.rb index 975b664..97eb415 100644 --- a/lib/fastimage.rb +++ b/lib/fastimage.rb @@ -214,7 +214,8 @@ class FastImage raise SizeNotFound if @options[:raise_on_failure] && @property == :size && !@size rescue Timeout::Error, SocketError, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET, - ImageFetchFailure, Net::HTTPBadResponse, EOFError, Errno::ENOENT, OpenSSL::SSL::SSLError + Errno::ENETUNREACH, ImageFetchFailure, Net::HTTPBadResponse, EOFError, Errno::ENOENT, + OpenSSL::SSL::SSLError 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] diff --git a/test/test.rb b/test/test.rb index dca9609..0d3bbe3 100644 --- a/test/test.rb +++ b/test/test.rb @@ -140,6 +140,14 @@ class FastImageTest < Test::Unit::TestCase end end + def test_should_raise_image_fetch_failure_error_if_net_unreach_exception_happens + FakeWeb.register_uri(:get, "http://example.com", :exception => Errno::ENETUNREACH) + + assert_raises(FastImage::ImageFetchFailure) do + FastImage.size("http://example.com", :raise_on_failure=>true) + end + end + def test_should_raise_unknown_image_typ_when_file_is_non_svg_xml assert_raises(FastImage::UnknownImageType) do FastImage.size(TestUrl + "test.xml", :raise_on_failure=>true) @@ -429,7 +437,7 @@ class FastImageTest < Test::Unit::TestCase def test_should_return_content_length_for_data_uri_images assert_equal DataUriImageContentLength, FastImage.new(DataUriImage).content_length end - + def test_canon_raw_formats_are_not_recognised_as_tiff assert_raises(FastImage::UnknownImageType) do FastImage.size(TestUrl + "a.CR2", :raise_on_failure=>true)