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,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/commands/server_command'
3
3
 
4
4
  class TestGemCommandsServerCommand < RubyGemTestCase
@@ -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/commands/sources_command'
3
3
 
4
4
  class TestGemCommandsSourcesCommand < RubyGemTestCase
@@ -115,48 +115,9 @@ beta-gems.example.com is not a URI
115
115
  assert_equal '', @ui.error
116
116
  end
117
117
 
118
- def test_execute_add_legacy
119
- util_setup_fake_fetcher
120
- util_setup_source_info_cache
121
-
122
- si = Gem::SourceIndex.new
123
- si.add_spec @a1
124
-
125
- @fetcher.data["#{@new_repo}/yaml"] = ''
126
-
127
- @cmd.handle_options %W[--add #{@new_repo}]
128
-
129
- use_ui @ui do
130
- @cmd.execute
131
- end
132
-
133
- assert_equal [@gem_repo], Gem.sources
134
-
135
- expected = <<-EOF
136
- WARNING: RubyGems 1.2+ index not found for:
137
- \t#{@new_repo}
138
-
139
- Will cause RubyGems to revert to legacy indexes, degrading performance.
140
- EOF
141
-
142
- assert_equal "#{@new_repo} added to sources\n", @ui.output
143
- assert_equal expected, @ui.error
144
- end
145
-
146
118
  def test_execute_clear_all
147
119
  @cmd.handle_options %w[--clear-all]
148
120
 
149
- util_setup_source_info_cache
150
-
151
- cache = Gem::SourceInfoCache.cache
152
- cache.update
153
- cache.write_cache
154
-
155
- assert File.exist?(cache.system_cache_file),
156
- 'system cache file'
157
- assert File.exist?(cache.latest_system_cache_file),
158
- 'latest system cache file'
159
-
160
121
  util_setup_spec_fetcher
161
122
 
162
123
  fetcher = Gem::SpecFetcher.fetcher
@@ -179,11 +140,6 @@ Will cause RubyGems to revert to legacy indexes, degrading performance.
179
140
  assert_equal expected, @ui.output
180
141
  assert_equal '', @ui.error
181
142
 
182
- refute File.exist?(cache.system_cache_file),
183
- 'system cache file'
184
- refute File.exist?(cache.latest_system_cache_file),
185
- 'latest system cache file'
186
-
187
143
  refute File.exist?(fetcher.dir), 'cache dir removed'
188
144
  end
189
145
 
@@ -249,30 +205,5 @@ Will cause RubyGems to revert to legacy indexes, degrading performance.
249
205
  assert_equal '', @ui.error
250
206
  end
251
207
 
252
- def test_execute_update_legacy
253
- @cmd.handle_options %w[--update]
254
-
255
- util_setup_fake_fetcher
256
- util_setup_source_info_cache
257
- Gem::SourceInfoCache.reset
258
-
259
- si = Gem::SourceIndex.new
260
- si.add_spec @a1
261
- @fetcher.data["#{@gem_repo}yaml"] = YAML.dump si
262
- @fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}"] = si.dump
263
-
264
- use_ui @ui do
265
- @cmd.execute
266
- end
267
-
268
- expected = <<-EOF
269
- Bulk updating Gem source index for: #{@gem_repo}
270
- source cache successfully updated
271
- EOF
272
-
273
- assert_equal expected, @ui.output
274
- assert_equal '', @ui.error
275
- end
276
-
277
208
  end
278
209
 
@@ -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/commands/specification_command'
3
3
 
4
4
  class TestGemCommandsSpecificationCommand < RubyGemTestCase
@@ -80,7 +80,7 @@ class TestGemCommandsSpecificationCommand < RubyGemTestCase
80
80
  @cmd.execute
81
81
  end
82
82
 
83
- assert_equal "--- foo\n\n", @ui.output
83
+ assert_equal "foo", YAML.load(@ui.output)
84
84
  end
85
85
 
86
86
  def test_execute_marshal
@@ -106,8 +106,7 @@ class TestGemCommandsSpecificationCommand < RubyGemTestCase
106
106
 
107
107
  util_setup_spec_fetcher foo
108
108
 
109
- FileUtils.rm File.join(@gemhome, 'specifications',
110
- "#{foo.full_name}.gemspec")
109
+ FileUtils.rm File.join(@gemhome, 'specifications', foo.spec_name)
111
110
 
112
111
  @cmd.options[:args] = %w[foo]
113
112
  @cmd.options[:domain] = :remote
@@ -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/commands/stale_command'
3
3
 
