summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_commands_fetch_command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems/test_gem_commands_fetch_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_fetch_command.rb91
1 files changed, 43 insertions, 48 deletions
diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb
index 364881a..c452e79 100644
--- a/test/rubygems/test_gem_commands_fetch_command.rb
+++ b/test/rubygems/test_gem_commands_fetch_command.rb
@@ -12,15 +12,13 @@ class TestGemCommandsFetchCommand < Gem::TestCase
end
def test_execute
- util_setup_fake_fetcher
- util_setup_spec_fetcher @a2
-
- @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
- File.read(@a2.cache_file)
+ specs = spec_fetcher do |fetcher|
+ fetcher.gem 'a', 2
+ end
refute_path_exists File.join(@tempdir, 'cache'), 'sanity check'
- @cmd.options[:args] = [@a2.name]
+ @cmd.options[:args] = %w[a]
use_ui @ui do
Dir.chdir @tempdir do
@@ -28,24 +26,23 @@ class TestGemCommandsFetchCommand < Gem::TestCase
end
end
- assert_path_exists(File.join(@tempdir, @a2.file_name),
- "#{@a2.full_name} not fetched")
+ a2 = specs['a-2']
+
+ assert_path_exists(File.join(@tempdir, a2.file_name),
+ "#{a2.full_name} not fetched")
refute_path_exists File.join(@tempdir, 'cache'),
'gem repository directories must not be created'
end
def test_execute_latest
- util_setup_fake_fetcher
- util_setup_spec_fetcher @a1, @a2
-
- @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
- File.read(@a1.cache_file)
- @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
- File.read(@a2.cache_file)
+ specs = spec_fetcher do |fetcher|
+ fetcher.gem 'a', 1
+ fetcher.gem 'a', 2
+ end
refute_path_exists File.join(@tempdir, 'cache'), 'sanity check'
- @cmd.options[:args] = [@a2.name]
+ @cmd.options[:args] = %w[a]
@cmd.options[:version] = req('>= 0.1')
use_ui @ui do
@@ -54,23 +51,20 @@ class TestGemCommandsFetchCommand < Gem::TestCase
end
end
- assert_path_exists(File.join(@tempdir, @a2.file_name),
- "#{@a2.full_name} not fetched")
+ a2 = specs['a-2']
+ assert_path_exists(File.join(@tempdir, a2.file_name),
+ "#{a2.full_name} not fetched")
refute_path_exists File.join(@tempdir, 'cache'),
'gem repository directories must not be created'
end
def test_execute_prerelease
- util_setup_fake_fetcher true
- util_clear_gems
- util_setup_spec_fetcher @a2, @a2_pre
-
- @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
- File.read(@a2.cache_file)
- @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
- File.read(@a2_pre.cache_file)
+ specs = spec_fetcher do |fetcher|
+ fetcher.gem 'a', 2
+ fetcher.gem 'a', '2.a'
+ end
- @cmd.options[:args] = [@a2.name]
+ @cmd.options[:args] = %w[a]
@cmd.options[:prerelease] = true
use_ui @ui do
@@ -79,21 +73,19 @@ class TestGemCommandsFetchCommand < Gem::TestCase
end
end
- assert_path_exists(File.join(@tempdir, @a2.file_name),
- "#{@a2.full_name} not fetched")
+ a2 = specs['a-2']
+
+ assert_path_exists(File.join(@tempdir, a2.file_name),
+ "#{a2.full_name} not fetched")
end
def test_execute_specific_prerelease
- util_setup_fake_fetcher true
- util_clear_gems
- util_setup_spec_fetcher @a2, @a2_pre
-
- @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
- File.read(@a2.cache_file)
- @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
- File.read(@a2_pre.cache_file)
+ specs = spec_fetcher do |fetcher|
+ fetcher.gem 'a', 2
+ fetcher.gem 'a', '2.a'
+ end
- @cmd.options[:args] = [@a2.name]
+ @cmd.options[:args] = %w[a]
@cmd.options[:prerelease] = true
@cmd.options[:version] = "2.a"
@@ -103,18 +95,19 @@ class TestGemCommandsFetchCommand < Gem::TestCase
end
end
- assert_path_exists(File.join(@tempdir, @a2_pre.file_name),
- "#{@a2_pre.full_name} not fetched")
+ a2_pre = specs['a-2.a']
+
+ assert_path_exists(File.join(@tempdir, a2_pre.file_name),
+ "#{a2_pre.full_name} not fetched")
end
def test_execute_version
- util_setup_fake_fetcher
- util_setup_spec_fetcher @a1, @a2
-
- @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
- File.read(@a1.cache_file)
+ specs = spec_fetcher do |fetcher|
+ fetcher.gem 'a', 1
+ fetcher.gem 'a', 2
+ end
- @cmd.options[:args] = [@a2.name]
+ @cmd.options[:args] = %w[a]
@cmd.options[:version] = Gem::Requirement.new '1'
use_ui @ui do
@@ -123,8 +116,10 @@ class TestGemCommandsFetchCommand < Gem::TestCase
end
end
- assert_path_exists(File.join(@tempdir, @a1.file_name),
- "#{@a1.full_name} not fetched")
+ a1 = specs['a-1']
+
+ assert_path_exists(File.join(@tempdir, a1.file_name),
+ "#{a1.full_name} not fetched")
end
end