rubygems-update 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (146) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +8 -1
  3. data/ChangeLog +164 -0
  4. data/History.txt +52 -1
  5. data/Manifest.txt +8 -8
  6. data/README +3 -2
  7. data/Rakefile +49 -5
  8. data/bin/gem +2 -2
  9. data/bin/update_rubygems +9 -11
  10. data/cruise_config.rb +4 -3
  11. data/hide_lib_for_update/note.txt +5 -0
  12. data/lib/rbconfig/datadir.rb +10 -14
  13. data/lib/rubygems.rb +117 -140
  14. data/lib/rubygems/builder.rb +4 -2
  15. data/lib/rubygems/command.rb +51 -48
  16. data/lib/rubygems/command_manager.rb +2 -0
  17. data/lib/rubygems/commands/dependency_command.rb +10 -5
  18. data/lib/rubygems/commands/environment_command.rb +1 -1
  19. data/lib/rubygems/commands/fetch_command.rb +6 -5
  20. data/lib/rubygems/commands/install_command.rb +1 -0
  21. data/lib/rubygems/commands/mirror_command.rb +8 -8
  22. data/lib/rubygems/commands/owner_command.rb +75 -0
  23. data/lib/rubygems/commands/pristine_command.rb +1 -1
  24. data/lib/rubygems/commands/push_command.rb +45 -0
  25. data/lib/rubygems/commands/query_command.rb +4 -1
  26. data/lib/rubygems/commands/rdoc_command.rb +24 -9
  27. data/lib/rubygems/commands/server_command.rb +6 -0
  28. data/lib/rubygems/commands/setup_command.rb +14 -4
  29. data/lib/rubygems/commands/unpack_command.rb +2 -2
  30. data/lib/rubygems/commands/update_command.rb +2 -2
  31. data/lib/rubygems/commands/which_command.rb +7 -9
  32. data/lib/rubygems/config_file.rb +100 -26
  33. data/lib/rubygems/defaults.rb +1 -1
  34. data/lib/rubygems/dependency.rb +133 -75
  35. data/lib/rubygems/dependency_installer.rb +28 -10
  36. data/lib/rubygems/dependency_list.rb +41 -12
  37. data/lib/rubygems/doc_manager.rb +7 -0
  38. data/lib/rubygems/format.rb +16 -20
  39. data/lib/rubygems/gem_openssl.rb +1 -1
  40. data/lib/rubygems/gem_path_searcher.rb +10 -12
  41. data/lib/rubygems/gemcutter_utilities.rb +49 -0
  42. data/lib/rubygems/indexer.rb +2 -2
  43. data/lib/rubygems/install_update_options.rb +1 -9
  44. data/lib/rubygems/installer.rb +35 -76
  45. data/lib/rubygems/local_remote_options.rb +1 -2
  46. data/lib/rubygems/package.rb +0 -1
  47. data/lib/rubygems/package/tar_input.rb +3 -1
  48. data/lib/rubygems/package_task.rb +16 -11
  49. data/lib/rubygems/remote_fetcher.rb +22 -8
  50. data/lib/rubygems/requirement.rb +78 -100
  51. data/lib/rubygems/server.rb +41 -10
  52. data/lib/rubygems/source_index.rb +5 -5
  53. data/lib/rubygems/spec_fetcher.rb +2 -2
  54. data/lib/rubygems/specification.rb +66 -16
  55. data/lib/rubygems/test_utilities.rb +33 -4
  56. data/lib/rubygems/uninstaller.rb +3 -3
  57. data/lib/rubygems/user_interaction.rb +45 -0
  58. data/lib/rubygems/validator.rb +6 -7
  59. data/lib/rubygems/version.rb +206 -149
  60. data/lib/rubygems/version_option.rb +16 -0
  61. data/test/fake_certlib/openssl.rb +1 -1
  62. data/test/functional.rb +0 -7
  63. data/test/gem_installer_test_case.rb +4 -4
  64. data/test/gem_package_tar_test_case.rb +1 -1
  65. data/test/gemutilities.rb +35 -31
  66. data/test/insure_session.rb +0 -8
  67. data/test/mockgemui.rb +0 -8
  68. data/test/simple_gem.rb +2 -8
  69. data/test/test_config.rb +3 -10
  70. data/test/test_gem.rb +9 -14
  71. data/test/test_gem_builder.rb +1 -7
  72. data/test/test_gem_command.rb +1 -8
  73. data/test/test_gem_command_manager.rb +1 -7
  74. data/test/test_gem_commands_build_command.rb +4 -4
  75. data/test/test_gem_commands_cert_command.rb +1 -2
  76. data/test/test_gem_commands_check_command.rb +1 -7
  77. data/test/test_gem_commands_contents_command.rb +1 -1
  78. data/test/test_gem_commands_dependency_command.rb +17 -31
  79. data/test/test_gem_commands_environment_command.rb +1 -1
  80. data/test/test_gem_commands_fetch_command.rb +14 -12
  81. data/test/test_gem_commands_generate_index_command.rb +1 -1
  82. data/test/test_gem_commands_install_command.rb +22 -20
  83. data/test/test_gem_commands_list_command.rb +1 -1
  84. data/test/test_gem_commands_lock_command.rb +1 -1
  85. data/test/test_gem_commands_mirror_command.rb +5 -5
  86. data/test/test_gem_commands_outdated_command.rb +3 -5
  87. data/test/test_gem_commands_owner_command.rb +105 -0
  88. data/test/test_gem_commands_pristine_command.rb +2 -2
  89. data/test/test_gem_commands_push_command.rb +61 -0
  90. data/test/test_gem_commands_query_command.rb +23 -56
  91. data/test/test_gem_commands_server_command.rb +1 -1
  92. data/test/test_gem_commands_sources_command.rb +1 -70
  93. data/test/test_gem_commands_specification_command.rb +3 -4
  94. data/test/test_gem_commands_stale_command.rb +1 -1
  95. data/test/test_gem_commands_uninstall_command.rb +3 -4
  96. data/test/test_gem_commands_unpack_command.rb +1 -1
  97. data/test/test_gem_commands_update_command.rb +13 -13
  98. data/test/test_gem_commands_which_command.rb +66 -0
  99. data/test/test_gem_config_file.rb +13 -7
  100. data/test/test_gem_dependency.rb +82 -134
  101. data/test/test_gem_dependency_installer.rb +55 -30
  102. data/test/test_gem_dependency_list.rb +28 -7
  103. data/test/test_gem_doc_manager.rb +1 -7
  104. data/test/test_gem_ext_configure_builder.rb +2 -2
  105. data/test/test_gem_ext_ext_conf_builder.rb +1 -1
  106. data/test/test_gem_ext_rake_builder.rb +1 -1
  107. data/test/test_gem_format.rb +14 -11
  108. data/test/test_gem_gem_path_searcher.rb +12 -1
  109. data/test/test_gem_gem_runner.rb +1 -1
  110. data/test/test_gem_gemcutter_utilities.rb +103 -0
  111. data/test/test_gem_indexer.rb +44 -51
  112. data/test/test_gem_install_update_options.rb +1 -7
  113. data/test/test_gem_installer.rb +22 -82
  114. data/test/test_gem_local_remote_options.rb +1 -1
  115. data/test/test_gem_package_tar_header.rb +1 -8
  116. data/test/test_gem_package_tar_input.rb +1 -8
  117. data/test/test_gem_package_tar_output.rb +1 -8
  118. data/test/test_gem_package_tar_reader.rb +1 -8
  119. data/test/test_gem_package_tar_reader_entry.rb +1 -8
  120. data/test/test_gem_package_tar_writer.rb +1 -8
  121. data/test/test_gem_package_task.rb +1 -25
  122. data/test/test_gem_platform.rb +4 -4
  123. data/test/test_gem_remote_fetcher.rb +31 -21
  124. data/test/test_gem_requirement.rb +210 -140
  125. data/test/test_gem_server.rb +36 -1
  126. data/test/test_gem_source_index.rb +7 -13
  127. data/test/test_gem_spec_fetcher.rb +17 -47
  128. data/test/test_gem_specification.rb +7 -20
  129. data/test/test_gem_stream_ui.rb +21 -1
  130. data/test/test_gem_uninstaller.rb +1 -2
  131. data/test/test_gem_validator.rb +2 -8
  132. data/test/test_gem_version.rb +110 -254
  133. data/test/test_gem_version_option.rb +1 -1
  134. data/test/test_kernel.rb +1 -7
  135. data/util/CL2notes +1 -1
  136. data/util/gem_prelude.rb.template +64 -41
  137. metadata +33 -71
  138. metadata.gz.sig +0 -0
  139. data/lib/rubygems/digest/digest_adapter.rb +0 -49
  140. data/lib/rubygems/digest/md5.rb +0 -23
  141. data/lib/rubygems/digest/sha1.rb +0 -22
  142. data/lib/rubygems/digest/sha2.rb +0 -22
  143. data/lib/rubygems/timer.rb +0 -28
  144. data/test/test_gem_digest.rb +0 -46
  145. data/test/test_gem_source_info_cache.rb +0 -447
  146. data/test/test_gem_source_info_cache_entry.rb +0 -78
