2 # Copyright Michael Orlitzky
4 # http://michael.orlitzky.com/
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # http://www.fsf.org/licensing/licenses/gpl.html
20 require 'src/uri_utilities.rb'
22 class UriUtilitiesTest
< Test
::Unit::TestCase
24 # Test that we get a 404 error for a nonexistent page.
25 def test_404_on_nonexistent_page
26 uu
= UriUtilities
.new()
28 # *Hopefully* this connection is refused.
29 example_uri
= 'http://www.example.com/test-nonexistent-page.html'
30 uri
= URI
.parse(example_uri
)
32 assert_raise OpenURI
::HTTPError do
33 uu
.download_with_progress_bar(uri
, 'dummy.tmp')
36 # This should be gone since there was an HTTP error.
37 assert(!File
.exists
?('dummy.tmp'))