4
4
  class TestGemCommandsStaleCommand < RubyGemTestCase
@@ -1,6 +1,5 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
2
- require File.join(File.expand_path(File.dirname(__FILE__)),
3
- 'gem_installer_test_case')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require File.expand_path('../gem_installer_test_case', __FILE__)
4
3
  require 'rubygems/commands/uninstall_command'
5
4
 
6
5
  class TestGemCommandsUninstallCommand < GemInstallerTestCase
@@ -60,7 +59,7 @@ class TestGemCommandsUninstallCommand < GemInstallerTestCase
60
59
 
61
60
  def test_execute_prerelease
62
61
  @spec = quick_gem "pre", "2.b"
63
- @gem = File.join @tempdir, "#{@spec.full_name}.gem"
62
+ @gem = File.join @tempdir, @spec.file_name
64
63
  FileUtils.touch @gem
65
64
 
66
65
  util_setup_gem
@@ -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/commands/unpack_command'
3
3
 
4
4
  class TestGemCommandsUnpackCommand < RubyGemTestCase
@@ -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/commands/update_command'
3
3
 
4
4
  class TestGemCommandsUpdateCommand < RubyGemTestCase
@@ -13,14 +13,14 @@ class TestGemCommandsUpdateCommand < RubyGemTestCase
13
13
 
14
14
  util_setup_fake_fetcher
15
15
 
16
- @a1_path = File.join @gemhome, 'cache', "#{@a1.full_name}.gem"
17
- @a2_path = File.join @gemhome, 'cache', "#{@a2.full_name}.gem"
16
+ @a1_path = File.join @gemhome, 'cache', @a1.file_name
17
+ @a2_path = File.join @gemhome, 'cache', @a2.file_name
18
18
 
19
19
  util_setup_spec_fetcher @a1, @a2
20
20
 
21
- @fetcher.data["#{@gem_repo}gems/#{@a1.full_name}.gem"] =
21
+ @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
22
22
  read_binary @a1_path
23
- @fetcher.data["#{@gem_repo}gems/#{@a2.full_name}.gem"] =
23
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
24
24
  read_binary @a2_path
25
25
  end
26
26
 
@@ -65,9 +65,9 @@ class TestGemCommandsUpdateCommand < RubyGemTestCase
65
65
  @a2.add_dependency 'c', '2'
66
66
  @a2.add_dependency 'b', '2'
67
67
 
68
- @b2_path = File.join @gemhome, 'cache', "#{@b2.full_name}.gem"
69
- @c1_2_path = File.join @gemhome, 'cache', "#{@c1_2.full_name}.gem"
70
- @c2_path = File.join @gemhome, 'cache', "#{@c2.full_name}.gem"
68
+ @b2_path = File.join @gemhome, 'cache', @b2.file_name
69
+ @c1_2_path = File.join @gemhome, 'cache', @c1_2.file_name
70
+ @c2_path = File.join @gemhome, 'cache', @c2.file_name
71
71
 
72
72
  @source_index = Gem::SourceIndex.new
73
73
  @source_index.add_spec @a1
@@ -80,12 +80,12 @@ class TestGemCommandsUpdateCommand < RubyGemTestCase
80
80
  util_build_gem @a2
81
81
  util_build_gem @c2
82
82
 
83
- @fetcher.data["#{@gem_repo}gems/#{@a1.full_name}.gem"] = read_binary @a1_path
84
- @fetcher.data["#{@gem_repo}gems/#{@a2.full_name}.gem"] = read_binary @a2_path
85
- @fetcher.data["#{@gem_repo}gems/#{@b2.full_name}.gem"] = read_binary @b2_path
86
- @fetcher.data["#{@gem_repo}gems/#{@c1_2.full_name}.gem"] =
83
+ @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = read_binary @a1_path
84
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = read_binary @a2_path
85
+ @fetcher.data["#{@gem_repo}gems/#{@b2.file_name}"] = read_binary @b2_path
86
+ @fetcher.data["#{@gem_repo}gems/#{@c1_2.file_name}"] =
87
87
  read_binary @c1_2_path
88
- @fetcher.data["#{@gem_repo}gems/#{@c2.full_name}.gem"] = read_binary @c2_path
88
+ @fetcher.data["#{@gem_repo}gems/#{@c2.file_name}"] = read_binary @c2_path
89
89
 
90
90
  util_setup_spec_fetcher @a1, @a2, @b2, @c1_2, @c2
91
91
  util_clear_gems
