def setup_gem_source
@source_path = Dir.mktmpdir("test_gem_source_path_#{$$}")
Dir.mkdir gemdir = File.join(@source_path, 'gems')
@source_working = working = Dir.mktmpdir("test_gem_source_#{$$}")
Dir.mkdir File.join(working, 'lib')
gemspecs = %w[a b c].map do |name|
FileUtils.touch File.join(working, 'lib', "#{name}.rb")
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = name
s.version = 1.0
s.author = 'rubygems'
s.email = 'example@example.com'
s.homepage = 'http://example.com'
s.has_rdoc = false
s.description = 'desc'
s.summary = "summ"
s.require_paths = %w[lib]
s.files = ??[lib/
s.rubyforge_project = 'rubygems'
end
end
gemspecs.each do |spec|
path = File.join(working, "#{spec.name}.gemspec")
open(path, 'w') do |io|
io.write(spec.to_ruby)
end
Dir.chdir(working) do
gem_file = Gem::Builder.new(spec).build
FileUtils.mv(gem_file, File.join(@source_path, 'gems', gem_file))
end
end
@source_gems = Dir[File.join(gemdir, '*.gem')].map {|p|File.basename(p)}
Gem::Indexer.new(@source_path).generate_index
end