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_mirror_command.rb
nobu b551e8c8b3 * lib/rubygems: update to 1.3.6.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-22 02:52:35 +00:00

60 lines
1.5 KiB
Ruby

require_relative 'gemutilities'
require 'rubygems/indexer'
require 'rubygems/commands/mirror_command'
class TestGemCommandsMirrorCommand < RubyGemTestCase
def setup
super
@cmd = Gem::Commands::MirrorCommand.new
end
def test_execute
util_make_gems
gems_dir = File.join @tempdir, 'gems'
mirror = File.join @tempdir, 'mirror'
FileUtils.mkdir_p gems_dir
FileUtils.mkdir_p mirror
Dir[File.join(@gemhome, 'cache', '*.gem')].each do |gem|
FileUtils.mv gem, gems_dir
end
use_ui @ui do
Gem::Indexer.new(@tempdir).generate_index
end
orig_HOME = ENV['HOME']
ENV['HOME'] = @tempdir
Gem.instance_variable_set :@user_home, nil
File.open File.join(Gem.user_home, '.gemmirrorrc'), 'w' do |fp|
fp.puts "---"
# tempdir could be a drive+path (under windows)
if @tempdir.match(/[a-z]:/i)
fp.puts "- from: file:///#{@tempdir}"
else
fp.puts "- from: file://#{@tempdir}"
end
fp.puts " to: #{mirror}"
end
use_ui @ui do
@cmd.execute
end
assert File.exist?(File.join(mirror, 'gems', @a1.file_name))
assert File.exist?(File.join(mirror, 'gems', @a2.file_name))
assert File.exist?(File.join(mirror, 'gems', @b2.file_name))
assert File.exist?(File.join(mirror, 'gems', @c1_2.file_name))
assert File.exist?(File.join(mirror, "Marshal.#{@marshal_version}"))
ensure
orig_HOME.nil? ? ENV.delete('HOME') : ENV['HOME'] = orig_HOME
Gem.instance_variable_set :@user_home, nil
end
end if ''.respond_to? :to_xs