unit_test (Gem::Validator)

    # File lib/rubygems/validator.rb, line 201
      def unit_test(gem_spec)
        start_dir = Dir.pwd
        Dir.chdir(gem_spec.full_gem_path)
        $: << gem_spec.full_gem_path
        # XXX: why do we need this gem_spec when we've already got 'spec'?
        test_files = gem_spec.test_files

        if test_files.empty? then
          say "There are no unit tests to run for #{gem_spec.full_name}"
          return nil
        end

        gem gem_spec.name, "= #{gem_spec.version.version}"

        test_files.each do |f| require f end

        if RUBY_VERSION < '1.9' then
          suite = Test::Unit::TestSuite.new("#{gem_spec.name}-#{gem_spec.version}")

          ObjectSpace.each_object(Class) do |klass|
            suite << klass.suite if (klass < Test::Unit::TestCase)
          end

          result = TestRunner.run suite, ui

          alert_error result.to_s unless result.passed?
        else
          result = MiniTest::Unit.new
          result.run
        end

        result
      ensure
        Dir.chdir(start_dir)
      end