diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-08 22:41:03 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-08 22:41:03 +0000 |
commit | 7083cebeaea83096128fc5ccb5f60bfbe5bcc939 (patch) | |
tree | fb25c12a6cc01a1a8de5221d64da632418e194a3 /test/rubygems | |
parent | fa343a796fd256fc9098db7fdddf226fe5cbd181 (diff) | |
download | ruby-7083cebeaea83096128fc5ccb5f60bfbe5bcc939.tar.gz |
* lib/rubygems: Update to RubyGems 2.0.4. See
https://github.com/rubygems/rubygems/blob/2.0/History.txt for changes
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems')
-rw-r--r-- | test/rubygems/test_gem.rb | 6 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_help_command.rb | 5 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_owner_command.rb | 12 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_push_command.rb | 16 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_search_command.rb | 25 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_setup_command.rb | 52 | ||||
-rw-r--r-- | test/rubygems/test_gem_gemcutter_utilities.rb | 23 | ||||
-rw-r--r-- | test/rubygems/test_gem_installer.rb | 14 | ||||
-rw-r--r-- | test/rubygems/test_gem_package.rb | 3 | ||||
-rw-r--r-- | test/rubygems/test_gem_spec_fetcher.rb | 4 | ||||
-rw-r--r-- | test/rubygems/test_gem_specification.rb | 26 |
11 files changed, 156 insertions, 30 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index b6c74659b1..fda83767f2 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -1198,8 +1198,10 @@ class TestGem < Gem::TestCase end def test_self_user_dir - assert_equal File.join(@userhome, '.gem', Gem.ruby_engine, - Gem::ConfigMap[:ruby_version]), Gem.user_dir + parts = [@userhome, '.gem', Gem.ruby_engine] + parts << Gem::ConfigMap[:ruby_version] unless Gem::ConfigMap[:ruby_version].empty? + + assert_equal File.join(parts), Gem.user_dir end def test_self_user_home diff --git a/test/rubygems/test_gem_commands_help_command.rb b/test/rubygems/test_gem_commands_help_command.rb index f039857009..a10e575a5a 100644 --- a/test/rubygems/test_gem_commands_help_command.rb +++ b/test/rubygems/test_gem_commands_help_command.rb @@ -10,6 +10,9 @@ class TestGemCommandsHelpCommand < Gem::TestCase super @cmd = Gem::Commands::HelpCommand.new + + load File.expand_path('../rubygems_plugin.rb', __FILE__) unless + Gem::Commands.const_defined? :InterruptCommand end def test_gem_help_bad @@ -34,6 +37,8 @@ class TestGemCommandsHelpCommand < Gem::TestCase assert_match(/\s+#{cmd}\s+\S+/, out) end assert_equal '', err + + refute_match 'No command found for ', out end end diff --git a/test/rubygems/test_gem_commands_owner_command.rb b/test/rubygems/test_gem_commands_owner_command.rb index dc84190e5e..dfbc2572dc 100644 --- a/test/rubygems/test_gem_commands_owner_command.rb +++ b/test/rubygems/test_gem_commands_owner_command.rb @@ -140,4 +140,16 @@ EOF assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization'] end + + def test_remove_owners_missing + response = 'Owner could not be found.' + @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 404, 'Not Found'] + + use_ui @ui do + @cmd.remove_owners("freewill", ["missing@example"]) + end + + assert_equal "Removing missing@example: #{response}\n", @ui.output + end + end diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb index 73fd7bf540..52109d0ae4 100644 --- a/test/rubygems/test_gem_commands_push_command.rb +++ b/test/rubygems/test_gem_commands_push_command.rb @@ -61,6 +61,22 @@ class TestGemCommandsPushCommand < Gem::TestCase assert_match @response, @ui.output end + def test_execute + open 'example', 'w' do |io| io.write 'hello' end + + @response = "Successfully registered gem: freewill (1.0.0)" + @fetcher.data["#{Gem.host}/api/v1/gems"] = [@response, 200, 'OK'] + + @cmd.options[:args] = %w[example] + + @cmd.execute + + assert_equal Net::HTTP::Post, @fetcher.last_request.class + assert_equal 'hello', @fetcher.last_request.body + assert_equal "application/octet-stream", + @fetcher.last_request["Content-Type"] + end + def test_execute_host host = 'https://other.example' diff --git a/test/rubygems/test_gem_commands_search_command.rb b/test/rubygems/test_gem_commands_search_command.rb deleted file mode 100644 index 05e7cff892..0000000000 --- a/test/rubygems/test_gem_commands_search_command.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'rubygems/test_case' -require 'rubygems/commands/search_command' - -class TestGemCommandsSearchCommand < Gem::TestCase - - def setup - super - - @cmd = Gem::Commands::SearchCommand.new - end - - def test_execute - @cmd.handle_options %w[a] - - use_ui @ui do - @cmd.execute - end - - assert_match %r%REMOTE GEMS%, @ui.output - - assert_empty @ui.error - end - -end - diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb index 16298c9393..9c5ee7a5a8 100644 --- a/test/rubygems/test_gem_commands_setup_command.rb +++ b/test/rubygems/test_gem_commands_setup_command.rb @@ -1,3 +1,5 @@ +# coding: UTF-8 + require 'rubygems/test_case' require 'rubygems/commands/setup_command' @@ -73,5 +75,55 @@ class TestGemCommandsSetupCommand < Gem::TestCase assert_path_exists os_defaults_rb end + def test_show_release_notes + @default_external = nil + capture_io do + @default_external, Encoding.default_external = + Encoding.default_external, Encoding::US_ASCII + end if Object.const_defined? :Encoding + + @cmd.options[:previous_version] = Gem::Version.new '2.0.2' + + open 'History.txt', 'w' do |io| + io.puts <<-History_txt +# coding: UTF-8 + +=== #{Gem::VERSION} / 2013-03-26 + +* Bug fixes: + * Fixed release note display for LANG=C when installing rubygems + * π is tasty + +=== 2.0.2 / 2013-03-06 + +* Bug fixes: + * Other bugs fixed + +=== 2.0.1 / 2013-03-05 + +* Bug fixes: + * Yet more bugs fixed + History_txt + end + + use_ui @ui do + @cmd.show_release_notes + end + + expected = <<-EXPECTED +=== 2.0.2 / 2013-03-06 + +* Bug fixes: + * Other bugs fixed + + EXPECTED + + assert_equal expected, @ui.output + ensure + capture_io do + Encoding.default_external = @default_external + end if @default_external + end + end diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb index 38979ac960..18b4518b06 100644 --- a/test/rubygems/test_gem_gemcutter_utilities.rb +++ b/test/rubygems/test_gem_gemcutter_utilities.rb @@ -15,6 +15,13 @@ class TestGemGemcutterUtilities < Gem::TestCase @cmd.extend Gem::GemcutterUtilities end + def teardown + ENV['RUBYGEMS_HOST'] = nil + Gem.configuration.rubygems_api_key = nil + + super + end + def test_alternate_key_alternate_host keys = { :rubygems_api_key => 'KEY', @@ -63,6 +70,22 @@ class TestGemGemcutterUtilities < Gem::TestCase assert_equal 'OTHER', @cmd.api_key end + def test_host + assert_equal 'https://rubygems.org', @cmd.host + end + + def test_host_RUBYGEMS_HOST + ENV['RUBYGEMS_HOST'] = 'https://other.example' + + assert_equal 'https://other.example', @cmd.host + end + + def test_host_RUBYGEMS_HOST_empty + ENV['RUBYGEMS_HOST'] = '' + + assert_equal 'https://rubygems.org', @cmd.host + end + def test_sign_in api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' util_sign_in [api_key, 200, 'OK'] diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 4f233f9aab..e513fe6da3 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -1365,6 +1365,20 @@ gem 'other', version refute_path_exists @spec.build_info_file end + def test_write_build_info_file_install_dir + installer = Gem::Installer.new @gem, :install_dir => "#{@gemhome}2" + + installer.build_args = %w[ + --with-libyaml-dir /usr/local/Cellar/libyaml/0.1.4 + ] + + installer.write_build_info_file + + refute_path_exists @spec.build_info_file + assert_path_exists \ + File.join("#{@gemhome}2", 'build_info', "#{@spec.full_name}.info") + end + def test_write_cache_file cache_file = File.join @gemhome, 'cache', @spec.file_name gem = File.join @gemhome, @spec.file_name diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb index 81e7f7891c..7b3f638aee 100644 --- a/test/rubygems/test_gem_package.rb +++ b/test/rubygems/test_gem_package.rb @@ -511,7 +511,8 @@ class TestGemPackage < Gem::Package::TarTestCase package.verify end - assert_match ' - nonexistent.gem', e.message + assert_match %r%^No such file or directory%, e.message + assert_match %r%nonexistent.gem$%, e.message end def test_verify_security_policy diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb index b4aff095c0..a821057705 100644 --- a/test/rubygems/test_gem_spec_fetcher.rb +++ b/test/rubygems/test_gem_spec_fetcher.rb @@ -132,8 +132,10 @@ class TestGemSpecFetcher < Gem::TestCase assert_equal 0, specs_and_sources.size assert_equal 1, errors.size + pmm = errors.first - assert_equal "i386-linux", errors[0].platforms.first + assert_equal "i386-linux", pmm.platforms.first + assert_equal "Found pl (1), but was for platform i386-linux", pmm.wordy end def test_spec_for_dependency_bad_fetch_spec diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index bdac866bca..9b2ae82fe3 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -434,6 +434,21 @@ dependencies: [] assert_equal expected, Gem::Specification.normalize_yaml_input(input) end + def test_self_outdated + util_clear_gems + util_setup_fake_fetcher true + + a4 = quick_gem @a1.name, '4' + util_build_gem a4 + util_setup_spec_fetcher @a1, @a2, @a3a, a4 + + Gem::Specification.remove_spec @a1 + Gem::Specification.remove_spec @a2 + Gem::Specification.remove_spec a4 + + assert_equal %w[a], Gem::Specification.outdated + end + DATA_PATH = File.expand_path "../data", __FILE__ def test_handles_private_null_type @@ -597,7 +612,16 @@ dependencies: [] assert @a2.activated? end - def test_add_dependency_with_explicit_type + def test_add_dependency_with_type + gem = quick_spec "awesome", "1.0" do |awesome| + awesome.add_dependency true + awesome.add_dependency :gem_name + end + + assert_equal %w[true gem_name], gem.dependencies.map { |dep| dep.name } + end + + def test_add_dependency_with_type_explicit gem = quick_spec "awesome", "1.0" do |awesome| awesome.add_development_dependency "monkey" end |