slimgems 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. data/ChangeLog +5811 -0
  2. data/History.txt +887 -0
  3. data/LICENSE.txt +51 -0
  4. data/README.md +87 -0
  5. data/Rakefile +120 -0
  6. data/bin/gem +25 -0
  7. data/bin/update_slimgems +35 -0
  8. data/bootstrap/Rakefile +4 -0
  9. data/hide_lib_for_update/note.txt +5 -0
  10. data/lib/gauntlet_rubygems.rb +50 -0
  11. data/lib/rbconfig/datadir.rb +20 -0
  12. data/lib/rubygems.rb +1220 -0
  13. data/lib/rubygems/builder.rb +102 -0
  14. data/lib/rubygems/command.rb +534 -0
  15. data/lib/rubygems/command_manager.rb +182 -0
  16. data/lib/rubygems/commands/build_command.rb +53 -0
  17. data/lib/rubygems/commands/cert_command.rb +86 -0
  18. data/lib/rubygems/commands/check_command.rb +80 -0
  19. data/lib/rubygems/commands/cleanup_command.rb +106 -0
  20. data/lib/rubygems/commands/contents_command.rb +98 -0
  21. data/lib/rubygems/commands/dependency_command.rb +195 -0
  22. data/lib/rubygems/commands/environment_command.rb +132 -0
  23. data/lib/rubygems/commands/fetch_command.rb +67 -0
  24. data/lib/rubygems/commands/generate_index_command.rb +133 -0
  25. data/lib/rubygems/commands/help_command.rb +172 -0
  26. data/lib/rubygems/commands/install_command.rb +178 -0
  27. data/lib/rubygems/commands/list_command.rb +35 -0
  28. data/lib/rubygems/commands/lock_command.rb +110 -0
  29. data/lib/rubygems/commands/mirror_command.rb +111 -0
  30. data/lib/rubygems/commands/outdated_command.rb +33 -0
  31. data/lib/rubygems/commands/owner_command.rb +75 -0
  32. data/lib/rubygems/commands/pristine_command.rb +93 -0
  33. data/lib/rubygems/commands/push_command.rb +56 -0
  34. data/lib/rubygems/commands/query_command.rb +280 -0
  35. data/lib/rubygems/commands/rdoc_command.rb +91 -0
  36. data/lib/rubygems/commands/search_command.rb +31 -0
  37. data/lib/rubygems/commands/server_command.rb +86 -0
  38. data/lib/rubygems/commands/setup_command.rb +387 -0
  39. data/lib/rubygems/commands/sources_command.rb +157 -0
  40. data/lib/rubygems/commands/specification_command.rb +125 -0
  41. data/lib/rubygems/commands/stale_command.rb +27 -0
  42. data/lib/rubygems/commands/uninstall_command.rb +83 -0
  43. data/lib/rubygems/commands/unpack_command.rb +121 -0
  44. data/lib/rubygems/commands/update_command.rb +212 -0
  45. data/lib/rubygems/commands/which_command.rb +86 -0
  46. data/lib/rubygems/config_file.rb +345 -0
  47. data/lib/rubygems/custom_require.rb +44 -0
  48. data/lib/rubygems/defaults.rb +101 -0
  49. data/lib/rubygems/dependency.rb +227 -0
  50. data/lib/rubygems/dependency_installer.rb +286 -0
  51. data/lib/rubygems/dependency_list.rb +208 -0
  52. data/lib/rubygems/doc_manager.rb +242 -0
  53. data/lib/rubygems/errors.rb +35 -0
  54. data/lib/rubygems/exceptions.rb +91 -0
  55. data/lib/rubygems/ext.rb +18 -0
  56. data/lib/rubygems/ext/builder.rb +56 -0
  57. data/lib/rubygems/ext/configure_builder.rb +25 -0
  58. data/lib/rubygems/ext/ext_conf_builder.rb +24 -0
  59. data/lib/rubygems/ext/rake_builder.rb +39 -0
  60. data/lib/rubygems/format.rb +81 -0
  61. data/lib/rubygems/gem_openssl.rb +92 -0
  62. data/lib/rubygems/gem_path_searcher.rb +100 -0
  63. data/lib/rubygems/gem_runner.rb +79 -0
  64. data/lib/rubygems/gemcutter_utilities.rb +49 -0
  65. data/lib/rubygems/indexer.rb +720 -0
  66. data/lib/rubygems/install_update_options.rb +125 -0
  67. data/lib/rubygems/installer.rb +604 -0
  68. data/lib/rubygems/local_remote_options.rb +135 -0
  69. data/lib/rubygems/old_format.rb +153 -0
  70. data/lib/rubygems/package.rb +97 -0
  71. data/lib/rubygems/package/f_sync_dir.rb +23 -0
  72. data/lib/rubygems/package/tar_header.rb +266 -0
  73. data/lib/rubygems/package/tar_input.rb +222 -0
  74. data/lib/rubygems/package/tar_output.rb +144 -0
  75. data/lib/rubygems/package/tar_reader.rb +106 -0
  76. data/lib/rubygems/package/tar_reader/entry.rb +141 -0
  77. data/lib/rubygems/package/tar_writer.rb +241 -0
  78. data/lib/rubygems/package_task.rb +126 -0
  79. data/lib/rubygems/platform.rb +183 -0
  80. data/lib/rubygems/remote_fetcher.rb +414 -0
  81. data/lib/rubygems/require_paths_builder.rb +18 -0
  82. data/lib/rubygems/requirement.rb +153 -0
  83. data/lib/rubygems/security.rb +814 -0
  84. data/lib/rubygems/server.rb +872 -0
  85. data/lib/rubygems/source_index.rb +597 -0
  86. data/lib/rubygems/source_info_cache.rb +395 -0
  87. data/lib/rubygems/source_info_cache_entry.rb +56 -0
  88. data/lib/rubygems/spec_fetcher.rb +337 -0
  89. data/lib/rubygems/specification.rb +1486 -0
  90. data/lib/rubygems/test_utilities.rb +147 -0
  91. data/lib/rubygems/text.rb +65 -0
  92. data/lib/rubygems/uninstaller.rb +278 -0
  93. data/lib/rubygems/user_interaction.rb +527 -0
  94. data/lib/rubygems/validator.rb +240 -0
  95. data/lib/rubygems/version.rb +316 -0
  96. data/lib/rubygems/version_option.rb +65 -0
  97. data/lib/ubygems.rb +10 -0
  98. data/setup.rb +42 -0
  99. data/test/bogussources.rb +8 -0
  100. data/test/data/gem-private_key.pem +27 -0
  101. data/test/data/gem-public_cert.pem +20 -0
  102. data/test/fake_certlib/openssl.rb +7 -0
  103. data/test/foo/discover.rb +0 -0
  104. data/test/functional.rb +92 -0
  105. data/test/gem_installer_test_case.rb +97 -0
  106. data/test/gem_package_tar_test_case.rb +132 -0
  107. data/test/gemutilities.rb +605 -0
  108. data/test/insure_session.rb +43 -0
  109. data/test/mockgemui.rb +56 -0
  110. data/test/plugin/exception/rubygems_plugin.rb +2 -0
  111. data/test/plugin/load/rubygems_plugin.rb +1 -0
  112. data/test/plugin/standarderror/rubygems_plugin.rb +2 -0
  113. data/test/private_key.pem +27 -0
  114. data/test/public_cert.pem +20 -0
  115. data/test/rubygems_plugin.rb +21 -0
  116. data/test/simple_gem.rb +66 -0
  117. data/test/test_config.rb +12 -0
  118. data/test/test_gem.rb +766 -0
  119. data/test/test_gem_builder.rb +27 -0
  120. data/test/test_gem_command.rb +178 -0
  121. data/test/test_gem_command_manager.rb +207 -0
  122. data/test/test_gem_commands_build_command.rb +74 -0
  123. data/test/test_gem_commands_cert_command.rb +124 -0
  124. data/test/test_gem_commands_check_command.rb +18 -0
  125. data/test/test_gem_commands_contents_command.rb +156 -0
  126. data/test/test_gem_commands_dependency_command.rb +216 -0
  127. data/test/test_gem_commands_environment_command.rb +144 -0
  128. data/test/test_gem_commands_fetch_command.rb +76 -0
  129. data/test/test_gem_commands_generate_index_command.rb +135 -0
  130. data/test/test_gem_commands_install_command.rb +315 -0
  131. data/test/test_gem_commands_list_command.rb +36 -0
  132. data/test/test_gem_commands_lock_command.rb +68 -0
  133. data/test/test_gem_commands_mirror_command.rb +60 -0
  134. data/test/test_gem_commands_outdated_command.rb +40 -0
  135. data/test/test_gem_commands_owner_command.rb +105 -0
  136. data/test/test_gem_commands_pristine_command.rb +108 -0
  137. data/test/test_gem_commands_push_command.rb +81 -0
  138. data/test/test_gem_commands_query_command.rb +426 -0
  139. data/test/test_gem_commands_server_command.rb +59 -0
  140. data/test/test_gem_commands_sources_command.rb +209 -0
  141. data/test/test_gem_commands_specification_command.rb +139 -0
  142. data/test/test_gem_commands_stale_command.rb +38 -0
  143. data/test/test_gem_commands_uninstall_command.rb +83 -0
  144. data/test/test_gem_commands_unpack_command.rb +199 -0
  145. data/test/test_gem_commands_update_command.rb +353 -0
  146. data/test/test_gem_commands_which_command.rb +66 -0
  147. data/test/test_gem_config_file.rb +287 -0
  148. data/test/test_gem_dependency.rb +149 -0
  149. data/test/test_gem_dependency_installer.rb +661 -0
  150. data/test/test_gem_dependency_list.rb +230 -0
  151. data/test/test_gem_doc_manager.rb +31 -0
  152. data/test/test_gem_ext_configure_builder.rb +84 -0
  153. data/test/test_gem_ext_ext_conf_builder.rb +173 -0
  154. data/test/test_gem_ext_rake_builder.rb +81 -0
  155. data/test/test_gem_format.rb +70 -0
  156. data/test/test_gem_gem_path_searcher.rb +78 -0
  157. data/test/test_gem_gem_runner.rb +45 -0
  158. data/test/test_gem_gemcutter_utilities.rb +103 -0
  159. data/test/test_gem_indexer.rb +673 -0
  160. data/test/test_gem_install_update_options.rb +68 -0
  161. data/test/test_gem_installer.rb +857 -0
  162. data/test/test_gem_local_remote_options.rb +97 -0
  163. data/test/test_gem_package_tar_header.rb +130 -0
  164. data/test/test_gem_package_tar_input.rb +112 -0
  165. data/test/test_gem_package_tar_output.rb +97 -0
  166. data/test/test_gem_package_tar_reader.rb +46 -0
  167. data/test/test_gem_package_tar_reader_entry.rb +109 -0
  168. data/test/test_gem_package_tar_writer.rb +144 -0
  169. data/test/test_gem_package_task.rb +59 -0
  170. data/test/test_gem_platform.rb +264 -0
  171. data/test/test_gem_remote_fetcher.rb +740 -0
  172. data/test/test_gem_requirement.rb +292 -0
  173. data/test/test_gem_server.rb +356 -0
  174. data/test/test_gem_silent_ui.rb +113 -0
  175. data/test/test_gem_source_index.rb +461 -0
  176. data/test/test_gem_spec_fetcher.rb +410 -0
  177. data/test/test_gem_specification.rb +1291 -0
  178. data/test/test_gem_stream_ui.rb +218 -0
  179. data/test/test_gem_text.rb +43 -0
  180. data/test/test_gem_uninstaller.rb +146 -0
  181. data/test/test_gem_validator.rb +63 -0
  182. data/test/test_gem_version.rb +181 -0
  183. data/test/test_gem_version_option.rb +89 -0
  184. data/test/test_kernel.rb +59 -0
  185. metadata +413 -0
