class Gem::TestCase

def install_gem spec, options = {}

def install_gem spec, options = {}
  require 'rubygems/installer'
  gem = File.join @tempdir, "gems", "#{spec.full_name}.gem"
  unless File.exist? gem then
    use_ui Gem::MockGemUi.new do
      Dir.chdir @tempdir do
        Gem::Package.build spec
      end
    end
    gem = File.join(@tempdir, File.basename(spec.cache_file)).untaint
  end
  Gem::Installer.at(gem, options.merge({:wrappers => true})).install
end