@@ -1,10 +1,4 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
8
2
  require 'rubygems/source_index'
9
3
  require 'rubygems/config_file'
10
4
 
@@ -31,7 +25,7 @@ class TestGemSourceIndex < RubyGemTestCase
31
25
 
32
26
  a1 = quick_gem 'a', '1' do |spec| spec.author = 'author 1' end
33
27
 
34
- spec_file = File.join spec_dir, "#{a1.full_name}.gemspec"
28
+ spec_file = File.join spec_dir, a1.spec_name
35
29
 
36
30
  File.open spec_file, 'w' do |fp|
37
31
  fp.write a1.to_ruby
@@ -52,7 +46,7 @@ class TestGemSourceIndex < RubyGemTestCase
52
46
 
53
47
  a1 = quick_gem 'a', '1' do |spec| spec.author = 'author 1' end
54
48
 
55
- spec_file = File.join spec_dir, "#{a1.full_name}.gemspec"
49
+ spec_file = File.join spec_dir, a1.spec_name
56
50
 
57
51
  File.open spec_file, 'w' do |fp|
58
52
  fp.write a1.to_ruby
@@ -298,11 +292,11 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
298
292
  a1 = quick_gem 'a', '1' do |spec| spec.author = 'author 1' end
299
293
  a2 = quick_gem 'a', '1' do |spec| spec.author = 'author 2' end
300
294
 
301
- File.open File.join(spec_dir1, "#{a1.full_name}.gemspec"), 'w' do |fp|
295
+ File.open File.join(spec_dir1, a1.spec_name), 'w' do |fp|
302
296
  fp.write a1.to_ruby