@@ -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
+
@@ -0,0 +1,287 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'rubygems/config_file'
3
+
4
+ class TestGemConfigFile < RubyGemTestCase
5
+
6
+ def setup
7
+ super
8
+
9
+ @temp_conf = File.join @tempdir, '.gemrc'
10
+
11
+ @cfg_args = %W[--config-file #{@temp_conf}]
12
+
13
+ @orig_SYSTEM_WIDE_CONFIG_FILE = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE
14
+ Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
15
+ Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
16
+ File.join(@tempdir, 'system-gemrc')
17
+ Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear
18
+ Gem::ConfigFile::PLATFORM_DEFAULTS.clear
19
+
20
+ util_config_file
21
+ end
22
+
23
+ def teardown
24
+ Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear
25
+ Gem::ConfigFile::PLATFORM_DEFAULTS.clear
26
+ Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
27
+ Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
28
+ @orig_SYSTEM_WIDE_CONFIG_FILE
29
+
30
+ super
31
+ end
32
+
33
+ def test_initialize
34
+ assert_equal @temp_conf, @cfg.config_file_name
35
+
36
+ assert_equal false, @cfg.backtrace
37
+ assert_equal true, @cfg.update_sources
38
+ assert_equal false, @cfg.benchmark
39
+ assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold
40
+ assert_equal true, @cfg.verbose
41
+ assert_equal [@gem_repo], Gem.sources
42
+
43
+ File.open @temp_conf, 'w' do |fp|
44
+ fp.puts ":backtrace: true"
45
+ fp.puts ":update_sources: false"
46
+ fp.puts ":benchmark: true"
47
+ fp.puts ":bulk_threshold: 10"
48
+ fp.puts ":verbose: false"
49
+ fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
50
+ fp.puts ":sources:"
51
+ fp.puts " - http://more-gems.example.com"
52
+ fp.puts "install: --wrappers"
53
+ fp.puts ":gempath:"
54
+ fp.puts "- /usr/ruby/1.8/lib/ruby/gems/1.8"
55
+ fp.puts "- /var/ruby/1.8/gem_home"
56
+ end
57
+
58
+ util_config_file
59
+
60
+ assert_equal true, @cfg.backtrace
61
+ assert_equal true, @cfg.benchmark
62
+ assert_equal 10, @cfg.bulk_threshold
63
+ assert_equal false, @cfg.verbose
64
+ assert_equal false, @cfg.update_sources
65
+ assert_equal "701229f217cdf23b1344c7b4b54ca97", @cfg.rubygems_api_key
66
+ assert_equal %w[http://more-gems.example.com], Gem.sources
67
+ assert_equal '--wrappers', @cfg[:install]
68
+ assert_equal(['/usr/ruby/1.8/lib/ruby/gems/1.8', '/var/ruby/1.8/gem_home'],
69
+ @cfg.path)
70
+ end
71
+
72
+ def test_initialize_handle_arguments_config_file
73
+ util_config_file %W[--config-file #{@temp_conf}]
74
+
75
+ assert_equal @temp_conf, @cfg.config_file_name
76
+ end
77
+
78
+ def test_initialize_handle_arguments_config_file_with_other_params
79
+ util_config_file %W[--config-file #{@temp_conf} --backtrace]
80
+
81
+ assert_equal @temp_conf, @cfg.config_file_name
82
+ end
83
+
84
+ def test_initialize_handle_arguments_config_file_equals
85
+ util_config_file %W[--config-file=#{@temp_conf}]
86
+
87
+ assert_equal @temp_conf, @cfg.config_file_name
88
+ end
89
+
90
+ def test_initialize_operating_system_override
91
+ Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS[:bulk_threshold] = 1
92
+ Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS['install'] = '--no-env-shebang'
93
+
94
+ Gem::ConfigFile::PLATFORM_DEFAULTS[:bulk_threshold] = 2
95
+
96
+ util_config_file
97
+
98
+ assert_equal 2, @cfg.bulk_threshold
99
+ assert_equal '--no-env-shebang', @cfg[:install]
100
+ end
101
+
102
+ def test_initialize_platform_override
103
+ Gem::ConfigFile::PLATFORM_DEFAULTS[:bulk_threshold] = 2
104
+ Gem::ConfigFile::PLATFORM_DEFAULTS['install'] = '--no-env-shebang'
105
+
106
+ File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, 'w' do |fp|
107
+ fp.puts ":bulk_threshold: 3"
108
+ end
109
+
110
+ util_config_file
111
+
112
+ assert_equal 3, @cfg.bulk_threshold
113
+ assert_equal '--no-env-shebang', @cfg[:install]
114
+ end
115
+
116
+ def test_initialize_system_wide_override
117
+ File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, 'w' do |fp|
118
+ fp.puts ":backtrace: false"
119
+ fp.puts ":bulk_threshold: 2048"
120
+ end
121
+
122
+ File.open @temp_conf, 'w' do |fp|
123
+ fp.puts ":backtrace: true"
124
+ end
125
+
126
+ util_config_file
127
+
128
+ assert_equal 2048, @cfg.bulk_threshold
129
+ assert_equal true, @cfg.backtrace
130
+ end
131
+
132
+ def test_handle_arguments
133
+ args = %w[--backtrace --bunch --of --args here]
134
+
135
+ @cfg.handle_arguments args
136
+
137
+ assert_equal %w[--bunch --of --args here], @cfg.args
138
+ end
139
+
140
+ def test_handle_arguments_backtrace
141
+ assert_equal false, @cfg.backtrace
142
+
143
+ args = %w[--backtrace]
144
+
145
+ @cfg.handle_arguments args
146
+
147
+ assert_equal true, @cfg.backtrace
148
+ end
149
+
150
+ def test_handle_arguments_benchmark
151
+ assert_equal false, @cfg.benchmark
152
+
153
+ args = %w[--benchmark]
154
+
155
+ @cfg.handle_arguments args
156
+
157
+ assert_equal true, @cfg.benchmark
158
+ end
159
+
160
+ def test_handle_arguments_debug
161
+ old_dollar_DEBUG = $DEBUG
162
+ assert_equal false, $DEBUG
163
+
164
+ args = %w[--debug]
165
+
166
+ @cfg.handle_arguments args
167
+
168
+ assert_equal true, $DEBUG
169
+ ensure
170
+ $DEBUG = old_dollar_DEBUG
171
+ end
172
+
173
+ def test_handle_arguments_override
174
+ File.open @temp_conf, 'w' do |fp|
175
+ fp.puts ":benchmark: false"
176
+ end
177
+
178
+ util_config_file %W[--benchmark --config-file=#{@temp_conf}]
179
+
180
+ assert_equal true, @cfg.benchmark
181
+ end
182
+
183
+ def test_handle_arguments_traceback
184
+ assert_equal false, @cfg.backtrace
185
+
186
+ args = %w[--traceback]
187
+
188
+ @cfg.handle_arguments args
189
+
190
+ assert_equal true, @cfg.backtrace
191
+ end
192
+
193
+ def test_really_verbose
194
+ assert_equal false, @cfg.really_verbose
195
+
196
+ @cfg.verbose = true
197
+
198
+ assert_equal false, @cfg.really_verbose
199
+
200
+ @cfg.verbose = 1
201
+
202
+ assert_equal true, @cfg.really_verbose
203
+ end
204
+
205
+ def test_write
206
+ @cfg.backtrace = true
207
+ @cfg.benchmark = true
208
+ @cfg.update_sources = false
209
+ @cfg.bulk_threshold = 10
210
+ @cfg.verbose = false
211
+ Gem.sources.replace %w[http://more-gems.example.com]
212
+ @cfg[:install] = '--wrappers'
213
+
214
+ @cfg.write
215
+
216
+ util_config_file
217
+
218
+ # These should not be written out to the config file.
219
+ assert_equal false, @cfg.backtrace, 'backtrace'
220
+ assert_equal false, @cfg.benchmark, 'benchmark'
221
+ assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold,
222
+ 'bulk_threshold'
223
+ assert_equal true, @cfg.update_sources, 'update_sources'
224
+ assert_equal true, @cfg.verbose, 'verbose'
225
+
226
+ assert_equal '--wrappers', @cfg[:install], 'install'
227
+
228
+ # this should be written out to the config file.
229
+ assert_equal %w[http://more-gems.example.com], Gem.sources
230
+ end
231
+
232
+ def test_write_from_hash
233
+ File.open @temp_conf, 'w' do |fp|
234
+ fp.puts ":backtrace: true"
235
+ fp.puts ":benchmark: true"
236
+ fp.puts ":bulk_threshold: 10"
237
+ fp.puts ":update_sources: false"
238
+ fp.puts ":verbose: false"
239
+ fp.puts ":sources:"
240
+ fp.puts " - http://more-gems.example.com"
241
+ fp.puts "install: --wrappers"
242
+ end
243
+
244
+ util_config_file
245
+
246
+ @cfg.backtrace = :junk
247
+ @cfg.benchmark = :junk
248
+ @cfg.update_sources = :junk
249
+ @cfg.bulk_threshold = 20
250
+ @cfg.verbose = :junk
251
+ Gem.sources.replace %w[http://even-more-gems.example.com]
252
+ @cfg[:install] = '--wrappers --no-rdoc'
253
+
254
+ @cfg.write
255
+
256
+ util_config_file
257
+
258
+ # These should not be written out to the config file
259
+ assert_equal true, @cfg.backtrace, 'backtrace'
260
+ assert_equal true, @cfg.benchmark, 'benchmark'
261
+ assert_equal 10, @cfg.bulk_threshold, 'bulk_threshold'
262
+ assert_equal false, @cfg.update_sources, 'update_sources'
263
+ assert_equal false, @cfg.verbose, 'verbose'
264
+
265
+ assert_equal '--wrappers --no-rdoc', @cfg[:install], 'install'
266
+
267
+ assert_equal %w[http://even-more-gems.example.com], Gem.sources
268
+ end
269
+
270
+ def test_load_rubygems_api_key_from_credentials
271
+ temp_cred = File.join Gem.user_home, '.gem', 'credentials'
272
+ FileUtils.mkdir File.dirname(temp_cred)
273
+ File.open temp_cred, 'w' do |fp|
274
+ fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
275
+ end
276
+
277
+ util_config_file
278
+
279
+ assert_equal "701229f217cdf23b1344c7b4b54ca97", @cfg.rubygems_api_key
280
+ end
281
+
282
+ def util_config_file(args = @cfg_args)
283
+ @cfg = Gem::ConfigFile.new args
284
+ end
285
+
286
+ end
287
+
@@ -0,0 +1,149 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'rubygems/dependency'
3
+
4
+ class TestGemDependency < RubyGemTestCase
5
+
6
+ def test_subclass
7
+ sc = Class.new Gem::Dependency
8
+ def sc.requirement() bogus; end
9
+
10
+ out, err = capture_io do
11
+ assert_equal Gem::Requirement.default, sc.new('a').version_requirement
12
+ end
13
+
14
+ assert_match %r%deprecated%, err
15
+ end
16
+
17
+ def test_initialize
18
+ d = dep "pkg", "> 1.0"
19
+
20
+ assert_equal "pkg", d.name
21
+ assert_equal req("> 1.0"), d.requirement
22
+ end
23
+
24
+ def test_initialize_double
25
+ d = dep "pkg", "> 1.0", "< 2.0"
26
+ assert_equal req("> 1.0", "< 2.0"), d.requirement
27
+ end
28
+
29
+ def test_initialize_empty
30
+ d = dep "pkg"
31
+ assert_equal req(">= 0"), d.requirement
32
+ end
33
+
34
+ def test_initialize_type
35
+ assert_equal :runtime, dep("pkg").type
36
+ assert_equal :development, dep("pkg", [], :development).type
37
+
38
+ assert_raises ArgumentError do
39
+ dep "pkg", :sometimes
40
+ end
41
+ end
42
+
43
+ def test_initialize_version
44
+ d = dep "pkg", v("2")
45
+ assert_equal req("= 2"), d.requirement
46
+ end
47
+
48
+ def test_equals2
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
55
+
56
+ refute_equal d, d1
57
+ refute_equal d1, d
58
+
59
+ refute_equal d, o
60
+ refute_equal o, d
61
+
62
+ refute_equal d, Object.new
63
+ refute_equal Object.new, d
64
+ end
65
+
66
+ def test_equals2_type
67
+ refute_equal dep("pkg", :runtime), dep("pkg", :development)
68
+ end
69
+
70
+ def test_equals_tilde
71
+ d = dep "a", "0"
72
+
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"
78
+
79
+ refute_match dep(/a/), dep("b")
80
+ refute_match dep("a"), Object.new
81
+ end
82
+
83
+ def test_equals_tilde_escape
84
+ refute_match dep("a|b"), dep("a", "1")
85
+ assert_match dep(/a|b/), dep("a", "1")
86
+ end
87
+
88
+ def test_equals_tilde_object
89
+ o = Object.new
90
+ def o.name ; 'a' end
91
+ def o.version ; '0' end
92
+
93
+ assert_match dep("a"), o
94
+ end
95
+
96
+ def test_equals_tilde_spec
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
103
+
104
+ def test_hash
105
+ d = dep "pkg", "1.0"
106
+
107
+ assert_equal d.hash, d.dup.hash
108
+ assert_equal d.dup.hash, d.hash
109
+
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
114
+
115
+ def test_prerelease_eh
116
+ d = dep "pkg", "= 1"
117
+
118
+ refute d.prerelease?
119
+
120
+ d.prerelease = true
121
+
122
+ assert d.prerelease?
123
+
124
+ d = dep "pkg", "= 1.a"
125
+
126
+ assert d.prerelease?
127
+
128
+ d.prerelease = false
129
+
130
+ assert d.prerelease?
131
+
132
+ d = dep "pkg", "> 1.a", "> 2"
133
+
134
+ assert d.prerelease?
135
+ end
136
+
137
+ def test_version_requirements_equals_deprecated
138
+ d = dep "pkg", "1.0"
139
+
140
+ out, err = capture_io do
141
+ d.version_requirements = '2.0'
142
+ assert_equal Gem::Requirement.new(%w[2.0]), d.requirement
143
+ end
144
+
145
+ assert_match %r%deprecated%, err
146
+ end
147
+
148
+ end
149
+