summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_commands_query_command.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-17 22:04:18 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-17 22:04:18 +0000
commit9d4f37f51fb2ffdef5e318afb3cb81516dcba4f7 (patch)
tree2eb3c16c59259a25f5d9315edacc61dfc8c59d62 /test/rubygems/test_gem_commands_query_command.rb
parentf98e6b91dec68ddd010ccb3bad651a18e7dca338 (diff)
Update RubyGems to 1.1.1 r1778 (almost 1.2)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_commands_query_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_query_command.rb150
1 files changed, 113 insertions, 37 deletions
diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb
index 3c86c69a41..1b65fc7633 100644
--- a/test/rubygems/test_gem_commands_query_command.rb
+++ b/test/rubygems/test_gem_commands_query_command.rb
@@ -7,33 +7,18 @@ class TestGemCommandsQueryCommand < RubyGemTestCase
def setup
super
- util_make_gems
-
- @a2.summary = 'This is a lot of text. ' * 4
-
@cmd = Gem::Commands::QueryCommand.new
- @si = util_setup_source_info_cache @a1, @a2, @pl1
util_setup_fake_fetcher
- @fetcher.data["#{@gem_repo}/Marshal.#{Gem.marshal_version}"] = proc do
+ @si = util_setup_spec_fetcher @a1, @a2, @pl1
+
+ @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
raise Gem::RemoteFetcher::FetchError
end
end
def test_execute
- cache = Gem::SourceInfoCache.cache
- cache.update
- cache.write_cache
- cache.reset_cache_data
- Gem::SourceInfoCache.reset
-
- a2_name = @a2.full_name
- @fetcher.data["#{@gem_repo}/quick/latest_index.rz"] = util_zip a2_name
- @fetcher.data["#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{a2_name}.gemspec.rz"] = util_zip Marshal.dump(@a2)
- @fetcher.data["#{@gem_repo}/Marshal.#{Gem.marshal_version}"] =
- Marshal.dump @si
-
@cmd.handle_options %w[-r]
use_ui @ui do
@@ -44,10 +29,8 @@ class TestGemCommandsQueryCommand < RubyGemTestCase
*** REMOTE GEMS ***
-Updating metadata for 1 gems from http://gems.example.com/
-.
-complete
a (2)
+pl (1)
EOF
assert_equal expected, @ui.output
@@ -55,21 +38,8 @@ a (2)
end
def test_execute_all
- cache = Gem::SourceInfoCache.cache
- cache.update
- cache.write_cache
- cache.reset_cache_data
- Gem::SourceInfoCache.reset
-
a1_name = @a1.full_name
a2_name = @a2.full_name
- @fetcher.data["#{@gem_repo}/quick/index.rz"] =
- util_zip [a1_name, a2_name].join("\n")
- @fetcher.data["#{@gem_repo}/quick/latest_index.rz"] = util_zip a2_name
- @fetcher.data["#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{a1_name}.gemspec.rz"] = util_zip Marshal.dump(@a1)
- @fetcher.data["#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{a2_name}.gemspec.rz"] = util_zip Marshal.dump(@a2)
- @fetcher.data["#{@gem_repo}/Marshal.#{Gem.marshal_version}"] =
- Marshal.dump @si
@cmd.handle_options %w[-r --all]
@@ -81,10 +51,8 @@ a (2)
*** REMOTE GEMS ***
-Updating metadata for 2 gems from http://gems.example.com/
-..
-complete
a (2, 1)
+pl (1)
EOF
assert_equal expected, @ui.output
@@ -92,6 +60,13 @@ a (2, 1)
end
def test_execute_details
+ @a2.summary = 'This is a lot of text. ' * 4
+ @a2.authors = ['Abraham Lincoln', 'Hirohito']
+ @a2.homepage = 'http://a.example.com/'
+ @a2.rubyforge_project = 'rubygems'
+
+ @si = util_setup_spec_fetcher @a1, @a2, @pl1
+
@cmd.handle_options %w[-r -d]
use_ui @ui do
@@ -103,10 +78,17 @@ a (2, 1)
*** REMOTE GEMS ***
a (2)
+ Authors: Abraham Lincoln, Hirohito
+ Rubyforge: http://rubyforge.org/projects/rubygems
+ Homepage: http://a.example.com/
+
This is a lot of text. This is a lot of text. This is a lot of text.
This is a lot of text.
pl (1)
+ Author: A User
+ Homepage: http://example.com
+
this is a summary
EOF
@@ -126,6 +108,7 @@ pl (1)
assert_equal 0, e.exit_code
assert_equal "true\n", @ui.output
+
assert_equal '', @ui.error
end
@@ -189,6 +172,99 @@ pl (1)
assert_equal 1, e.exit_code
end
+ def test_execute_legacy
+ Gem::SpecFetcher.fetcher = nil
+ si = util_setup_source_info_cache @a1, @a2, @pl1
+
+ @fetcher.data["#{@gem_repo}yaml"] = YAML.dump si
+ @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] =
+ si.dump
+
+ @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil
+
+ @cmd.handle_options %w[-r]
+
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ expected = <<-EOF
+
+*** REMOTE GEMS ***
+
+a (2)
+pl (1)
+ EOF
+
+ assert_equal expected, @ui.output
+
+ expected = <<-EOF
+WARNING: RubyGems 1.2+ index not found for:
+\t#{@gem_repo}
+
+RubyGems will revert to legacy indexes degrading performance.
+ EOF
+
+ assert_equal expected, @ui.error
+ end
+
+ def test_execute_local_details
+ @a2.summary = 'This is a lot of text. ' * 4
+ @a2.authors = ['Abraham Lincoln', 'Hirohito']
+ @a2.homepage = 'http://a.example.com/'
+ @a2.rubyforge_project = 'rubygems'
+
+ @cmd.handle_options %w[--local --details]
+
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ expected = <<-EOF
+
+*** LOCAL GEMS ***
+
+a (2, 1)
+ Author: A User
+ Homepage: http://example.com
+ Installed at (2): #{@gemhome}
+ (1): #{@gemhome}
+
+ this is a summary
+
+a_evil (9)
+ Author: A User
+ Homepage: http://example.com
+ Installed at: #{@gemhome}
+
+ this is a summary
+
+b (2)
+ Author: A User
+ Homepage: http://example.com
+ Installed at: #{@gemhome}
+
+ this is a summary
+
+c (1.2)
+ Author: A User
+ Homepage: http://example.com
+ Installed at: #{@gemhome}
+
+ this is a summary
+
+pl (1)
+ Author: A User
+ Homepage: http://example.com
+ Installed at: #{@gemhome}
+
+ this is a summary
+ EOF
+
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
+ end
+
def test_execute_no_versions
@cmd.handle_options %w[-r --no-versions]