303
297
  end
304
298
 
305
- File.open File.join(spec_dir2, "#{a2.full_name}.gemspec"), 'w' do |fp|
299
+ File.open File.join(spec_dir2, a2.spec_name), 'w' do |fp|
306
300
  fp.write a2.to_ruby
307
301
  end
308
302
 
@@ -340,7 +334,7 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
340
334
  end
341
335
 
342
336
  def test_refresh_bang
343
- a1_spec = File.join @gemhome, "specifications", "#{@a1.full_name}.gemspec"
337
+ a1_spec = File.join @gemhome, "specifications", @a1.spec_name
344
338
 
345
339
  FileUtils.mv a1_spec, @tempdir
346
340
 
@@ -348,7 +342,7 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
348
342
 
349
343
  refute source_index.gems.include?(@a1.full_name)
350
344
 
351
- FileUtils.mv File.join(@tempdir, "#{@a1.full_name}.gemspec"), a1_spec
345
+ FileUtils.mv File.join(@tempdir, @a1.spec_name), a1_spec
352
346
 
353
347
  source_index.refresh!
354
348
 
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/spec_fetcher'
3
3
 
4
4
  class TestGemSpecFetcher < RubyGemTestCase
@@ -39,16 +39,17 @@ class TestGemSpecFetcher < RubyGemTestCase
39
39
  end
40
40
 
41
41
  def test_fetch_all
42
- @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.full_name}.gemspec.rz"] =
42
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}.rz"] =
43
43
  util_zip(Marshal.dump(@a1))
44
- @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a2.full_name}.gemspec.rz"] =
44
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a2.spec_name}.rz"] =
45
45
  util_zip(Marshal.dump(@a2))
46
- @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a_pre.full_name}.gemspec.rz"] =
46
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a_pre.spec_name}.rz"] =
47
47
  util_zip(Marshal.dump(@a_pre))
48
- @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a3a.full_name}.gemspec.rz"] =
48
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a3a.spec_name}.rz"] =
49
49
  util_zip(Marshal.dump(@a3a))
50
50
 
51
51
  dep = Gem::Dependency.new 'a', 1
52
+
52
53
  specs_and_sources = @sf.fetch dep, true
53
54
 
54
55
  spec_names = specs_and_sources.map do |spec, source_uri|
@@ -63,11 +64,11 @@ class TestGemSpecFetcher < RubyGemTestCase
63
64
  end
64
65
 
65
66
  def test_fetch_latest
66
- @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.full_name}.gemspec.rz"] =
67
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}.rz"] =
67
68
  util_zip(Marshal.dump(@a1))
68
- @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a2.full_name}.gemspec.rz"] =
69
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a2.spec_name}.rz"] =
69
70
  util_zip(Marshal.dump(@a2))
70
- @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a_pre.full_name}.gemspec.rz"] =
71
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a_pre.spec_name}.rz"] =
71
72
  util_zip(Marshal.dump(@a_pre))
72
73
 
73
74
  dep = Gem::Dependency.new 'a', 1
@@ -81,11 +82,11 @@ class TestGemSpecFetcher < RubyGemTestCase
81
82
  end
82
83
 
83
84
  def test_fetch_prerelease
84
- @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.full_name}.gemspec.rz"] =
85
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}.rz"] =
85
86
  util_zip(Marshal.dump(@a1))
86
- @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a2.full_name}.gemspec.rz"] =
87
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a2.spec_name}.rz"] =
87
88
  util_zip(Marshal.dump(@a2))
88
- @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a_pre.full_name}.gemspec.rz"] =
89
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a_pre.spec_name}.rz"] =
89
90
  util_zip(Marshal.dump(@a_pre))
90
91
 
91
92
  dep = Gem::Dependency.new 'a', '1.a'
@@ -98,37 +99,6 @@ class TestGemSpecFetcher < RubyGemTestCase
98
99
  assert_equal [[@a_pre.full_name, @gem_repo]], spec_names
99
100
  end
100
101
 
101
- def test_fetch_legacy_repo
102
- @fetcher.data.delete "#{@gem_repo}specs.#{Gem.marshal_version}.gz"
103
- @fetcher.data["#{@gem_repo}yaml"] = ''
104
- util_setup_source_info_cache @a1, @a2
105
-
106
- dep = Gem::Dependency.new 'a', 1
107
- specs = nil
108
-
109
- use_ui @ui do
110
- specs = @sf.fetch dep, true
111
- end
112
-
113
- expected = <<-EOF
114
- WARNING: RubyGems 1.2+ index not found for:
115
- \thttp://gems.example.com/
116
-
117
- RubyGems will revert to legacy indexes degrading performance.
118
- EOF
119
-
120
- assert_equal expected, @ui.error
121
-
122
- specs = specs.map { |spec, source_uri| [spec.full_name, source_uri] }
123
-
124
- expected = [
125
- [@a1.full_name, @gem_repo],
126
- [@a2.full_name, @gem_repo],
127
- ]
128
-
129
- assert_equal expected, specs
130
- end
131
-
132
102
  def test_fetch_platform
133
103
  util_set_arch 'i386-linux'
134
104
 
@@ -146,7 +116,7 @@ RubyGems will revert to legacy indexes degrading performance.
146
116
  end
147
117
 
148
118
  def test_fetch_spec
