Skip to content
Permalink
Browse files

handle rubygems errors when parsing gem prerelease versions

  • Loading branch information...
thewoolleyman committed Mar 25, 2010
1 parent 0abec7e commit 3eec994f7855e44e5624d7bfc171edcfe484b1d3
@@ -27,7 +27,15 @@ def search_less_than_or_equal_0_9_4(gem_pattern, version_requirement)
end

def search_greater_than_0_9_4(gem, version_requirement, platform_only = false)
dependency = Gem::Dependency.new(gem.name, version_requirement)
dependency = nil
begin
dependency = Gem::Dependency.new(gem.name, version_requirement)
rescue => e
msg = "Rubygems failed to parse gem: name='#{gem.name}', version='#{version_requirement}'. Original Error:\n" +
" #{e.inspect}\n" +
"If you are having problems with prerelease gems or non-numeric versions, please upgrade to the latest Rubygems."
raise GemInstaller::GemInstallerError.new(msg)
end
@gem_source_index_proxy.refresh!
@gem_source_index_proxy.search(dependency, platform_only)
end
@@ -21,6 +21,11 @@
@mock_gem_source_index_proxy.should_receive(:search).with('', GemInstaller::RubyGem.default_version)
@source_index_search_adapter.all_local_specs
end
else
it "raises a GemInstaller error if Gem::Dependency.new fails" do
Gem::Dependency.should_receive(:new).and_raise(ArgumentError)
lambda { @source_index_search_adapter.search(@sample_gem,@sample_gem.version) }.should raise_error(GemInstaller::GemInstallerError)
end
end

end

0 comments on commit 3eec994

Please sign in to comment.
You can’t perform that action at this time.