1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rubygems/test_gem_commands_setup_command.rb
drbrain 10c5d6ee25 * lib/rubygems/commands/setup_command.rb: Don't delete non-rubygems
files when installing RubyGems.
* test/rubygems/test_gem_commands_setup_command.rb:  Test for the
  above.

* lib/rubygems/ext/ext_conf_builder.rb:  Use full path to siteconf.rb
  in case the extconf.rb changes directories (like memcached does).

* lib/rubygems/package.rb:  Remove double slash from path.
* test/rubygems/test_gem_package.rb:  Test for the above.
* test/rubygems/test_gem_package_old.rb:  ditto.

* lib/rubygems/source.rb:  Revert automatic HTTPS upgrade
* lib/rubygems/spec_fetcher.rb:  ditto.
* test/rubygems/test_gem_remote_fetcher.rb:  ditto.
* test/rubygems/test_gem_source.rb:  ditto.
* test/rubygems/test_gem_spec_fetcher.rb:  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-11 21:29:32 +00:00

77 lines
2.3 KiB
Ruby

require 'rubygems/test_case'
require 'rubygems/commands/setup_command'
class TestGemCommandsSetupCommand < Gem::TestCase
def setup
super
@install_dir = File.join @tempdir, 'install'
@cmd = Gem::Commands::SetupCommand.new
@cmd.options[:prefix] = @install_dir
FileUtils.mkdir_p 'bin'
FileUtils.mkdir_p 'lib/rubygems/ssl_certs'
open 'bin/gem', 'w' do |io| io.puts '# gem' end
open 'lib/rubygems.rb', 'w' do |io| io.puts '# rubygems.rb' end
open 'lib/rubygems/test_case.rb', 'w' do |io| io.puts '# test_case.rb' end
open 'lib/rubygems/ssl_certs/foo.pem', 'w' do |io| io.puts 'PEM' end
end
def test_pem_files_in
assert_equal %w[rubygems/ssl_certs/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_install_lib
@cmd.extend FileUtils
Dir.mktmpdir 'lib' do |dir|
@cmd.install_lib dir
assert_path_exists File.join(dir, 'rubygems.rb')
assert_path_exists File.join(dir, 'rubygems/ssl_certs/foo.pem')
end
end
def test_remove_old_lib_files
lib = File.join @install_dir, 'lib'
lib_rubygems = File.join lib, 'rubygems'
lib_rubygems_defaults = File.join lib_rubygems, 'defaults'
securerandom_rb = File.join lib, 'securerandom.rb'
engine_defaults_rb = File.join lib_rubygems_defaults, 'jruby.rb'
os_defaults_rb = File.join lib_rubygems_defaults, 'operating_system.rb'
old_builder_rb = File.join lib_rubygems, 'builder.rb'
old_format_rb = File.join lib_rubygems, 'format.rb'
FileUtils.mkdir_p lib_rubygems_defaults
open securerandom_rb, 'w' do |io| io.puts '# securerandom.rb' end
open old_builder_rb, 'w' do |io| io.puts '# builder.rb' end
open old_format_rb, 'w' do |io| io.puts '# format.rb' end
open engine_defaults_rb, 'w' do |io| io.puts '# jruby.rb' end
open os_defaults_rb, 'w' do |io| io.puts '# operating_system.rb' end
@cmd.remove_old_lib_files lib
refute_path_exists old_builder_rb
refute_path_exists old_format_rb
assert_path_exists securerandom_rb
assert_path_exists engine_defaults_rb
assert_path_exists os_defaults_rb
end
end