149
- spec_uri = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.full_name}.gemspec"
119
+ spec_uri = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}"
150
120
  @fetcher.data["#{spec_uri}.rz"] = util_zip(Marshal.dump(@a1))
151
121
 
152
122
  spec = @sf.fetch_spec ['a', Gem::Version.new(1), 'ruby'], @uri
@@ -154,19 +124,19 @@ RubyGems will revert to legacy indexes degrading performance.
154
124
 
155
125
  cache_dir = @sf.cache_dir URI.parse(spec_uri)
156
126
 
157
- cache_file = File.join cache_dir, "#{@a1.full_name}.gemspec"
127
+ cache_file = File.join cache_dir, @a1.spec_name
158
128
 
159
129
  assert File.exist?(cache_file)
160
130
  end
161
131
 
162
132
  def test_fetch_spec_cached
163
- spec_uri = "#{@gem_repo}/#{Gem::MARSHAL_SPEC_DIR}#{@a1.full_name}.gemspec"
133
+ spec_uri = "#{@gem_repo}/#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}"
164
134
  @fetcher.data["#{spec_uri}.rz"] = nil
165
135
 
166
136
  cache_dir = @sf.cache_dir URI.parse(spec_uri)
167
137
  FileUtils.mkdir_p cache_dir
168
138
 
169
- cache_file = File.join cache_dir, "#{@a1.full_name}.gemspec"
139
+ cache_file = File.join cache_dir, @a1.spec_name
170
140
 
171
141
  open cache_file, 'wb' do |io|
172
142
  Marshal.dump @a1, io
@@ -186,7 +156,7 @@ RubyGems will revert to legacy indexes degrading performance.
186
156
  end
187
157
 
188
158
  def test_fetch_spec_platform_ruby
189
- @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.full_name}.gemspec.rz"] =
159
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}.rz"] =
190
160
  util_zip(Marshal.dump(@a1))
191
161
 
192
162
  spec = @sf.fetch_spec ['a', Gem::Version.new(1), nil], @uri
@@ -1,11 +1,5 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
1
+ require File.expand_path('../gemutilities', __FILE__)
7
2
  require 'stringio'
8
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
9
3
  require 'rubygems/specification'
10
4
 
11
5
  class TestGemSpecification < RubyGemTestCase
@@ -129,7 +123,7 @@ end
129
123
  end
130
124
 
131
125
  def test_self_load
132
- spec = File.join @gemhome, 'specifications', "#{@a2.full_name}.gemspec"
126
+ spec = File.join @gemhome, 'specifications', @a2.spec_name
133
127
  gs = Gem::Specification.load spec
134
128
 
135
129
  assert_equal @a2, gs
@@ -145,16 +139,6 @@ end
145
139
  assert_equal false, spec.has_unit_tests?
146
140
  end
147
141
 
148
- def test_self_load_legacy_yaml
149
- s = YAML.load StringIO.new(LEGACY_YAML_SPEC)
150
- assert_equal 'keyedlist', s.name
151
- assert_equal '0.4.0', s.version.to_s
152
- assert_equal true, s.has_rdoc?
153
- #assert_equal Date.today, s.date
154
- #assert s.required_ruby_version.satisfied_by?(Gem::Version.new('1'))
155
- assert_equal false, s.has_unit_tests?
156
- end
157
-
158
142
  def test_self_normalize_yaml_input_with_183_yaml
159
143
  input = "!ruby/object:Gem::Specification "
160
144
  assert_equal "--- #{input}", Gem::Specification.normalize_yaml_input(input)
@@ -538,8 +522,7 @@ end
538
522
 
539
523
  def test_full_gem_path_double_slash
540
524
  gemhome = @gemhome.sub(/\w\//, '\&/')
541
- @a1.loaded_from = File.join gemhome, 'specifications',
542
- "#{@a1.full_name}.gemspec"
525
+ @a1.loaded_from = File.join gemhome, 'specifications', @a1.spec_name
543
526
 
544
527
  assert_equal File.join(@gemhome, 'gems', @a1.full_name),
545
528
  @a1.full_gem_path
@@ -730,6 +713,10 @@ end
730
713
  assert_equal( 1, (s2 <=> s1))
731
714
  end
732
715
 
716
+ def test_spec_name
717
+ assert_equal 'a-1.gemspec', @a1.spec_name
718
+ end
719
+
733
720
  def test_summary
734
721
  assert_equal 'this is a summary', @a1.summary
735
722
  end
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/user_interaction'
3
3
 
4
4
  class TestGemStreamUI < RubyGemTestCase
@@ -46,6 +46,26 @@ class TestGemStreamUI < RubyGemTestCase
46
46
  end
47
47
  end
48
48
 
49
+ def test_ask_for_password
50
+ skip 'Always uses $stdin on windows' if Gem.win_platform?
51
+
52
+ timeout(1) do
53
+ expected_answer = "Arthur, King of the Britons"
54
+ @in.string = "#{expected_answer}\n"
55
+ actual_answer = @sui.ask_for_password("What is your name?")
56
+ assert_equal expected_answer, actual_answer
57
+ end
58
+ end
59
+
60
+ def test_ask_for_password_no_tty
61
+ @in.tty = false
62
+
63
+ timeout(0.1) do
64
+ answer = @sui.ask_for_password("what is the airspeed velocity of an unladen swallow?")
65
+ assert_equal nil, answer
66
+ end
67
+ end
68
+
49
69
  def test_ask_yes_no_no_tty_with_default
50
70
  @in.tty = false
51
71
 
@@ -1,5 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)),
2
- 'gem_installer_test_case')
1
+ require File.expand_path('../gem_installer_test_case', __FILE__)
3
2
  require 'rubygems/uninstaller'
