Skip to content

Commit

Permalink
Warn when updating the specs cache fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
evanphx committed Mar 21, 2012
1 parent b491d7f commit 5d61d92
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/rubygems/test_gem_commands_install_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,38 @@ def test_execute_nonexistent
assert_match(/ould not find a valid gem 'nonexistent'/, @ui.error)
end

def test_execute_bad_source
util_setup_fake_fetcher
util_setup_spec_fetcher

# This is needed because we need to exercise the cache path
# within SpecFetcher
path = File.join Gem.user_home, '.gem', 'specs', "not-there.nothing%80",
"latest_specs.4.8"

FileUtils.mkdir_p File.dirname(path)

File.open path, "w" do |f|
f.write Marshal.dump([])
end

Gem.sources.replace ["http://not-there.nothing"]

@cmd.options[:args] = %w[nonexistent]

use_ui @ui do
e = assert_raises Gem::SystemExitException do
@cmd.execute
end
assert_equal 2, e.exit_code
end

errs = @ui.error.split("\n")

assert_match(/ould not find a valid gem 'nonexistent'/, errs.shift)
assert_match(%r!Unable to download data from http://not-there.nothing!, errs.shift)
end

def test_execute_nonexistent_with_hint
misspelled = "nonexistent_with_hint"
correctly_spelled = "non_existent_with_hint"
Expand Down

0 comments on commit 5d61d92

Please sign in to comment.