summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_commands_update_command.rb
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 03:45:05 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 03:45:05 +0000
commitd22130922e7842226d38d59680e4bbb48a28a5f0 (patch)
tree39594d3a14641dd5488a99a5e633239296fa5742 /test/rubygems/test_gem_commands_update_command.rb
parent4752539e3f3e563d559732c52424206bd6f12dbd (diff)
Import rubygems 1.8.5 (released @ 137c80f)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_commands_update_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_update_command.rb69
1 files changed, 45 insertions, 24 deletions
diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb
index 24966a3a84..b43be11843 100644
--- a/test/rubygems/test_gem_commands_update_command.rb
+++ b/test/rubygems/test_gem_commands_update_command.rb
@@ -24,15 +24,15 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
@cmd.options[:generate_ri] = false
util_setup_fake_fetcher
-
- @a1_path = Gem.cache_gem(@a1.file_name, @gemhome)
- @a2_path = Gem.cache_gem(@a2.file_name, @gemhome)
-
+ util_clear_gems
util_setup_spec_fetcher @a1, @a2
- @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
+ @a1_path = @a1.cache_file
+ @a2_path = @a2.cache_file
+
+ @fetcher.data["#{@gem_repo}gems/#{File.basename @a1_path}"] =
read_binary @a1_path
- @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
+ @fetcher.data["#{@gem_repo}gems/#{File.basename @a2_path}"] =
read_binary @a2_path
end
@@ -81,18 +81,19 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
def util_add_to_fetcher *specs
specs.each do |spec|
- gem_file = Gem.cache_gem(spec.file_name, @gemhome)
+ gem_file = spec.cache_file
+ file_name = File.basename gem_file
- @fetcher.data["http://gems.example.com/gems/#{spec.file_name}"] =
+ @fetcher.data["http://gems.example.com/gems/#{file_name}"] =
Gem.read_binary gem_file
end
end
def test_execute_system
+ util_clear_gems
util_setup_rubygem9
util_setup_spec_fetcher @rubygem9
util_add_to_fetcher @rubygem9
- util_clear_gems
@cmd.options[:args] = []
@cmd.options[:system] = true
@@ -113,17 +114,17 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
end
def test_execute_system_at_latest
+ util_clear_gems
util_setup_rubygem_current
util_setup_spec_fetcher @rubygem_current
util_add_to_fetcher @rubygem_current
- util_clear_gems
@cmd.options[:args] = []
@cmd.options[:system] = true
@cmd.options[:generate_rdoc] = false
@cmd.options[:generate_ri] = false
- assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException do
use_ui @ui do
@cmd.execute
end
@@ -135,11 +136,11 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
end
def test_execute_system_multiple
+ util_clear_gems
util_setup_rubygem9
util_setup_rubygem8
util_setup_spec_fetcher @rubygem8, @rubygem9
util_add_to_fetcher @rubygem8, @rubygem9
- util_clear_gems
@cmd.options[:args] = []
@cmd.options[:system] = true
@@ -184,6 +185,31 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
assert_empty out
end
+ def test_execute_system_specifically_to_latest_version
+ util_clear_gems
+ util_setup_rubygem9
+ util_setup_rubygem8
+ util_setup_spec_fetcher @rubygem8, @rubygem9
+ util_add_to_fetcher @rubygem8, @rubygem9
+
+ @cmd.options[:args] = []
+ @cmd.options[:system] = "9"
+ @cmd.options[:generate_rdoc] = false
+ @cmd.options[:generate_ri] = false
+
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ out = @ui.output.split "\n"
+ assert_equal "Updating rubygems-update", out.shift
+ assert_equal "Successfully installed rubygems-update-9", out.shift
+ assert_equal "Installing RubyGems 9", out.shift
+ assert_equal "RubyGems system software updated", out.shift
+
+ assert_empty out
+ end
+
def test_execute_system_with_gems
@cmd.options[:args] = %w[gem]
@cmd.options[:system] = true
@@ -218,16 +244,11 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
@a2.add_dependency 'c', '2'
@a2.add_dependency 'b', '2'
- @b2_path = Gem.cache_gem(@b2.file_name, @gemhome)
- @c1_2_path = Gem.cache_gem(@c1_2.file_name, @gemhome)
- @c2_path = Gem.cache_gem(@c2.file_name, @gemhome)
+ @b2_path = @b2.cache_file
+ @c1_2_path = @c1_2.cache_file
+ @c2_path = @c2.cache_file
- @source_index = Gem::SourceIndex.new
- @source_index.add_spec @a1
- @source_index.add_spec @a2
- @source_index.add_spec @b2
- @source_index.add_spec @c1_2
- @source_index.add_spec @c2
+ install_specs @a1, @a2, @b2, @c1_2, @c2
util_build_gem @a1
util_build_gem @a2
@@ -236,16 +257,16 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
@fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = read_binary @a1_path
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = read_binary @a2_path
@fetcher.data["#{@gem_repo}gems/#{@b2.file_name}"] = read_binary @b2_path
- @fetcher.data["#{@gem_repo}gems/#{@c1_2.file_name}"] =
- read_binary @c1_2_path
+ @fetcher.data["#{@gem_repo}gems/#{@c1_2.file_name}"] = read_binary @c1_2_path
@fetcher.data["#{@gem_repo}gems/#{@c2.file_name}"] = read_binary @c2_path
util_setup_spec_fetcher @a1, @a2, @b2, @c1_2, @c2
- util_clear_gems
Gem::Installer.new(@c1_2_path).install
Gem::Installer.new(@a1_path).install
+ Gem::Specification.reset
+
@cmd.options[:args] = []
use_ui @ui do