4
3
 
5
4
  class TestGemUninstaller < GemInstallerTestCase
@@ -1,11 +1,5 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
8
- require File.join(File.expand_path(File.dirname(__FILE__)), 'simple_gem')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require File.expand_path('../simple_gem', __FILE__)
9
3
  require 'rubygems/validator'
10
4
 
11
5
  class TestGemValidator < RubyGemTestCase
@@ -1,316 +1,172 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
8
- require 'rubygems/version'
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require "rubygems/version"
9
3
 
10
4
  class TestGemVersion < RubyGemTestCase
11
5
 
12
- def setup
13
- super
14
-
15
- version = Object.new
16
- def version.to_s() '1.4.0' end
17
-
18
- @v1_0 = Gem::Version.new '1.0'
19
- @v1_2 = Gem::Version.new '1.2'
20
- @v1_3 = Gem::Version.new '1.3'
21
- @v1_4_0 = Gem::Version.new version
22
- end
23
-
24
- def test_class_create
25
- assert_version Gem::Version.create('1.0')
26
- assert_version Gem::Version.create("1.0 ")
27
- assert_version Gem::Version.create(" 1.0 ")
28
- assert_version Gem::Version.create("1.0\n")
29
- assert_version Gem::Version.create("\n1.0\n")
30
-
31
- assert_equal Gem::Version.create('1'), Gem::Version.create(1)
32
- end
33
-
34
- def test_class_create_malformed
35
- e = assert_raises ArgumentError do Gem::Version.create("junk") end
36
- assert_equal "Malformed version number string junk", e.message
37
-
38
- e = assert_raises ArgumentError do Gem::Version.create("1.0\n2.0") end
39
- assert_equal "Malformed version number string 1.0\n2.0", e.message
6
+ def test_bump
7
+ assert_bumped_version_equal "5.3", "5.2.4"
40
8
  end
41
9
 
42
- def test_bad
43
- assert_inadequate( "", "> 0.1")
44
- assert_inadequate( "1.2.3", "!= 1.2.3")
45
- assert_inadequate( "1.2.003.0.0", "!= 1.02.3")
46
- assert_inadequate( "4.5.6", "< 1.2.3")
47
- assert_inadequate( "1.0", "> 1.1")
48
- assert_inadequate( "0", ">")
49
- assert_inadequate( "0", "<")
50
- assert_inadequate( "", "= 0.1")
51
- assert_inadequate( "1.1.1", "> 1.1.1")
52
- assert_inadequate( "1.2", "= 1.1")
53
- assert_inadequate( "1.40", "= 1.1")
54
- assert_inadequate( "1.3", "= 1.40")
55
- assert_inadequate( "9.3.3", "<= 9.3.2")
56
- assert_inadequate( "9.3.1", ">= 9.3.2")
57
- assert_inadequate( "9.3.03", "<= 9.3.2")
58
- assert_inadequate( "1.0.0.1", "= 1.0")
10
+ def test_bump_alpha
11
+ assert_bumped_version_equal "5.3", "5.2.4.a"
59
12
  end
60
13
 
61
14
  def test_bump_trailing_zeros
62
- v = Gem::Version.new("5.0.0")
63
- assert_equal "5.1", v.bump.to_s
64
- end
65
-
66
- def test_bump
67
- v = Gem::Version.new("5.2.4")
68
- assert_equal "5.3", v.bump.to_s
69
- end
70
-
71
- def test_bump_alpha
72
- v = Gem::Version.new("5.2.4.a")
73
- assert_equal "5.3", v.bump.to_s
15
+ assert_bumped_version_equal "5.1", "5.0.0"
74
16
  end
75
17
 
76
18
  def test_bump_one_level
77
- v = Gem::Version.new("5")
78
- assert_equal "6", v.bump.to_s
19
+ assert_bumped_version_equal "6", "5"
79
20
  end
80
21
 
81
- def test_eql_eh
82
- v1_2 = Gem::Version.new '1.2'
83
- v1_2_0 = Gem::Version.new '1.2.0'
22
+ # FIX: For "legacy reasons," any object that responds to +version+
23
+ # is returned unchanged. I'm not certain why.
84
24
 
85
- assert_equal true, v1_2.eql?(@v1_2)
86
- assert_equal true, @v1_2.eql?(v1_2)
87
-
88
- assert_equal false, v1_2_0.eql?(@v1_2)
89
- assert_equal false, @v1_2.eql?(v1_2_0)
25
+ def test_class_create
26
+ fake = Object.new
27
+ def fake.version; "1.0" end
90
28
 
91
- assert_equal false, @v1_2.eql?(@v1_3)
92
- assert_equal false, @v1_3.eql?(@v1_2)
29
+ assert_same fake, Gem::Version.create(fake)
30
+ assert_nil Gem::Version.create(nil)
31
+ assert_equal v("5.1"), Gem::Version.create("5.1")
93
32
  end
94
33
 
