summaryrefslogtreecommitdiff
path: root/lib/rubygems/test_utilities.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/test_utilities.rb')
-rw-r--r--lib/rubygems/test_utilities.rb36
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index 25786e6a21..6789f6efc5 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -186,7 +186,6 @@ end
# f.gem 'a', 1
# f.spec 'a', 2
# f.gem 'b', 1' 'a' => '~> 1.0'
-# f.clear
# end
#
# The above declaration creates two gems, a-1 and b-1, with a dependency from
@@ -214,19 +213,12 @@ class Gem::TestCase::SpecFetcherSetup
@repository = repository
@gems = {}
+ @downloaded = []
@installed = []
@operations = []
end
##
- # Removes any created gems or specifications from Gem.dir (the default
- # install location).
-
- def clear
- @operations << [:clear]
- end
-
- ##
# Returns a Hash of created Specification full names and the corresponding
# Specification.
@@ -254,9 +246,6 @@ class Gem::TestCase::SpecFetcherSetup
def execute_operations # :nodoc:
@operations.each do |operation, *arguments|
case operation
- when :clear then
- @test.util_clear_gems
- @installed.clear
when :gem then
spec, gem = @test.util_gem(*arguments, &arguments.pop)
@@ -264,6 +253,11 @@ class Gem::TestCase::SpecFetcherSetup
@gems[spec] = gem
@installed << spec
+ when :download then
+ spec, gem = @test.util_gem(*arguments, &arguments.pop)
+
+ @gems[spec] = gem
+ @downloaded << spec
when :spec then
spec = @test.util_spec(*arguments, &arguments.pop)
@@ -287,6 +281,17 @@ class Gem::TestCase::SpecFetcherSetup
end
##
+ # Creates a gem with +name+, +version+ and +deps+. The created gem is
+ # downloaded in to the cache directory but is not installed
+ #
+ # The specification will be yielded before gem creation for customization,
+ # but only the block or the dependencies may be set, not both.
+
+ def download name, version, dependencies = nil, &block
+ @operations << [:download, name, version, dependencies, block]
+ end
+
+ ##
# Creates a legacy platform spec with the name 'pl' and version 1
def legacy_platform
@@ -312,17 +317,12 @@ class Gem::TestCase::SpecFetcherSetup
gem_repo, @test.gem_repo = @test.gem_repo, @repository
@test.uri = URI @repository
- @test.util_setup_spec_fetcher(*@gems.keys)
+ @test.util_setup_spec_fetcher(*@downloaded)
ensure
@test.gem_repo = gem_repo
@test.uri = URI gem_repo
end
- # This works around util_setup_spec_fetcher adding all created gems to the
- # installed set.
- Gem::Specification.reset
- Gem::Specification.add_specs(*@installed)
-
@gems.each do |spec, gem|
next unless gem