summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
-rw-r--r--lib/rdoc/rubygems_hook.rb4
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/source.rb2
-rw-r--r--lib/rubygems/specification.rb2
-rw-r--r--lib/rubygems/test_case.rb120
-rw-r--r--lib/rubygems/test_utilities.rb158
6 files changed, 212 insertions, 76 deletions
@@ -156,6 +156,10 @@ class RDoc::RubygemsHook
args.concat @spec.require_paths
args.concat @spec.extra_rdoc_files
case config_args = Gem.configuration[:rdoc]
when String then
args = args.concat config_args.split
@@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
- VERSION = '2.2.0.preview.2'
end
# Must be first since it unloads the prelude from 1.9.2
@@ -56,8 +56,6 @@ class Gem::Source
# Returns a Set that can fetch specifications from this source.
def dependency_resolver_set # :nodoc:
- uri = api_uri
-
bundler_api_uri = api_uri + './api/v1/dependencies'
begin
@@ -1393,7 +1393,7 @@ class Gem::Specification < Gem::BasicSpecification
# Returns the build_args used to install the gem
def build_args
- if File.exists? build_info_file
File.readlines(build_info_file).map { |x| x.strip }
else
[]
@@ -30,7 +30,6 @@ require 'fileutils'
require 'tmpdir'
require 'uri'
require 'rubygems/package'
-require 'rubygems/test_utilities'
require 'pp'
require 'zlib'
require 'pathname'
@@ -84,6 +83,8 @@ end
class Gem::TestCase < MiniTest::Unit::TestCase
def assert_activate expected, *specs
specs.each do |spec|
case spec
@@ -197,7 +198,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
@orig_gem_path = ENV['GEM_PATH']
@current_dir = Dir.pwd
- @ui = Gem::MockGemUi.new
tmpdir = File.expand_path Dir.tmpdir
tmpdir.untaint
@@ -378,7 +380,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
gem = File.join @tempdir, "gems", "#{spec.full_name}.gem"
- unless File.exists? gem
use_ui Gem::MockGemUi.new do
Dir.chdir @tempdir do
Gem::Package.build spec
@@ -503,28 +505,11 @@ class Gem::TestCase < MiniTest::Unit::TestCase
return spec
end
- def quick_spec name, version = '2'
- # TODO: deprecate
- require 'rubygems/specification'
-
- spec = Gem::Specification.new do |s|
- s.platform = Gem::Platform::RUBY
- s.name = name
- s.version = version
- s.author = 'A User'
- s.email = '[email protected]'
- s.homepage = 'http://example.com'
- s.summary = "this is a summary"
- s.description = "This is a test description"
-
- yield(s) if block_given?
- end
-
- spec.loaded_from = spec.spec_file
-
- Gem::Specification.add_spec spec
- return spec
end
##
@@ -561,7 +546,9 @@ class Gem::TestCase < MiniTest::Unit::TestCase
def util_clear_gems
FileUtils.rm_rf File.join(@gemhome, "gems") # TODO: use Gem::Dirs
FileUtils.rm_rf File.join(@gemhome, "specifications")
Gem::Specification.reset
end
@@ -612,10 +599,11 @@ class Gem::TestCase < MiniTest::Unit::TestCase
end
##
- # Create a new spec (or gem if passed an array of files) and set it
- # up properly. Use this instead of util_spec and util_gem.
- def new_spec name, version, deps = nil, *files
require 'rubygems/specification'
spec = Gem::Specification.new do |s|
@@ -656,7 +644,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
end
def new_default_spec(name, version, deps = nil, *files)
- spec = new_spec(name, version, deps)
spec.loaded_from = File.join(@default_spec_dir, spec.spec_name)
spec.files = files
@@ -674,24 +663,38 @@ class Gem::TestCase < MiniTest::Unit::TestCase
end
##
- # Creates a spec with +name+, +version+ and +deps+.
- def util_spec(name, version, deps = nil, &block)
- # TODO: deprecate
- raise "deps or block, not both" if deps and block
if deps then
- block = proc do |s|
- # Since Hash#each is unordered in 1.8, sort
- # the keys and iterate that way so the tests are
- # deteriminstic on all implementations.
- deps.keys.sort.each do |n|
- s.add_dependency n, (deps[n] || '>= 0')
- end
end
end
- quick_spec(name, version, &block)
end
##
@@ -1132,38 +1135,8 @@ Also, a list:
# end
def spec_fetcher
- gems = {}
-
- fetcher = Object.new
- fetcher.instance_variable_set :@test, self
- fetcher.instance_variable_set :@gems, gems
-
- def fetcher.gem name, version, dependencies = nil, &block
- spec, gem = @test.util_gem name, version, dependencies, &block
-
- @gems[spec] = gem
-
- spec
- end
-
- def fetcher.spec name, version, dependencies = nil, &block
- spec = @test.util_spec name, version, dependencies, &block
-
- @gems[spec] = nil
-
- spec
- end
-
- yield fetcher
-
- util_setup_fake_fetcher unless @fetcher
- util_setup_spec_fetcher(*gems.keys)
-
- gems.each do |spec, gem|
- next unless gem
-
- @fetcher.data["http://gems.example.com/gems/#{spec.file_name}"] =
- Gem.read_binary(gem)
end
end
@@ -1318,3 +1291,6 @@ Also, a list:
end if defined?(OpenSSL::SSL)
end
@@ -160,6 +160,164 @@ end
# :startdoc:
##
# A StringIO duck-typed class that uses Tempfile instead of String as the
# backing store.
#