95
- def test_eql_eh4
96
- v1_4 = Gem::Version.new '1.4'
97
- v1_4_0 = Gem::Version.new "1.4.0"
98
-
99
- assert_equal true, v1_4_0.eql?(@v1_4_0)
100
- assert_equal true, @v1_4_0.eql?(v1_4_0)
101
-
102
- assert_equal false, v1_4.eql?(@v1_4_0)
103
- assert_equal false, @v1_4_0.eql?(v1_4)
104
-
105
- assert_equal false, @v1_4_0.eql?(@v1_3)
106
- assert_equal false, @v1_3.eql?(@v1_4_0)
34
+ def test_eql_eh
35
+ assert_version_eql "1.2", "1.2"
36
+ refute_version_eql "1.2", "1.2.0"
37
+ refute_version_eql "1.2", "1.3"
107
38
  end
108
39
 
109
- def test_equals2
110
- v = Gem::Version.new("1.2")
111
-
112
- assert_equal v, @v1_2
113
- assert_equal @v1_2, v
114
-
115
- refute_equal @v1_2, @v1_3
116
- refute_equal @v1_3, @v1_2
40
+ def test_equals
41
+ assert_version_equal "1.2", "1.2"
42
+ refute_version_equal "1.2", "1.3"
117
43
  end
118
44
 
45
+ # REVISIT: consider removing as too impl-bound
119
46
  def test_hash
120
- v1_2 = Gem::Version.new "1.2"
121
- v1_2_0 = Gem::Version.new "1.2.0"
122
- v1_4_0 = Gem::Version.new "1.4.0"
123
-
124
- assert_equal v1_2.hash, @v1_2.hash
125
-
126
- refute_equal v1_2_0.hash, @v1_2.hash
127
-
128
- assert_equal v1_4_0.hash, @v1_4_0.hash
129
-
130
- refute_equal @v1_2.hash, @v1_3.hash
131
-
132
- refute_equal @v1_2.hash, @v1_4_0.hash
47
+ assert_equal v("1.2").hash, v("1.2").hash
48
+ refute_equal v("1.2").hash, v("1.3").hash
49
+ refute_equal v("1.2").hash, v("1.2.0").hash
133
50
  end
134
51
 
135
- def test_illformed_requirements
136
- [ ">>> 1.3.5", "> blah" ].each do |rq|
137
- assert_raises ArgumentError, "req [#{rq}] should fail" do
138
- Gem::Version::Requirement.new rq
139
- end
52
+ def test_initialize
53
+ ["1.0", "1.0 ", " 1.0 ", "1.0\n", "\n1.0\n"].each do |good|
54
+ assert_version_equal "1.0", good
140
55
  end
141
- end
142
56
 
143
- def test_normalize
144
- assert_equal [0], Gem::Version.new("").normalize.map { |part| part.value }
145
- assert_equal [0], Gem::Version.new("0").normalize.map { |part| part.value }
146
- assert_equal [1], Gem::Version.new("1").normalize.map { |part| part.value }
147
- assert_equal [1], Gem::Version.new("1.0").normalize.map { |part| part.value }
148
- assert_equal [1, 1], Gem::Version.new("1.1").normalize.map { |part| part.value }
149
- assert_equal [1, 1, "a"], Gem::Version.new("1.1.a").normalize.map { |part| part.value }
57
+ assert_version_equal "1", 1
150
58
  end
151
59
 
152
- def test_ok
153
- assert_adequate( "0.2.33", "= 0.2.33")
154
- assert_adequate( "0.2.34", "> 0.2.33")
155
- assert_adequate( "1.0", "= 1.0")
156
- assert_adequate( "1.0", "1.0")
157
- assert_adequate( "1.8.2", "> 1.8.0")
158
- assert_adequate( "1.112", "> 1.111")
159
- assert_adequate( "0.2", "> 0.0.0")
160
- assert_adequate( "0.0.0.0.0.2", "> 0.0.0")
161
- assert_adequate( "0.0.1.0", "> 0.0.0.1")
162
- assert_adequate( "10.3.2", "> 9.3.2")
163
- assert_adequate( "1.0.0.0", "= 1.0")
164
- assert_adequate( "10.3.2", "!= 9.3.4")
165
- assert_adequate( "10.3.2", "> 9.3.2")
166
- assert_adequate( "10.3.2", "> 9.3.2")
167
- assert_adequate( " 9.3.2", ">= 9.3.2")
168
- assert_adequate( "9.3.2 ", ">= 9.3.2")
169
- assert_adequate( "", "= 0")
170
- assert_adequate( "", "< 0.1")
171
- assert_adequate( " ", "< 0.1 ")
172
- assert_adequate( "", " < 0.1")
173
- assert_adequate( " ", "> 0.a ")
174
- assert_adequate( "", " > 0.a")
175
- assert_adequate( "0", "=")
176
- assert_adequate( "0", ">=")
177
- assert_adequate( "0", "<=")
178
- assert_adequate( "3.1", "< 3.2.rc1")
179
- assert_adequate( "3.2.0", "> 3.2.0.rc1")
180
- assert_adequate( "3.2.0.rc2", "> 3.2.0.rc1")
181
- assert_adequate( "3.0.rc2", "< 3.0")
182
- assert_adequate( "3.0.rc2", "< 3.0.0")
183
- assert_adequate( "3.0.rc2", "< 3.0.1")
184
- end
60
+ def test_initialize_bad
61
+ ["junk", "1.0\n2.0"].each do |bad|
62
+ e = assert_raises ArgumentError do
63
+ Gem::Version.new bad
64
+ end
185
65
 