@@ -0,0 +1,66 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'rubygems/commands/which_command'
3
+
4
+ class TestGemCommandsWhichCommand < RubyGemTestCase
5
+
6
+ def setup
7
+ super
8
+ @cmd = Gem::Commands::WhichCommand.new
9
+ end
10
+
11
+ def test_execute
12
+ util_foo_bar
13
+
14
+ @cmd.handle_options %w[foo_bar]
15
+
16
+ use_ui @ui do
17
+ @cmd.execute
18
+ end
19
+
20
+ assert_equal "#{@foo_bar.full_gem_path}/lib/foo_bar.rb\n", @ui.output
21
+ assert_equal '', @ui.error
22
+ end
23
+
24
+ def test_execute_one_missing
25
+ util_foo_bar
26
+
27
+ @cmd.handle_options %w[foo_bar missing]
28
+
29
+ use_ui @ui do
30
+ @cmd.execute
31
+ end
32
+
33
+ assert_equal "#{@foo_bar.full_gem_path}/lib/foo_bar.rb\n", @ui.output
34
+ assert_match %r%Can't find ruby library file or shared library missing\n%,
35
+ @ui.error
36
+ end
37
+
38
+ def test_execute_missing
39
+ @cmd.handle_options %w[missing]
40
+
41
+ use_ui @ui do
42
+ assert_raises MockGemUi::TermError do
43
+ @cmd.execute
44
+ end
45
+ end
46
+
47
+ assert_equal '', @ui.output
48
+ assert_match %r%Can't find ruby library file or shared library missing\n%,
49
+ @ui.error
50
+ end
51
+
52
+ def util_foo_bar
53
+ files = %w[lib/foo_bar.rb Rakefile]
54
+ @foo_bar = quick_gem 'foo_bar' do |gem|
55
+ gem.files = files
56
+ end
57
+
58
+ files.each do |file|
59
+ filename = @foo_bar.full_gem_path + "/#{file}"
60
+ FileUtils.mkdir_p File.dirname(filename)
61
+ FileUtils.touch filename
62
+ end
63
+ end
64
+
65
+ end
66
+
@@ -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/config_file'
9
3
 
10
4
  class TestGemConfigFile < RubyGemTestCase
