summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiroshi SHIBATA <[email protected]>2020-12-08 16:33:39 +0900
committerHiroshi SHIBATA <[email protected]>2020-12-08 17:30:02 +0900
commit4aca77edde91f826aa243e268bf1ef5214530583 ()
treeef0cf1a95fcced00ca5fa40f3412c567bf95d705 /test
parent6a6a24df9b72750d12f9b15192bdb7517e668efb (diff)
Merge prepare version of RubyGems 3.2.0
Notes: Merged: https://.com/ruby/ruby/pull/3864
-rw-r--r--test/rubygems/test_bundled_ca.rb14
-rw-r--r--test/rubygems/test_gem.rb6
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb202
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_cleanup_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_contents_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_help_command.rb17
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_owner_command.rb50
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_push_command.rb36
-rw-r--r--test/rubygems/test_gem_commands_query_command.rb6
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb31
-rw-r--r--test/rubygems/test_gem_commands_signin_command.rb30
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb60
-rw-r--r--test/rubygems/test_gem_commands_specification_command.rb28
-rw-r--r--test/rubygems/test_gem_commands_update_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_yank_command.rb32
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb38
-rw-r--r--test/rubygems/test_gem_dependency_list.rb4
-rw-r--r--test/rubygems/test_gem_ext_builder.rb24
-rw-r--r--test/rubygems/test_gem_ext_cmake_builder.rb12
-rw-r--r--test/rubygems/test_gem_ext_configure_builder.rb12
-rw-r--r--test/rubygems/test_gem_ext_ext_conf_builder.rb35
-rw-r--r--test/rubygems/test_gem_ext_rake_builder.rb18
-rw-r--r--test/rubygems/test_gem_gem_runner.rb9
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb6
-rw-r--r--test/rubygems/test_gem_install_update_options.rb18
-rw-r--r--test/rubygems/test_gem_installer.rb85
-rw-r--r--test/rubygems/test_gem_package.rb16
-rw-r--r--test/rubygems/test_gem_package_old.rb8
-rw-r--r--test/rubygems/test_gem_package_tar_writer.rb2
-rw-r--r--test/rubygems/test_gem_platform.rb67
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb32
-rw-r--r--test/rubygems/test_gem_request.rb4
-rw-r--r--test/rubygems/test_gem_request_set_lockfile.rb8
-rw-r--r--test/rubygems/test_gem_resolver_api_set.rb16
-rw-r--r--test/rubygems/test_gem_resolver_conflict.rb2
-rw-r--r--test/rubygems/test_gem_resolver_vendor_set.rb2
-rw-r--r--test/rubygems/test_gem_security.rb4
-rw-r--r--test/rubygems/test_gem_security_policy.rb4
-rw-r--r--test/rubygems/test_gem_security_signer.rb4
-rw-r--r--test/rubygems/test_gem_security_trust_dir.rb4
-rw-r--r--test/rubygems/test_gem_source.rb5
-rw-r--r--test/rubygems/test_gem_source_subpath_problem.rb49
-rw-r--r--test/rubygems/test_gem_specification.rb9
-rw-r--r--test/rubygems/test_gem_uninstaller.rb14
-rw-r--r--test/rubygems/test_gem_validator.rb2
-rw-r--r--test/rubygems/test_gem_version_option.rb2
-rw-r--r--test/rubygems/test_require.rb59
50 files changed, 873 insertions, 233 deletions
@@ -3,7 +3,7 @@ require 'rubygems/test_case'
require 'net/http'
require 'rubygems/openssl'
-unless defined?(OpenSSL::SSL)
warn 'Skipping bundled certificates tests. openssl not found.'
end
@@ -46,11 +46,15 @@ class TestBundledCA < Gem::TestCase
assert_https('rubygems.org')
end
- def test_accessing_fastly
- assert_https('rubygems.global.ssl.fastly.net')
end
def test_accessing_new_index
- assert_https('fastly.rubygems.org')
end
-end if defined?(OpenSSL::SSL)
@@ -164,7 +164,7 @@ class TestGem < Gem::TestCase
:prog_mode => win_platform? ? 0410 : 0510,
:data_mode => 0640,
:wrappers => true,
- :format_executable => format_executable
}
Dir.chdir @tempdir do
Dir.mkdir 'bin'
@@ -765,7 +765,7 @@ class TestGem < Gem::TestCase
expected = [
File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR),
- File.join(foo1.full_gem_path, discover_path)
].sort
assert_equal expected, Gem.find_files('sff/discover').sort
@@ -1532,7 +1532,7 @@ class TestGem < Gem::TestCase
tests = [
[:dir0, [ Gem.dir, Gem.user_dir], m0],
- [:dir1, [ Gem.user_dir, Gem.dir], m1]
]
tests.each do |_name, _paths, expected|
@@ -231,7 +231,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
end
assert_equal '', @ui.output
- assert_equal "ERROR: Gemspec file not found: some_gem.gemspec\n", @ui.error
end
def test_execute_outside_dir
@@ -272,8 +272,200 @@ class TestGemCommandsBuildCommand < Gem::TestCase
assert_equal "this is a summary", spec.summary
end
def test_can_find_gemspecs_without_dot_gemspec
- gemspec_file = File.join(@tempdir, @gem.spec_name)
File.open gemspec_file + ".gemspec", 'w' do |gs|
gs.write @gem.to_ruby
@@ -390,7 +582,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
end
def test_build_signed_gem
- skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
trust_dir = Gem::Security.trust_dir
@@ -417,7 +609,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
end
def test_build_signed_gem_with_cert_expiration_length_days
- skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
gem_path = File.join Gem.user_home, ".gem"
Dir.mkdir gem_path
@@ -461,7 +653,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
end
def test_build_auto_resign_cert
- skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
gem_path = File.join Gem.user_home, ".gem"
Dir.mkdir gem_path
@@ -2,7 +2,7 @@
require 'rubygems/test_case'
require 'rubygems/commands/cert_command'
-unless defined?(OpenSSL::SSL)
warn 'Skipping `gem cert` tests. openssl not found.'
end
@@ -805,4 +805,4 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
assert_equal "invalid argument: --sign #{nonexistent}: does not exist",
e.message
end
-end if defined?(OpenSSL::SSL) && !Gem.java_platform?
@@ -221,7 +221,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
@b_2 = util_spec 'b', 3
install_gem @b_1
- install_default_specs @b_default
install_gem @b_2
@cmd.options[:args] = []
@@ -227,7 +227,7 @@ lib/foo.rb
nil, "default/gem.rb")
default_gem_spec.executables = ["default_command"]
default_gem_spec.files += ["default_gem.so"]
- install_default_specs(default_gem_spec)
@cmd.options[:args] = %w[default]
@@ -238,7 +238,7 @@ lib/foo.rb
expected = [
[RbConfig::CONFIG['bindir'], 'default_command'],
[RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'],
- [RbConfig::CONFIG['archdir'], 'default_gem.so']
].sort.map{|a|File.join a }.join "\n"
assert_equal expected, @ui.output.chomp
@@ -40,10 +40,12 @@ class TestGemCommandsHelpCommand < Gem::TestCase
util_gem 'commands' do |out, err|
mgr.command_names.each do |cmd|
- assert_match(/\s+#{cmd}\s+\S+/, out)
end
- if defined?(OpenSSL::SSL)
assert_empty err
refute_match 'No command found for ', out
@@ -51,6 +53,17 @@ class TestGemCommandsHelpCommand < Gem::TestCase
end
end
def test_gem_no_args_shows_help
util_gem do |out, err|
assert_match(/Usage:/, out)
@@ -410,7 +410,7 @@ ERROR: Possible alternatives: non_existent_with_hint
expected = [
"ERROR: Could not find a valid gem 'non-existent_with-hint' (>= 0) in any repository",
- "ERROR: Possible alternatives: nonexistent-with_hint"
]
output = @ui.error.split "\n"
@@ -247,7 +247,7 @@ EOF
@stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [
[response_fail, 401, 'Unauthorized'],
- [response_success, 200, 'OK']
]
@otp_ui = Gem::MockGemUi.new "111111\n"
@@ -275,4 +275,52 @@ EOF
assert_match 'Code: ', @otp_ui.output
assert_equal '111111', @stub_fetcher.last_request['OTP']
end
end
@@ -568,7 +568,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
assert_equal([
"Restoring gems to pristine condition...",
"Cached gem for a-2 not found, attempting to fetch...",
- "Skipped a-2, it was not found from cache and remote sources"
], @ui.output.split("\n"))
assert_empty @ui.error
@@ -577,7 +577,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
def test_execute_default_gem
default_gem_spec = new_default_spec("default", "2.0.0.0",
nil, "default/gem.rb")
- install_default_specs(default_gem_spec)
@cmd.options[:args] = %w[default]
@@ -152,7 +152,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
keys = {
:rubygems_api_key => 'KEY',
- @host => @api_key
}
FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path
@@ -187,7 +187,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
keys = {
:rubygems_api_key => 'KEY',
- @host => @api_key
}
FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path
@@ -271,7 +271,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
keys = {
:rubygems_api_key => 'KEY',
- @host => @api_key
}
FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path
@@ -302,7 +302,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
api_key = "PRIVKEY"
keys = {
- host => api_key
}
FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path
@@ -373,7 +373,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
@fetcher.data["#{Gem.host}/api/v1/gems"] = [
[response_fail, 401, 'Unauthorized'],
- [response_success, 200, 'OK']
]
@otp_ui = Gem::MockGemUi.new "111111\n"
@@ -404,6 +404,32 @@ class TestGemCommandsPushCommand < Gem::TestCase
assert_equal '111111', @fetcher.last_request['OTP']
end
private
def singleton_gem_class
@@ -644,7 +644,7 @@ a (2 universal-darwin, 1 ruby x86-linux)
spec_fetcher {|fetcher| fetcher.spec 'a', 2 }
a1 = new_default_spec 'a', 1
- install_default_specs a1
use_ui @stub_ui do
@cmd.execute
@@ -663,7 +663,7 @@ EOF
def test_execute_show_default_gems_with_platform
a1 = new_default_spec 'a', 1
a1.platform = 'java'
- install_default_specs a1
use_ui @stub_ui do
@cmd.execute
@@ -685,7 +685,7 @@ EOF
end
a1 = new_default_spec 'a', 1
- install_default_specs a1
@cmd.handle_options %w[-l -d]
@@ -26,12 +26,12 @@ class TestGemCommandsSetupCommand < Gem::TestCase
bundler/exe/bundle
bundler/lib/bundler.rb
bundler/lib/bundler/b.rb
bundler/lib/bundler/templates/.circleci/config.yml
bundler/lib/bundler/templates/.travis.yml
bundler/man/bundle-b.1
- bundler/man/bundle-b.1.ronn
bundler/man/gemfile.5
- bundler/man/gemfile.5.ronn
]
create_dummy_files(filelist)
@@ -155,23 +155,18 @@ class TestGemCommandsSetupCommand < Gem::TestCase
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(gem_bin_path)
end
- def test_pem_files_in
- assert_equal %w[rubygems/ssl_certs/rubygems.org/foo.pem],
- @cmd.pem_files_in('lib').sort
- end
-
- def test_rb_files_in
- assert_equal %w[rubygems.rb rubygems/test_case.rb],
- @cmd.rb_files_in('lib').sort
end
def test_bundler_man1_files_in
- assert_equal %w[bundle-b.1 bundle-b.1.ronn],
@cmd.bundler_man1_files_in('bundler/man').sort
end
def test_bundler_man5_files_in
- assert_equal %w[gemfile.5 gemfile.5.ronn],
@cmd.bundler_man5_files_in('bundler/man').sort
end
@@ -187,7 +182,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
assert_path_exists File.join(dir, 'bundler.rb')
assert_path_exists File.join(dir, 'bundler/b.rb')
- assert_path_exists File.join(dir, 'bundler/templates/.circleci/config.yml')
assert_path_exists File.join(dir, 'bundler/templates/.travis.yml')
end
end
@@ -199,9 +194,9 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@cmd.install_man dir
assert_path_exists File.join("#{dir}/man1", 'bundle-b.1')
- assert_path_exists File.join("#{dir}/man1", 'bundle-b.1.ronn')
assert_path_exists File.join("#{dir}/man5", 'gemfile.5')
- assert_path_exists File.join("#{dir}/man5", 'gemfile.5.ronn')
end
end
@@ -297,7 +292,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@cmd.remove_old_lib_files lib
- files_that_go.each {|file| refute_path_exists file }
files_that_stay.each {|file| assert_path_exists file }
end
@@ -313,8 +308,8 @@ class TestGemCommandsSetupCommand < Gem::TestCase
gemfile_5_ronn = File.join man, 'man5', 'gemfile.5.ronn'
gemfile_5_txt = File.join man, 'man5', 'gemfile.5.txt'
- files_that_go = [bundle_b_1_txt, gemfile_5_txt]
- files_that_stay = [ruby_1, bundle_b_1, bundle_b_1_ronn, gemfile_5, gemfile_5_ronn]
create_dummy_files(files_that_go + files_that_stay)
@@ -73,14 +73,38 @@ class TestGemCommandsSigninCommand < Gem::TestCase
assert_equal api_key, credentials[:rubygems_api_key]
end
# Utility method to capture IO/UI within the block passed
- def util_capture(ui_stub = nil, host = nil, api_key = nil)
api_key ||= 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
response = [api_key, 200, 'OK']
password = 'secret'
- fetcher = Gem::FakeFetcher.new
# Set the expected response for the Web-API supplied
ENV['RUBYGEMS_HOST'] = host || Gem::DEFAULT_HOST
@@ -88,7 +112,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
fetcher.data[data_key] = response
Gem::RemoteFetcher.fetcher = fetcher
- sign_in_ui = ui_stub || Gem::MockGemUi.new("#{email}\n#{password}\n")
use_ui sign_in_ui do
yield
@@ -107,6 +107,36 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
assert_empty ui.error
end
def test_execute_add_deny_typo_squatting_source
rubygems_org = "https://rubyems.org"
@@ -283,6 +313,36 @@ source http://gems.example.com/ already present in the cache
assert_empty @ui.error
end
def test_execute_add_https_rubygems_org
https_rubygems_org = 'https://rubygems.org/'
@@ -186,6 +186,34 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
assert_equal Gem::Version.new("1"), spec.version
end
def test_execute_remote_without_prerelease
spec_fetcher do |fetcher|
fetcher.spec 'foo', '2.0.0'
@@ -198,13 +198,13 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
def test_execute_system_specific_newer_than_or_equal_to_3_2_leaves_plugins_dir_alone
spec_fetcher do |fetcher|
- fetcher.download 'rubygems-update', 3.2 do |s|
s.files = %w[setup.rb]
end
end
@cmd.options[:args] = []
- @cmd.options[:system] = "3.2"
FileUtils.mkdir_p Gem.plugindir
plugin_file = File.join(Gem.plugindir, 'a_plugin.rb')
@@ -70,7 +70,7 @@ class TestGemCommandsYankCommand < Gem::TestCase
yank_uri = 'http://example/api/v1/gems/yank'
@fetcher.data[yank_uri] = [
[response_fail, 401, 'Unauthorized'],
- ['Successfully yanked', 200, 'OK']
]
@cmd.options[:args] = %w[a]
@@ -147,4 +147,34 @@ class TestGemCommandsYankCommand < Gem::TestCase
assert_equal 'key', @fetcher.last_request['Authorization']
assert_equal [yank_uri], @fetcher.paths
end
end
@@ -528,6 +528,40 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_equal %w[a-1 e-1], inst.installed_gems.map {|s| s.full_name }
end
def test_install_no_document
util_setup_gems
@@ -749,7 +783,7 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = nil
Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new
inst.install 'a'
end
@@ -842,7 +876,7 @@ class TestGemDependencyInstaller < Gem::TestCase
require 'rubygems/openssl'
- if defined? OpenSSL
def test_install_security_policy
util_setup_gems
@@ -139,8 +139,8 @@ class TestGemDependencyList < Gem::TestCase
exp = {
"b" => [
- Gem::Dependency.new("a", ">= 1")
- ]
}
assert_equal exp, @deplist.why_not_ok?
@@ -30,9 +30,8 @@ class TestGemExtBuilder < Gem::TestCase
ENV['DESTDIR'] = 'destination'
results = []
- Dir.chdir @ext do
- File.open 'Makefile', 'w' do |io|
- io.puts <<-MAKEFILE
all:
\t@#{Gem.ruby} -e "puts %Q{all: \#{ENV['DESTDIR']}}"
@@ -41,12 +40,11 @@ clean:
install:
\t@#{Gem.ruby} -e "puts %Q{install: \#{ENV['DESTDIR']}}"
- MAKEFILE
- end
-
- Gem::Ext::Builder.make @dest_path, results
end
results = results.join("\n").b
assert_match %r{"DESTDIR=#{ENV['DESTDIR']}" clean$}, results
@@ -64,20 +62,18 @@ install:
ENV['DESTDIR'] = 'destination'
results = []
- Dir.chdir @ext do
- File.open 'Makefile', 'w' do |io|
- io.puts <<-MAKEFILE
all:
\t@#{Gem.ruby} -e "puts %Q{all: \#{ENV['DESTDIR']}}"
install:
\t@#{Gem.ruby} -e "puts %Q{install: \#{ENV['DESTDIR']}}"
- MAKEFILE
- end
-
- Gem::Ext::Builder.make @dest_path, results
end
results = results.join("\n").b
assert_match %r{"DESTDIR=#{ENV['DESTDIR']}" clean$}, results
@@ -36,9 +36,7 @@ install (FILES test.txt DESTINATION bin)
output = []
- Dir.chdir @ext do
- Gem::Ext::CmakeBuilder.build nil, @dest_path, output
- end
output = output.join "\n"
@@ -54,9 +52,7 @@ install (FILES test.txt DESTINATION bin)
output = []
error = assert_raises Gem::InstallError do
- Dir.chdir @ext do
- Gem::Ext::CmakeBuilder.build nil, @dest_path, output
- end
end
output = output.join "\n"
@@ -77,9 +73,7 @@ install (FILES test.txt DESTINATION bin)
output = []
- Dir.chdir @ext do
- Gem::Ext::CmakeBuilder.build nil, @dest_path, output
- end
output = output.join "\n"
@@ -25,9 +25,7 @@ class TestGemExtConfigureBuilder < Gem::TestCase
output = []
- Dir.chdir @ext do
- Gem::Ext::ConfigureBuilder.build nil, @dest_path, output
- end
assert_match(/^current directory:/, output.shift)
assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift
@@ -48,9 +46,7 @@ class TestGemExtConfigureBuilder < Gem::TestCase
output = []
error = assert_raises Gem::InstallError do
- Dir.chdir @ext do
- Gem::Ext::ConfigureBuilder.build nil, @dest_path, output
- end
end
shell_error_msg = %r{(\./configure: .*)|((?:[Cc]an't|cannot) open '?\./configure'?(?:: No such file or directory)?)}
@@ -74,9 +70,7 @@ class TestGemExtConfigureBuilder < Gem::TestCase
end
output = []
- Dir.chdir @ext do
- Gem::Ext::ConfigureBuilder.build nil, @dest_path, output
- end
assert_contains_make_command 'clean', output[1]
assert_contains_make_command '', output[4]
@@ -29,12 +29,9 @@ class TestGemExtExtConfBuilder < Gem::TestCase
output = []
- Dir.chdir @ext do
- result =
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
- assert_same result, output
- end
assert_match(/^current directory:/, output[0])
assert_match(/^#{Gem.ruby}.* extconf.rb/, output[1])
@@ -59,9 +56,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
output = []
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
- end
assert_equal "creating Makefile\n", output[2]
assert_contains_make_command 'clean', output[4]
@@ -86,9 +81,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
output = []
assert_raises Gem::InstallError do
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
- end
end
assert_equal "creating Makefile\n", output[2]
@@ -112,9 +105,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
output = []
error = assert_raises Gem::InstallError do
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
- end
end
assert_equal 'extconf failed, exit code 1', error.message
@@ -139,9 +130,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
output = []
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
- end
refute_includes(output, "To see why this extension failed to compile, please check the mkmf.log which can be found here:\n")
@@ -181,9 +170,7 @@ end
output = []
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output
- end
assert_contains_make_command 'clean', output[4]
assert_contains_make_command '', output[7]
@@ -207,9 +194,7 @@ end
makefile.puts "install:"
end
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.make @ext, output
- end
assert_contains_make_command 'clean', output[1]
assert_contains_make_command '', output[4]
@@ -218,9 +203,7 @@ end
def test_class_make_no_Makefile
error = assert_raises Gem::InstallError do
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.make @ext, ['output']
- end
end
assert_equal 'Makefile not found', error.message
@@ -18,9 +18,7 @@ class TestGemExtRakeBuilder < Gem::TestCase
output = []
build_rake_in do |rake|
- Dir.chdir @ext do
- Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', @dest_path, output
- end
output = output.join "\n"
@@ -38,10 +36,8 @@ class TestGemExtRakeBuilder < Gem::TestCase
output = []
build_rake_in do |rake|
- Dir.chdir @ext do
- non_empty_args_list = ['']
- Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', @dest_path, output, non_empty_args_list
- end
output = output.join "\n"
@@ -55,9 +51,7 @@ class TestGemExtRakeBuilder < Gem::TestCase
output = []
build_rake_in do |rake|
- Dir.chdir @ext do
- Gem::Ext::RakeBuilder.build "ext/Rakefile", @dest_path, output, ["test1", "test2"]
- end
output = output.join "\n"
@@ -72,9 +66,7 @@ class TestGemExtRakeBuilder < Gem::TestCase
build_rake_in(false) do |rake|
error = assert_raises Gem::InstallError do
- Dir.chdir @ext do
- Gem::Ext::RakeBuilder.build "mkrf_conf.rb", @dest_path, output
- end
end
assert_match %r{^rake failed}, error.message
@@ -74,17 +74,18 @@ class TestGemGemRunner < Gem::TestCase
args = %w[query]
use_ui @ui do
- assert_nil @runner.run(args)
end
assert_match(/WARNING: query command is deprecated. It will be removed in Rubygems [0-9]+/, @ui.error)
end
def test_info_succeeds
args = %w[info]
use_ui @ui do
- assert_nil @runner.run(args)
end
assert_empty @ui.error
@@ -94,7 +95,7 @@ class TestGemGemRunner < Gem::TestCase
args = %w[list]
use_ui @ui do
- assert_nil @runner.run(args)
end
assert_empty @ui.error
@@ -104,7 +105,7 @@ class TestGemGemRunner < Gem::TestCase
args = %w[search]
use_ui @ui do
- assert_nil @runner.run(args)
end
assert_empty @ui.error
@@ -32,7 +32,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
def test_alternate_key_alternate_host
keys = {
:rubygems_api_key => 'KEY',
- "http://rubygems.engineyard.com" => "EYKEY"
}
FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path
@@ -202,7 +202,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @sign_in_ui.output
assert_match 'Code: ', @sign_in_ui.output
- assert_match 'Signed in.', @sign_in_ui.output
assert_equal '111111', @fetcher.last_request['OTP']
end
@@ -233,7 +233,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
@fetcher.data["#{host}/api/v1/api_key"] = response
Gem::RemoteFetcher.fetcher = @fetcher
- @sign_in_ui = Gem::MockGemUi.new("#{email}\n#{password}\n" + extra_input)
use_ui @sign_in_ui do
if args.length > 0
@@ -30,7 +30,7 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
args.concat %w[--vendor] unless Gem.java_platform?
- args.concat %w[-P HighSecurity] if defined?(OpenSSL::SSL)
assert @cmd.handles?(args)
end
@@ -92,7 +92,7 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
end
def test_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
@cmd.handle_options %w[-P HighSecurity]
@@ -100,7 +100,7 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
end
def test_security_policy_unknown
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
@cmd.add_install_update_options
@@ -192,4 +192,16 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
assert_equal true, @cmd.options[:post_install_message]
end
end
@@ -83,7 +83,7 @@ end
end
def test_check_executable_overwrite_default_bin_dir
- installer = setup_base_installer
bindir(Gem.bindir) do
util_conflict_executable false
@@ -143,7 +143,7 @@ gem 'other', version
end
def test_check_executable_overwrite_other_gem
- installer = setup_base_installer
util_conflict_executable true
@@ -287,7 +287,7 @@ gem 'other', version
end
def test_ensure_loadable_spec_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
_, a_gem = util_gem 'a', 2 do |s|
s.add_dependency 'garbage ~> 5'
@@ -345,7 +345,7 @@ gem 'other', version
options = {
:bin_dir => bin_dir,
- :install_dir => "/non/existent"
}
inst = Gem::Installer.at '', options
@@ -794,10 +794,35 @@ gem 'other', version
assert_equal spec, installer.install
- assert !File.exist?(system_path), 'plugin not written to user plugins_dir'
assert File.exist?(user_path), 'plugin not written to user plugins_dir'
end
def test_keeps_plugins_up_to_date
# NOTE: version a-2 is already installed by setup hooks
@@ -1134,7 +1159,7 @@ gem 'other', version
Gem::Package.build @spec
end
end
- installer = Gem::Installer.at @gem
build_rake_in do
use_ui @ui do
assert_equal @spec, installer.install
@@ -1156,6 +1181,15 @@ gem 'other', version
assert_path_exists gem_dir
end
def test_install_missing_dirs
installer = setup_base_installer
@@ -1337,7 +1371,7 @@ gem 'other', version
# reinstall the gem, this is also the same as pristine
use_ui @ui do
- installer = Gem::Installer.at path
installer.install
end
@@ -1537,6 +1571,7 @@ gem 'other', version
installer = setup_base_installer
@spec.add_dependency 'b', '> 5'
installer = util_setup_gem
use_ui @ui do
assert_raises Gem::InstallError do
@@ -1781,13 +1816,24 @@ gem 'other', version
def test_process_options_build_root
build_root = File.join @tempdir, 'build_root'
@gem = setup_base_gem
- installer = Gem::Installer.at @gem, :build_root => build_root
- assert_equal Pathname(build_root), installer.build_root
- assert_equal File.join(build_root, @gemhome, 'bin'), installer.bin_dir
- assert_equal File.join(build_root, @gemhome), installer.gem_home
end
def test_shebang_arguments
@@ -2169,6 +2215,23 @@ gem 'other', version
assert_equal ['exe/executable'], default_spec.files
end
def test_package_attribute
gem = quick_gem 'c' do |spec|
util_make_exec spec, '#!/usr/bin/ruby', 'exe'
@@ -95,7 +95,7 @@ class TestGemPackage < Gem::Package::TarTestCase
'SHA256' => {
'metadata.gz' => metadata_sha256,
'data.tar.gz' => Digest::SHA256.hexdigest(tar),
- }
}
assert_equal expected, YAML.load(checksums)
@@ -252,7 +252,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_build_auto_signed
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
FileUtils.mkdir_p File.join(Gem.user_home, '.gem')
@@ -295,7 +295,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_build_auto_signed_encrypted_key
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
FileUtils.mkdir_p File.join(Gem.user_home, '.gem')
@@ -364,7 +364,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_build_signed
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
spec = Gem::Specification.new 'build', '1'
spec.summary = 'build'
@@ -401,7 +401,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_build_signed_encrypted_key
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
spec = Gem::Specification.new 'build', '1'
spec.summary = 'build'
@@ -957,7 +957,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_verify_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
package = Gem::Package.new @gem
package.security_policy = Gem::Security::HighSecurity
@@ -974,7 +974,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_verify_security_policy_low_security
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
@spec.cert_chain = [PUBLIC_CERT.to_pem]
@spec.signing_key = PRIVATE_KEY
@@ -994,7 +994,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_verify_security_policy_checksum_missing
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
@spec.cert_chain = [PUBLIC_CERT.to_pem]
@spec.signing_key = PRIVATE_KEY
@@ -23,7 +23,7 @@ unless Gem.java_platform? # jruby can't require the simple_gem file
end
def test_contents_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
@package.security_policy = Gem::Security::AlmostNoSecurity
@@ -44,7 +44,7 @@ unless Gem.java_platform? # jruby can't require the simple_gem file
end
def test_extract_files_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
@package.security_policy = Gem::Security::AlmostNoSecurity
@@ -58,7 +58,7 @@ unless Gem.java_platform? # jruby can't require the simple_gem file
end
def test_spec_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
@package.security_policy = Gem::Security::AlmostNoSecurity
@@ -68,7 +68,7 @@ unless Gem.java_platform? # jruby can't require the simple_gem file
end
def test_verify
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
assert @package.verify
@@ -117,7 +117,7 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
end
def test_add_file_signer
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
signer = Gem::Security::Signer.new PRIVATE_KEY, [PUBLIC_CERT]
@@ -11,10 +11,69 @@ class TestGemPlatform < Gem::TestCase
end
def test_self_match
- assert Gem::Platform.match(nil), 'nil == ruby'
- assert Gem::Platform.match(Gem::Platform.local), 'exact match'
- assert Gem::Platform.match(Gem::Platform.local.to_s), '=~ match'
- assert Gem::Platform.match(Gem::Platform::RUBY), 'ruby'
end
def test_self_new
@@ -2,13 +2,9 @@
require 'rubygems/test_case'
require 'webrick'
-begin
- require 'webrick/https'
-rescue LoadError => e
- raise unless e.path == 'openssl'
-end
-unless defined?(OpenSSL::SSL)
warn 'Skipping Gem::RemoteFetcher tests. openssl not found.'
end
@@ -667,7 +663,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_config_creds
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass'}
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -679,7 +675,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_config_creds_with_region
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass', :region => 'us-west-2'}
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -691,7 +687,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_config_creds_with_token
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass', :security_token => 'testtoken'}
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -706,7 +702,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
ENV['AWS_SESSION_TOKEN'] = nil
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'env'}
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -722,7 +718,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
ENV['AWS_SESSION_TOKEN'] = nil
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'env', :region => 'us-west-2'}
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -738,7 +734,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
ENV['AWS_SESSION_TOKEN'] = 'testtoken'
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'env'}
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -758,7 +754,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_instance_profile_creds
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'instance_profile'}
}
url = 's3://my-bucket/gems/specs.4.8.gz'
@@ -772,7 +768,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_instance_profile_creds_with_region
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'instance_profile', :region => 'us-west-2'}
}
url = 's3://my-bucket/gems/specs.4.8.gz'
@@ -786,7 +782,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_instance_profile_creds_with_token
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'instance_profile'}
}
url = 's3://my-bucket/gems/specs.4.8.gz'
@@ -816,7 +812,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_no_host
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass'}
}
url = 's3://other-bucket/gems/specs.4.8.gz'
@@ -1062,7 +1058,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
:SSLCertificate => cert('ssl_cert.pem'),
:SSLPrivateKey => key('ssl_key.pem'),
:SSLVerifyClient => nil,
- :SSLCertName => nil
}.merge(config))
server.mount_proc("/yaml") do |req, res|
res.body = "--- true\n"
@@ -1145,4 +1141,4 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def key(filename)
OpenSSL::PKey::RSA.new(File.read(File.join(__dir__, filename)))
end
-end if defined?(OpenSSL::SSL)
@@ -4,7 +4,7 @@ require 'rubygems/request'
require 'ostruct'
require 'base64'
-unless defined?(OpenSSL::SSL)
warn 'Skipping Gem::Request tests. openssl not found.'
end
@@ -506,4 +506,4 @@ ERROR: Certificate is an invalid CA certificate
@response
end
end
-end if defined?(OpenSSL::SSL)
@@ -51,7 +51,7 @@ class TestGemRequestSetLockfile < Gem::TestCase
expected = [
'DEPENDENCIES',
' a',
- nil
]
assert_equal expected, out
@@ -78,7 +78,7 @@ class TestGemRequestSetLockfile < Gem::TestCase
expected = [
'DEPENDENCIES',
' a (~> 2.0)',
- nil
]
assert_equal expected, out
@@ -111,7 +111,7 @@ class TestGemRequestSetLockfile < Gem::TestCase
' a (2)',
' b',
' b (2)',
- nil
]
assert_equal expected, out
@@ -139,7 +139,7 @@ class TestGemRequestSetLockfile < Gem::TestCase
'PLATFORMS',
' ruby',
' x86-darwin-8',
- nil
]
assert_equal expected, out
@@ -39,7 +39,7 @@ class TestGemResolverAPISet < Gem::TestCase
{ :name => 'a',
:number => '1',
:platform => 'ruby',
- :dependencies => [], },
]
@fetcher.data["#{@dep_uri}?gems=a"] = Marshal.dump data
@@ -49,7 +49,7 @@ class TestGemResolverAPISet < Gem::TestCase
a_dep = @DR::DependencyRequest.new dep('a'), nil
expected = [
- @DR::APISpecification.new(set, data.first)
]
assert_equal expected, set.find_all(a_dep)
@@ -62,7 +62,7 @@ class TestGemResolverAPISet < Gem::TestCase
{ :name => 'a',
:number => '1',
:platform => 'ruby',
- :dependencies => [], },
]
@fetcher.data["#{@dep_uri}?gems=a"] = Marshal.dump data
@@ -74,7 +74,7 @@ class TestGemResolverAPISet < Gem::TestCase
set.prefetch [a_dep]
expected = [
- @DR::APISpecification.new(set, data.first)
]
assert_equal expected, set.find_all(a_dep)
@@ -114,7 +114,7 @@ class TestGemResolverAPISet < Gem::TestCase
{ :name => 'a',
:number => '1',
:platform => 'ruby',
- :dependencies => [], },
]
@fetcher.data["#{@dep_uri}?gems=a,b"] = Marshal.dump data
@@ -138,7 +138,7 @@ class TestGemResolverAPISet < Gem::TestCase
{ :name => 'a',
:number => '1',
:platform => 'ruby',
- :dependencies => [], },
]
@fetcher.data["#{@dep_uri}?gems=a"] = Marshal.dump data
@@ -163,7 +163,7 @@ class TestGemResolverAPISet < Gem::TestCase
{ :name => 'a',
:number => '1',
:platform => 'ruby',
- :dependencies => [], },
]
@fetcher.data["#{@dep_uri}?gems=a,b"] = Marshal.dump data
@@ -187,7 +187,7 @@ class TestGemResolverAPISet < Gem::TestCase
{ :name => 'a',
:number => '1',
:platform => 'ruby',
- :dependencies => [], },
]
@fetcher.data["#{@dep_uri}?gems=a,b"] = Marshal.dump data
@@ -73,7 +73,7 @@ class TestGemResolverConflict < Gem::TestCase
expected = [
'net-ssh (>= 2.0.13), 2.2.2 activated',
- 'rye (= 0.9.8), 0.9.8 activated'
]
assert_equal expected, conflict.request_path(child.requester)
@@ -51,7 +51,7 @@ class TestGemResolverVendorSet < Gem::TestCase
source = Gem::Source::Vendor.new directory
expected = [
- Gem::Resolver::VendorSpecification.new(@set, spec, source)
]
assert_equal expected, found
@@ -2,7 +2,7 @@
require 'rubygems/test_case'
require 'rubygems/security'
-unless defined?(OpenSSL::SSL)
warn 'Skipping Gem::Security tests. openssl not found.'
end
@@ -309,4 +309,4 @@ class TestGemSecurity < Gem::TestCase
assert_equal key.to_pem, key_from_file.to_pem
end
-end if defined?(OpenSSL::SSL) && !Gem.java_platform?
@@ -2,7 +2,7 @@
require 'rubygems/test_case'
-unless defined?(OpenSSL::SSL)
warn 'Skipping Gem::Security::Policy tests. openssl not found.'
end
@@ -532,4 +532,4 @@ class TestGemSecurityPolicy < Gem::TestCase
return digests, signatures
end
-end if defined?(OpenSSL::SSL)
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'rubygems/test_case'
-unless defined?(OpenSSL::SSL)
warn 'Skipping Gem::Security::Signer tests. openssl not found.'
end
@@ -214,4 +214,4 @@ toqvglr0kdbknSRRjBVLK6tsgr07aLT9gNP7mTW2PA==
signer.sign 'hello'
end
end
-end if defined?(OpenSSL::SSL)
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'rubygems/test_case'
-unless defined?(OpenSSL::SSL)
warn 'Skipping Gem::Security::TrustDir tests. openssl not found.'
end
@@ -95,4 +95,4 @@ class TestGemSecurityTrustDir < Gem::TestCase
assert_equal mask, File.stat(@dest_dir).mode unless win_platform?
end
-end if defined?(OpenSSL::SSL)
@@ -240,6 +240,11 @@ class TestGemSource < Gem::TestCase
refute rubygems_source.typo_squatting?("rubysertgems.org")
end
def test_typo_squatting_custom_distance_threshold
rubygems_source = Gem::Source.new("https://rubgems.org")
distance_threshold = 5
@@ -0,0 +1,49 @@
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require 'benchmark'
require 'rubygems/test_case'
require 'pathname'
require 'stringio'
require 'rubygems/ext'
@@ -1999,7 +2000,7 @@ dependencies: []
test_cases = {
'i386-mswin32' => 'a-1-x86-mswin32-60',
'i386-mswin32_80' => 'a-1-x86-mswin32-80',
- 'i386-mingw32' => 'a-1-x86-mingw32'
}
test_cases.each do |arch, expected|
@@ -3035,7 +3036,7 @@ Please report a bug if this causes problems.
specification.define_singleton_method(:find_all_by_name) do |dep_name|
[
specification.new {|s| s.name = "z", s.version = Gem::Version.new("1") },
- specification.new {|s| s.name = "z", s.version = Gem::Version.new("2") }
]
end
@@ -3578,7 +3579,7 @@ Did you mean 'Ruby'?
"one" => "two",
"home" => "three",
"homepage_uri" => "https://example.com/user/repo",
- "funding_uri" => "https://example.com/donate"
}
end
@@ -3838,7 +3839,7 @@ end
default_gem_spec = new_default_spec("default", "2.0.0.0",
nil, "default/gem.rb")
- spec_path = File.join(@default_spec_dir, default_gem_spec.spec_name)
write_file(spec_path) do |file|
file.print(default_gem_spec.to_ruby)
end
@@ -177,7 +177,7 @@ class TestGemUninstaller < Gem::InstallerTestCase
@spec.files += %w[lib/rubygems_plugin.rb]
- Gem::Installer.at(Gem::Package.build(@spec)).install
plugin_path = File.join Gem.plugindir, 'a_plugin.rb'
assert File.exist?(plugin_path), 'plugin not written'
@@ -194,7 +194,7 @@ class TestGemUninstaller < Gem::InstallerTestCase
@spec.files += %w[lib/rubygems_plugin.rb]
- Gem::Installer.at(Gem::Package.build(@spec)).install
plugin_path = File.join Gem.plugindir, 'a_plugin.rb'
assert File.exist?(plugin_path), 'plugin not written'
@@ -212,7 +212,7 @@ class TestGemUninstaller < Gem::InstallerTestCase
@spec.files += %w[lib/rubygems_plugin.rb]
- Gem::Installer.at(Gem::Package.build(@spec)).install
plugin_path = File.join Gem.plugindir, 'a_plugin.rb'
assert File.exist?(plugin_path), 'plugin not written'
@@ -314,7 +314,7 @@ create_makefile '#{@spec.name}'
use_ui @ui do
path = Gem::Package.build @spec
- installer = Gem::Installer.at path
installer.install
end
@@ -633,19 +633,19 @@ create_makefile '#{@spec.name}'
plugin_path = File.join Gem.plugindir, 'a_plugin.rb'
@spec.version = '1'
- Gem::Installer.at(Gem::Package.build(@spec)).install
refute File.exist?(plugin_path), 'version without plugin installed, but plugin written'
@spec.files += %w[lib/rubygems_plugin.rb]
@spec.version = '2'
- Gem::Installer.at(Gem::Package.build(@spec)).install
assert File.exist?(plugin_path), 'version with plugin installed, but plugin not written'
assert_match %r{\Arequire.*a-2/lib/rubygems_plugin\.rb}, File.read(plugin_path), 'written plugin has incorrect content'
@spec.version = '3'
- Gem::Installer.at(Gem::Package.build(@spec)).install
assert File.exist?(plugin_path), 'version with plugin installed, but plugin removed'
assert_match %r{\Arequire.*a-3/lib/rubygems_plugin\.rb}, File.read(plugin_path), 'old version installed, but plugin updated'
@@ -26,7 +26,7 @@ class TestGemValidator < Gem::TestCase
@spec.file_name => [
Gem::Validator::ErrorData.new('lib/b.rb', 'Missing file'),
Gem::Validator::ErrorData.new('lib/c.rb', 'Extra file'),
- ]
}
assert_equal expected, alien
@@ -56,7 +56,7 @@ class TestGemVersionOption < Gem::TestCase
@cmd.handle_options %w[--platform ruby]
expected = [
- Gem::Platform::RUBY
]
assert_equal expected, Gem.platforms
@@ -120,7 +120,7 @@ class TestGemRequire < Gem::TestCase
c1 = new_default_spec "c", "1", nil, "c/c.rb"
c2 = new_default_spec "c", "2", nil, "c/c.rb"
- install_default_specs c1, c2, b1, a1
dir = Dir.mktmpdir("test_require", @tempdir)
dash_i_arg = File.join dir, 'lib'
@@ -405,8 +405,8 @@ class TestGemRequire < Gem::TestCase
# Remove an old default gem version directly from disk as if someone ran
# gem cleanup.
- FileUtils.rm_rf(File.join @default_dir, "#{b1.full_name}")
- FileUtils.rm_rf(File.join @default_spec_dir, "#{b1.full_name}.gemspec")
# Require gems that have not been removed.
assert_require 'a/b'
@@ -433,7 +433,7 @@ class TestGemRequire < Gem::TestCase
def test_default_gem_only
default_gem_spec = new_default_spec("default", "2.0.0.0",
nil, "default/gem.rb")
- install_default_specs(default_gem_spec)
assert_require "default/gem"
assert_equal %w[default-2.0.0.0], loaded_spec_names
end
@@ -441,7 +441,7 @@ class TestGemRequire < Gem::TestCase
def test_default_gem_require_activates_just_once
default_gem_spec = new_default_spec("default", "2.0.0.0",
nil, "default/gem.rb")
- install_default_specs(default_gem_spec)
assert_require "default/gem"
@@ -506,7 +506,7 @@ class TestGemRequire < Gem::TestCase
def test_default_gem_and_normal_gem
default_gem_spec = new_default_spec("default", "2.0.0.0",
nil, "default/gem.rb")
- install_default_specs(default_gem_spec)
normal_gem_spec = util_spec("default", "3.0", nil,
"lib/default/gem.rb")
install_specs(normal_gem_spec)
@@ -544,11 +544,11 @@ class TestGemRequire < Gem::TestCase
def test_default_gem_prerelease
default_gem_spec = new_default_spec("default", "2.0.0",
nil, "default/gem.rb")
- install_default_specs(default_gem_spec)
normal_gem_higher_prerelease_spec = util_spec("default", "3.0.0.rc2", nil,
"lib/default/gem.rb")
- install_default_specs(normal_gem_higher_prerelease_spec)
assert_require "default/gem"
assert_equal %w[default-3.0.0.rc2], loaded_spec_names
@@ -586,7 +586,7 @@ class TestGemRequire < Gem::TestCase
def test_require_when_gem_defined
default_gem_spec = new_default_spec("default", "2.0.0.0",
nil, "default/gem.rb")
- install_default_specs(default_gem_spec)
c = Class.new do
def self.gem(*args)
raise "received #gem with #{args.inspect}"
@@ -677,6 +677,47 @@ class TestGemRequire < Gem::TestCase
end
end
end
end
private