186
- def test_parse_parts_from_version_string
187
- assert_equal [], part_values(Gem::Version.new("").parse_parts_from_version_string)
188
- assert_equal [1], part_values(Gem::Version.new("1").parse_parts_from_version_string)
189
- assert_equal [1, 0], part_values(Gem::Version.new("1.0").parse_parts_from_version_string)
190
- assert_equal [1, 0, "a"], part_values(Gem::Version.new("1.0.a").parse_parts_from_version_string)
66
+ assert_equal "Malformed version number string #{bad}", e.message
67
+ end
191
68
  end
192
69
 
193
70
  def test_prerelease
194
- assert Gem::Version.new('1.2.0.a').prerelease?
195
- assert Gem::Version.new('2.9.b').prerelease?
196
- assert Gem::Version.new('22.1.50.0.d').prerelease?
71
+ assert_prerelease "1.2.0.a"
72
+ assert_prerelease "2.9.b"
73
+ assert_prerelease "22.1.50.0.d"
74
+ assert_prerelease "1.2.d.42"
197
75
 
198
- refute Gem::Version.new('1.2.0').prerelease?
199
- refute Gem::Version.new('2.9').prerelease?
200
- refute Gem::Version.new('22.1.50.0').prerelease?
201
- end
202
-
203
- def test_release
204
- assert_equal Gem::Version.new('1.2.0'), Gem::Version.new('1.2.0.a').release
205
- assert_equal Gem::Version.new('1.1'), Gem::Version.new('1.1.rc10').release
206
- assert_equal Gem::Version.new('1.9.3'), Gem::Version.new('1.9.3.alpha.5').release
207
- assert_equal Gem::Version.new('1.9.3'), Gem::Version.new('1.9.3').release
208
- end
76
+ assert_prerelease '1.A'
209
77
 
210
- def test_satisfied_by_eh_boxed
211
- assert_inadequate("1.3", "~> 1.4")
212
- assert_adequate( "1.4", "~> 1.4")
213
- assert_adequate( "1.5", "~> 1.4")
214
- assert_inadequate("2.0", "~> 1.4")
215
-
216
- assert_inadequate("1.3", "~> 1.4.4")
217
- assert_inadequate("1.4", "~> 1.4.4")
218
- assert_adequate( "1.4.4", "~> 1.4.4")
219
- assert_adequate( "1.4.5", "~> 1.4.4")
220
- assert_inadequate("1.5", "~> 1.4.4")
221
- assert_inadequate("2.0", "~> 1.4.4")
222
-
223
- assert_inadequate("1.1.pre", "~> 1.0.0")
224
- assert_adequate( "1.1.pre", "~> 1.1")
225
- assert_inadequate("2.0.a", "~> 1.0")
226
- assert_adequate( "2.0.a", "~> 2.0")
78
+ refute_prerelease "1.2.0"
79
+ refute_prerelease "2.9"
80
+ refute_prerelease "22.1.50.0"
227
81
  end
228
82
 
229
- def test_satisfied_by_eh_multiple
230
- req = [">= 1.4", "<= 1.6", "!= 1.5"]
231
- assert_inadequate("1.3", req)
232
- assert_adequate( "1.4", req)
233
- assert_inadequate("1.5", req)
234
- assert_adequate( "1.6", req)
235
- assert_inadequate("1.7", req)
236
- assert_inadequate("2.0", req)
83
+ def test_release
84
+ assert_release_equal "1.2.0", "1.2.0.a"
85
+ assert_release_equal "1.1", "1.1.rc10"
86
+ assert_release_equal "1.9.3", "1.9.3.alpha.5"
87
+ assert_release_equal "1.9.3", "1.9.3"
237
88
  end
238
89
 
239
90
  def test_spaceship
240
- assert_equal 0, Gem::Version.new('1.0') <=> Gem::Version.new('1.0.0')
241
- assert_equal 1, Gem::Version.new('1.0') <=> Gem::Version.new('1.0.a')
242
- assert_equal 1, Gem::Version.new('1.8.2') <=> Gem::Version.new('0.0.0')
243
- assert_equal 1, Gem::Version.new('1.8.2') <=> Gem::Version.new('1.8.2.a')
244
- assert_equal 1, Gem::Version.new('1.8.2.b') <=> Gem::Version.new('1.8.2.a')
245
- assert_equal 0, Gem::Version.new('') <=> Gem::Version.new('0')
91
+ assert_equal( 0, v("1.0") <=> v("1.0.0"))
92
+ assert_equal( 1, v("1.0") <=> v("1.0.a"))
93
+ assert_equal( 1, v("1.8.2") <=> v("0.0.0"))
94
+ assert_equal( 1, v("1.8.2") <=> v("1.8.2.a"))
95
+ assert_equal( 1, v("1.8.2.b") <=> v("1.8.2.a"))
96
+ assert_equal(-1, v("1.8.2.a") <=> v("1.8.2"))
97
+ assert_equal( 0, v("") <=> v("0"))
246
98
  end
247
99
 
