summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-07 22:17:08 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-07 22:17:08 +0000
commitbab42629ebff81cf5d8117f91bd536b3b2ac4a48 (patch)
tree8a92a4bebd2ce0f7c1b733886221cf024b04d595
parent972041696f8fd9506e4e0355ed1df04f78591035 (diff)
* lib/rubygems/dependency_installer.rb: Only install local gems if
they end in '.gem'. Fixes github rubygems issue #407. * test/rubygems/test_gem_dependency_installer.rb: Test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/rubygems/dependency_installer.rb2
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb27
3 files changed, 34 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a2640b1..fc2ab55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Feb 8 07:17:00 2013 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rubygems/dependency_installer.rb: Only install local gems if
+ they end in '.gem'. Fixes github rubygems issue #407.
+ * test/rubygems/test_gem_dependency_installer.rb: Test for the above.
+
Fri Feb 8 00:02:48 2013 Tanaka Akira <akr@fsij.org>
* process.c (obj2gid): use getgrnam_r() only if getgrnam_r() and
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index ed90af0..0158a71 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -260,7 +260,7 @@ class Gem::DependencyInstaller
set = Gem::AvailableSet.new
if consider_local?
- if File.file? gem_name then
+ if gem_name =~ /\.gem$/ and File.file? gem_name then
src = Gem::Source::SpecificFile.new(gem_name)
set.add src.spec, src
else
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
index 0d1a564..bbab5fe 100644
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ b/test/rubygems/test_gem_dependency_installer.rb
@@ -794,6 +794,19 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_equal Gem::Source.new(@gem_repo), s.source
end
+ def test_find_spec_by_name_and_version_bad_gem
+ FileUtils.touch 'rdoc.gem'
+
+ inst = Gem::DependencyInstaller.new
+
+ e = assert_raises Gem::Package::FormatError do
+ inst.find_spec_by_name_and_version 'rdoc.gem'
+ end
+
+ full_path = File.join @tempdir, 'rdoc.gem'
+ assert_equal "package metadata is missing in #{full_path}", e.message
+ end
+
def test_find_spec_by_name_and_version_directory
Dir.mkdir 'rdoc'
@@ -808,6 +821,20 @@ class TestGemDependencyInstaller < Gem::TestCase
e.message
end
+ def test_find_spec_by_name_and_version_file
+ FileUtils.touch 'rdoc'
+
+ inst = Gem::DependencyInstaller.new
+
+ e = assert_raises Gem::SpecificGemNotFoundException do
+ inst.find_spec_by_name_and_version 'rdoc'
+ end
+
+ assert_equal "Could not find a valid gem 'rdoc' (>= 0) " +
+ "locally or in a repository",
+ e.message
+ end
+
def test_find_gems_with_sources_local
util_setup_gems