@@ -271,6 +265,18 @@ class TestGemConfigFile < RubyGemTestCase
271
265
  assert_equal %w[http://even-more-gems.example.com], Gem.sources
272
266
  end
273
267
 
268
+ def test_load_rubygems_api_key_from_credentials
269
+ temp_cred = File.join Gem.user_home, '.gem', 'credentials'
270
+ FileUtils.mkdir File.dirname(temp_cred)
271
+ File.open temp_cred, 'w' do |fp|
272
+ fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
273
+ end
274
+
275
+ util_config_file
276
+
277
+ assert_equal "701229f217cdf23b1344c7b4b54ca97", @cfg.rubygems_api_key
278
+ end
279
+
274
280
  def util_config_file(args = @cfg_args)
275
281
  @cfg = Gem::ConfigFile.new args
276
282
  end
@@ -1,189 +1,137 @@
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/dependency'
9
3
 
10
4
  class TestGemDependency < RubyGemTestCase
11
5
 
12
- def setup
13
- super
14
-
15
- @pkg1_0 = Gem::Dependency.new 'pkg', ['> 1.0']
16
- @pkg1_1 = Gem::Dependency.new 'pkg', ['> 1.1']
17
-
18
- @oth1_0 = Gem::Dependency.new 'other', ['> 1.0']
6
+ def test_subclass
7
+ sc = Class.new Gem::Dependency
8
+ def sc.requirement() bogus; end
19
9
 
20
- @r1_0 = Gem::Requirement.new ['> 1.0']
21
- end
10
+ out, err = capture_io do
11
+ assert_equal Gem::Requirement.default, sc.new('a').version_requirement
12
+ end
22
13
 
23
- def dep(name, version)
24
- Gem::Dependency.new name, version
14
+ assert_match %r%deprecated%, err
25
15
  end
26
16
 
27
17
  def test_initialize
28
- assert_equal "pkg", @pkg1_0.name
29
- assert_equal @r1_0, @pkg1_0.version_requirements
18
+ d = dep "pkg", "> 1.0"
19
+
20
+ assert_equal "pkg", d.name
21
+ assert_equal req("> 1.0"), d.requirement
30
22
  end
31
23
 
32
24
  def test_initialize_double
33
- dep = Gem::Dependency.new("pkg", ["> 1.0", "< 2.0"])
34
-
35
- assert_equal Gem::Requirement.new(["> 1.0", "< 2.0"]),
36
- dep.version_requirements
25
+ d = dep "pkg", "> 1.0", "< 2.0"
26
+ assert_equal req("> 1.0", "< 2.0"), d.requirement
37
27
  end
38
28
 
39
29
  def test_initialize_empty
40
- dep = Gem::Dependency.new("pkg", [])
41
- req = @r1_0
42
-
43
- req.instance_eval do
44
- @version = ">= 1.0"
45
- @op = ">="
46
- @nums = [1,0]
47
- @requirements = nil
48
- end
49
-
50
- dep.instance_eval do
51
- @version_requirement = req
52
- @version_requirements = nil
53
- end
54
-
55
- assert_equal Gem::Requirement.new([">= 1.0"]), dep.version_requirements
56
- end
57
-
58
- def test_initialize_version
59
- dep = Gem::Dependency.new 'pkg', Gem::Version.new('2')
60
-
61
- assert_equal 'pkg', dep.name
62
-
63
- assert_equal Gem::Requirement.new('= 2'), dep.version_requirements
30
+ d = dep "pkg"
31
+ assert_equal req(">= 0"), d.requirement
64
32
  end
65
33
 
66
- def test_initialize_with_type
67
- dep = Gem::Dependency.new("pkg", [], :development)
68
- assert_equal(:development, dep.type)
69
- end
34
+ def test_initialize_type
35
+ assert_equal :runtime, dep("pkg").type
36
+ assert_equal :development, dep("pkg", [], :development).type
70
37
 
71
- def test_type_is_runtime_by_default
72
- assert_equal(:runtime, Gem::Dependency.new("pkg", []).type)
73
- end
74
-
75
- def test_type_is_restricted
76
38
  assert_raises ArgumentError do
77
- Gem::Dependency.new("pkg", [:sometimes])
39
+ dep "pkg", :sometimes
78
40
  end
79
41
  end
80
42
 
43
+ def test_initialize_version
44
+ d = dep "pkg", v("2")
45
+ assert_equal req("= 2"), d.requirement
46
+ end
47
+
81
48
  def test_equals2
82
- assert_equal @pkg1_0, @pkg1_0.dup
83
- assert_equal @pkg1_0.dup, @pkg1_0
49
+ o = dep "other"
50
+ d = dep "pkg", "> 1.0"
51
+ d1 = dep "pkg", "> 1.1"
52
+
53
+ assert_equal d, d.dup
54
+ assert_equal d.dup, d
84
55
 
85
- refute_equal @pkg1_0, @pkg1_1, "requirements different"
86
- refute_equal @pkg1_1, @pkg1_0, "requirements different"
56
+ refute_equal d, d1
57
+ refute_equal d1, d
87
58
 
88
- refute_equal @pkg1_0, @oth1_0, "names different"
89
- refute_equal @oth1_0, @pkg1_0, "names different"
59
+ refute_equal d, o
60
+ refute_equal o, d
90
61
 
91
- refute_equal @pkg1_0, Object.new
92
- refute_equal Object.new, @pkg1_0
62
+ refute_equal d, Object.new
63
+ refute_equal Object.new, d
93
64
  end
94
65
 
95
66
  def test_equals2_type
96
- runtime = Gem::Dependency.new("pkg", [])
97
- development = Gem::Dependency.new("pkg", [], :development)
98
-
99
- refute_equal(runtime, development)
67
+ refute_equal dep("pkg", :runtime), dep("pkg", :development)
100
68
  end
101
69
 
102
70
  def test_equals_tilde
103
- a0 = dep 'a', '0'
104
- a1 = dep 'a', '1'
105
- b0 = dep 'b', '0'
106
-
107
- pa0 = dep 'a', '>= 0'
108
- pa0r = dep(/a/, '>= 0')
109
- pab0r = dep(/a|b/, '>= 0')
110
-
111
- assert_match a0, a0, 'match self'
112
- assert_match pa0, a0, 'match version exact'
113
- assert_match pa0, a1, 'match version'
114
- assert_match pa0r, a0, 'match regex simple'
115
- assert_match pab0r, a0, 'match regex complex'
116
-
117
- refute_match pa0r, b0, 'fail match regex'
118
- refute_match pa0r, Object.new, 'fail match Object'
119
- end
71
+ d = dep "a", "0"
120
72
 
121
- def test_equals_tilde_escape
122
- a1 = Gem::Dependency.new 'a', '1'
73
+ assert_match d, d, "matche self"
74
+ assert_match dep("a", ">= 0"), d, "match version exact"
75
+ assert_match dep("a", ">= 0"), dep("a", "1"), "match version"
76
+ assert_match dep(/a/, ">= 0"), d, "match simple regexp"
77
+ assert_match dep(/a|b/, ">= 0"), d, "match scary regexp"
123
78
 
124
- pab1 = Gem::Dependency.new 'a|b', '>= 1'
125
- pab1r = Gem::Dependency.new(/a|b/, '>= 1')
79
+ refute_match dep(/a/), dep("b")
80
+ refute_match dep("a"), Object.new
81
+ end
126
82
 
127
- refute_match pab1, a1, 'escaped'
128
- assert_match pab1r, a1, 'exact regexp'
83
+ def test_equals_tilde_escape
84
+ refute_match dep("a|b"), dep("a", "1")
85
+ assert_match dep(/a|b/), dep("a", "1")
129
86
  end
130
87
 
131
88
  def test_equals_tilde_object
132
- a0 = Object.new
133
-
134
- def a0.name() 'a' end
135
- def a0.version() '0' end
136
-
137
- pa0 = Gem::Dependency.new 'a', '>= 0'
89
+ o = Object.new
90
+ def o.name ; 'a' end
91
+ def o.version ; '0' end
138
92
 
139
- assert_match pa0, a0, 'match version exact'
93
+ assert_match dep("a"), o
140
94
  end
141
95
 
142
96
  def test_equals_tilde_spec
143
- def spec(name, version)
144
- Gem::Specification.new do |spec|
145
- spec.name = name
146
- spec.version = version
147
- end
148
- end
97
+ assert_match dep("a", ">= 0"), spec("a", "0")
98
+ assert_match dep("a", "1"), spec("a", "1")
99
+ assert_match dep(/a/, ">= 0"), spec("a", "0")
100
+ assert_match dep(/a|b/, ">= 0"), spec("b", "0")
101
+ refute_match dep(/a/, ">= 0"), spec("b", "0")
102
+ end
149
103
 
150
- a0 = spec 'a', '0'
151
- a1 = spec 'a', '1'
152
- b0 = spec 'b', '0'
104
+ def test_hash
105
+ d = dep "pkg", "1.0"
153
106
 
154
- pa0 = dep 'a', '>= 0'
155
- pa0r = dep(/a/, '>= 0')
156
- pab0r = dep(/a|b/, '>= 0')
107
+ assert_equal d.hash, d.dup.hash
108
+ assert_equal d.dup.hash, d.hash
157
109
 
158
- assert_match pa0, a0, 'match version exact'
159
- assert_match pa0, a1, 'match version'
110
+ refute_equal dep("pkg", "1.0").hash, dep("pkg", "2.0").hash, "requirement"
111
+ refute_equal dep("pkg", "1.0").hash, dep("abc", "1.0").hash, "name"
112
+ refute_equal dep("pkg", :development), dep("pkg", :runtime), "type"
113
+ end
160
114
 
161
- assert_match pa0r, a0, 'match regex simple'
162
- assert_match pa0r, a1, 'match regex simple'
115
+ def test_prerelease_eh
116
+ d = dep "pkg", "= 1"
163
117
 
164
- assert_match pab0r, a0, 'match regex complex'
165
- assert_match pab0r, b0, 'match regex complex'
118
+ refute d.prerelease?
166
119
 
167
- refute_match pa0r, b0, 'fail match regex'
168
- refute_match pa0r, Object.new, 'fail match Object'
169
- end
120
+ d.prerelease = true
170
121
 
171
- def test_hash
172
- assert_equal @pkg1_0.hash, @pkg1_0.dup.hash
173
- assert_equal @pkg1_0.dup.hash, @pkg1_0.hash
122
+ assert d.prerelease?
174
123
 
175
- refute_equal @pkg1_0.hash, @pkg1_1.hash, "requirements different"
176
- refute_equal @pkg1_1.hash, @pkg1_0.hash, "requirements different"
124
+ d = dep "pkg", "= 1.a"
177
125
 
178
- refute_equal @pkg1_0.hash, @oth1_0.hash, "names different"
179
- refute_equal @oth1_0.hash, @pkg1_0.hash, "names different"
180
- end
126
+ assert d.prerelease?
127
+
128
+ d.prerelease = false
129
+
130
+ assert d.prerelease?
181
131
 
182
- def test_hash_type
183
- runtime = Gem::Dependency.new("pkg", [])
184
- development = Gem::Dependency.new("pkg", [], :development)
132
+ d = dep "pkg", "> 1.a", "> 2"
185
133
 
186
- refute_equal(runtime.hash, development.hash)
134
+ assert d.prerelease?
187
135
  end
188
136
 
189
137
  end