248
- def test_boxed
249
- assert_inadequate("1.3", "~> 1.4")
250
- assert_adequate( "1.4", "~> 1.4")
251
- assert_adequate( "1.5", "~> 1.4")
252
- assert_inadequate("2.0", "~> 1.4")
253
-
254
- assert_inadequate("1.3", "~> 1.4.4")
255
- assert_inadequate("1.4", "~> 1.4.4")
256
- assert_adequate( "1.4.4", "~> 1.4.4")
257
- assert_adequate( "1.4.5", "~> 1.4.4")
258
- assert_inadequate("1.5", "~> 1.4.4")
259
- assert_inadequate("2.0", "~> 1.4.4")
100
+ def test_spermy_recommendation
101
+ assert_spermy_equal "~> 1.0", "1"
102
+ assert_spermy_equal "~> 1.0", "1.0"
103
+ assert_spermy_equal "~> 1.2", "1.2"
104
+ assert_spermy_equal "~> 1.2", "1.2.0"
105
+ assert_spermy_equal "~> 1.2", "1.2.3"
106
+ assert_spermy_equal "~> 1.2", "1.2.3.a.4"
260
107
  end
261
108
 
262
109
  def test_to_s
263
- v = Gem::Version.new("5.2.4")
264
- assert_equal "5.2.4", v.to_s
110
+ assert_equal "5.2.4", v("5.2.4").to_s
111
+ end
112
+
113
+ # Asserts that +version+ is a prerelease.
114
+
115
+ def assert_prerelease version
116
+ assert v(version).prerelease?, "#{version} is a prerelease"
265
117
  end
266
118
 
267
- def assert_adequate(version, requirement)
268
- ver = Gem::Version.new(version)
269
- req = Gem::Requirement.new(requirement)
270
- assert req.satisfied_by?(ver),
271
- "Version #{version} should be adequate for Requirement #{requirement}"
119
+ # Assert that +expected+ is the "spermy" recommendation for +version".
120
+
121
+ def assert_spermy_equal expected, version
122
+ assert_equal expected, v(version).spermy_recommendation
272
123
  end
273
124
 
274
- def assert_inadequate(version, requirement)
275
- ver = Gem::Version.new(version)
276
- req = Gem::Version::Requirement.new(requirement)
277
- refute req.satisfied_by?(ver),
278
- "Version #{version} should not be adequate for Requirement #{requirement}"
125
+ # Assert that bumping the +unbumped+ version yields the +expected+.
126
+
127
+ def assert_bumped_version_equal expected, unbumped
128
+ assert_version_equal expected, v(unbumped).bump
279
129
  end
280
130
 
281
- def assert_version(actual)
282
- assert_equal @v1_0, actual
283
- assert_equal @v1_0.version, actual.version
131
+ # Assert that +release+ is the correct non-prerelease +version+.
132
+
133
+ def assert_release_equal release, version
134
+ assert_version_equal release, v(version).release
284
135
  end
285
136
 
286
- def part_values(*parts)
287
- parts.flatten.map { |part| part.value }
137
+ # Assert that two versions are equal. Handles strings or
138
+ # Gem::Version instances.
139
+
140
+ def assert_version_equal expected, actual
141
+ assert_equal v(expected), v(actual)
288
142
  end
289
- end
290
143
 
291
- class TestGemVersionPart < RubyGemTestCase
292
- def test_initialize
293
- assert_equal 1, Gem::Version::Part.new(1).value
294
- assert_equal 1, Gem::Version::Part.new("1").value
295
- assert_equal "a", Gem::Version::Part.new("a").value
144
+ # Assert that two versions are eql?. Checks both directions.
145
+
146
+ def assert_version_eql first, second
147
+ first, second = v(first), v(second)
148
+ assert first.eql?(second), "#{first} is eql? #{second}"
149
+ assert second.eql?(first), "#{second} is eql? #{first}"
296
150
  end
297
151
 
298
- def test_spaceship
299
- assert_equal(-1, Gem::Version::Part.new(1) <=> Gem::Version::Part.new(2))
300
- assert_equal( 0, Gem::Version::Part.new(2) <=> Gem::Version::Part.new(2))
301
- assert_equal( 1, Gem::Version::Part.new(2) <=> Gem::Version::Part.new(1))
152
+ # Refute the assumption that +version+ is a prerelease.
302
153
 
303
- assert_equal(-1, Gem::Version::Part.new("a") <=> Gem::Version::Part.new("b"))
304
- assert_equal( 0, Gem::Version::Part.new("b") <=> Gem::Version::Part.new("b"))
305
- assert_equal( 1, Gem::Version::Part.new("b") <=> Gem::Version::Part.new("a"))
154
+ def refute_prerelease version
155
+ refute v(version).prerelease?, "#{version} is NOT a prerelease"
156
+ end
306
157
 
307
- assert_equal(-1, Gem::Version::Part.new("a") <=> Gem::Version::Part.new(1))
308
- assert_equal( 1, Gem::Version::Part.new(1) <=> Gem::Version::Part.new("a"))
158
+ # Refute the assumption that two versions are eql?. Checks both
159
+ # directions.
160
+
161
+ def refute_version_eql first, second
162
+ first, second = v(first), v(second)
163
+ refute first.eql?(second), "#{first} is NOT eql? #{second}"
164
+ refute second.eql?(first), "#{second} is NOT eql? #{first}"
309
165
  end
310
166
 
311
- def test_succ
312
- assert_equal 2, Gem::Version::Part.new(1).succ.value
313
- assert_equal "b", Gem::Version::Part.new("a").succ.value
167
+ # Refute the assumption that the two versions are equal?.
168
+
169
+ def refute_version_equal unexpected, actual
170
+ refute_equal v(unexpected), v(actual)
314
171
  end
315
172
  end
316
-