summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-04 00:29:40 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-04 00:29:40 +0000
commit5a90f9e8f84533e7859232895fc4bbe6b31cc771 (patch)
treee15086587f691a1f5bd3c7ddbfa38e825828caf6 /test/rubygems/test_gem.rb
parentf1321bd6e7c2d6b6a29a67074bad6f2742263921 (diff)
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.6.1.
Please see entries of 2.6.0 and 2.6.1 on https://github.com/rubygems/rubygems/blob/master/History.txt [fix GH-1270] Patch by @segiddins git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem.rb')
-rw-r--r--test/rubygems/test_gem.rb98
1 files changed, 98 insertions, 0 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index aec9d98c9a..aa57261d5e 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -473,6 +473,45 @@ class TestGem < Gem::TestCase
assert_equal cwd, $LOAD_PATH.shift
end
+ def test_self_find_files_with_gemfile
+ # write_file(File.join Dir.pwd, 'Gemfile') fails on travis 1.8.7 with $SAFE=1
+ skip if RUBY_VERSION <= "1.8.7"
+
+ cwd = File.expand_path("test/rubygems", @@project_dir)
+ $LOAD_PATH.unshift cwd
+
+ discover_path = File.join 'lib', 'sff', 'discover.rb'
+
+ foo1, _ = %w(1 2).map { |version|
+ spec = quick_gem 'sff', version do |s|
+ s.files << discover_path
+ end
+
+ write_file(File.join 'gems', spec.full_name, discover_path) do |fp|
+ fp.puts "# #{spec.full_name}"
+ end
+
+ spec
+ }
+ Gem.refresh
+
+ write_file(File.join Dir.pwd, 'Gemfile') do |fp|
+ fp.puts "source 'https://rubygems.org'"
+ fp.puts "gem '#{foo1.name}', '#{foo1.version}'"
+ end
+ Gem.use_gemdeps(File.join Dir.pwd, 'Gemfile')
+
+ expected = [
+ File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
+ File.join(foo1.full_gem_path, discover_path)
+ ]
+
+ assert_equal expected, Gem.find_files('sff/discover')
+ assert_equal expected, Gem.find_files('sff/**.rb'), '[ruby-core:31730]'
+ ensure
+ assert_equal cwd, $LOAD_PATH.shift unless RUBY_VERSION <= "1.8.7"
+ end
+
def test_self_find_latest_files
cwd = File.expand_path("test/rubygems", @@project_dir)
$LOAD_PATH.unshift cwd
@@ -929,6 +968,26 @@ class TestGem < Gem::TestCase
assert_match %r%Could not find 'b' %, e.message
end
+ def test_self_try_activate_missing_prerelease
+ b = util_spec 'b', '1.0rc1'
+ a = util_spec 'a', '1.0rc1', 'b' => '1.0rc1'
+
+ install_specs b, a
+ uninstall_gem b
+
+ a_file = File.join a.gem_dir, 'lib', 'a_file.rb'
+
+ write_file a_file do |io|
+ io.puts '# a_file.rb'
+ end
+
+ e = assert_raises Gem::LoadError do
+ Gem.try_activate 'a_file'
+ end
+
+ assert_match %r%Could not find 'b' \(= 1.0rc1\)%, e.message
+ end
+
def test_self_try_activate_missing_extensions
spec = util_spec 'ext', '1' do |s|
s.extensions = %w[ext/extconf.rb]
@@ -951,6 +1010,45 @@ class TestGem < Gem::TestCase
assert_equal expected, err
end
+ def test_self_use_paths_with_nils
+ orig_home = ENV.delete 'GEM_HOME'
+ orig_path = ENV.delete 'GEM_PATH'
+ Gem.use_paths nil, nil
+ assert_equal Gem.default_dir, Gem.paths.home
+ assert_equal (Gem.default_path + [Gem.paths.home]).uniq, Gem.paths.path
+ ensure
+ ENV['GEM_HOME'] = orig_home
+ ENV['GEM_PATH'] = orig_path
+ end
+
+ def test_setting_paths_does_not_warn_about_unknown_keys
+ stdout, stderr = capture_io do
+ Gem.paths = { 'foo' => [],
+ 'bar' => Object.new,
+ 'GEM_HOME' => Gem.paths.home,
+ 'GEM_PATH' => 'foo' }
+ end
+ assert_equal ['foo', Gem.paths.home], Gem.paths.path
+ assert_equal '', stderr
+ assert_equal '', stdout
+ end
+
+ def test_setting_paths_does_not_mutate_parameter_object
+ Gem.paths = { 'GEM_HOME' => Gem.paths.home,
+ 'GEM_PATH' => 'foo' }.freeze
+ assert_equal ['foo', Gem.paths.home], Gem.paths.path
+ end
+
+ def test_deprecated_paths=
+ stdout, stderr = capture_io do
+ Gem.paths = { 'GEM_HOME' => Gem.paths.home,
+ 'GEM_PATH' => [Gem.paths.home, 'foo'] }
+ end
+ assert_equal [Gem.paths.home, 'foo'], Gem.paths.path
+ assert_match(/Array values in the parameter are deprecated. Please use a String or nil/, stderr)
+ assert_equal '', stdout
+ end
+
def test_self_use_paths
util_ensure_gem_dirs