rubygems-update 0.9.4 → 0.9.5

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 (225) hide show
  1. data/ChangeLog +587 -0
  2. data/README +0 -1
  3. data/Rakefile +39 -12
  4. data/TODO +0 -5
  5. data/bin/gem +7 -7
  6. data/bin/update_rubygems +1 -1
  7. data/examples/application/an-app.gemspec +1 -1
  8. data/gemspecs/cgikit-1.1.0.gemspec +1 -2
  9. data/gemspecs/jabber4r.gemspec +1 -1
  10. data/gemspecs/linguistics.gemspec +1 -1
  11. data/gemspecs/ook.gemspec +1 -1
  12. data/gemspecs/progressbar.gemspec +1 -1
  13. data/gemspecs/redcloth.gemspec +1 -1
  14. data/gemspecs/rublog.gemspec +1 -1
  15. data/gemspecs/ruby-doom.gemspec +1 -1
  16. data/gemspecs/rubyjdwp.gemspec +1 -1
  17. data/gemspecs/statistics.gemspec +1 -1
  18. data/lib/rubygems.rb +167 -105
  19. data/lib/rubygems/builder.rb +12 -10
  20. data/lib/rubygems/command.rb +177 -60
  21. data/lib/rubygems/command_manager.rb +30 -38
  22. data/lib/rubygems/commands/build_command.rb +42 -46
  23. data/lib/rubygems/commands/cert_command.rb +72 -69
  24. data/lib/rubygems/commands/check_command.rb +63 -63
  25. data/lib/rubygems/commands/cleanup_command.rb +25 -7
  26. data/lib/rubygems/commands/contents_command.rb +70 -62
  27. data/lib/rubygems/commands/dependency_command.rb +131 -86
  28. data/lib/rubygems/commands/environment_command.rb +67 -46
  29. data/lib/rubygems/commands/fetch_command.rb +62 -0
  30. data/lib/rubygems/commands/generate_index_command.rb +57 -0
  31. data/lib/rubygems/commands/help_command.rb +163 -73
  32. data/lib/rubygems/commands/install_command.rb +114 -128
  33. data/lib/rubygems/commands/list_command.rb +10 -8
  34. data/lib/rubygems/commands/lock_command.rb +101 -0
  35. data/lib/rubygems/commands/mirror_command.rb +105 -0
  36. data/lib/rubygems/commands/outdated_command.rb +24 -15
  37. data/lib/rubygems/commands/pristine_command.rb +118 -88
  38. data/lib/rubygems/commands/query_command.rb +109 -77
  39. data/lib/rubygems/commands/rdoc_command.rb +13 -10
  40. data/lib/rubygems/commands/search_command.rb +10 -8
  41. data/lib/rubygems/commands/server_command.rb +48 -0
  42. data/lib/rubygems/commands/sources_command.rb +104 -83
  43. data/lib/rubygems/commands/specification_command.rb +65 -51
  44. data/lib/rubygems/commands/uninstall_command.rb +17 -12
  45. data/lib/rubygems/commands/unpack_command.rb +68 -68
  46. data/lib/rubygems/commands/update_command.rb +72 -25
  47. data/lib/rubygems/commands/which_command.rb +86 -0
  48. data/lib/rubygems/config_file.rb +202 -78
  49. data/lib/rubygems/custom_require.rb +7 -88
  50. data/lib/rubygems/dependency.rb +65 -0
  51. data/lib/rubygems/dependency_installer.rb +232 -0
  52. data/lib/rubygems/dependency_list.rb +133 -105
  53. data/lib/rubygems/digest/md5.rb +4 -1
  54. data/lib/rubygems/digest/sha2.rb +1 -1
  55. data/lib/rubygems/doc_manager.rb +41 -19
  56. data/lib/rubygems/exceptions.rb +63 -0
  57. data/lib/rubygems/ext.rb +18 -0
  58. data/lib/rubygems/ext/builder.rb +56 -0
  59. data/lib/rubygems/ext/configure_builder.rb +24 -0
  60. data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
  61. data/lib/rubygems/ext/rake_builder.rb +27 -0
  62. data/lib/rubygems/format.rb +16 -6
  63. data/lib/rubygems/gem_openssl.rb +43 -6
  64. data/lib/rubygems/gem_path_searcher.rb +84 -0
  65. data/lib/rubygems/gem_runner.rb +20 -5
  66. data/lib/rubygems/indexer.rb +163 -0
  67. data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
  68. data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
  69. data/lib/rubygems/indexer/master_index_builder.rb +53 -0
  70. data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
  71. data/lib/rubygems/install_update_options.rb +87 -0
  72. data/lib/rubygems/installer.rb +316 -562
  73. data/lib/rubygems/local_remote_options.rb +106 -0
  74. data/lib/rubygems/old_format.rb +5 -13
  75. data/lib/rubygems/open-uri.rb +2 -0
  76. data/lib/rubygems/package.rb +28 -32
  77. data/lib/rubygems/platform.rb +187 -0
  78. data/lib/rubygems/remote_fetcher.rb +46 -29
  79. data/lib/rubygems/remote_installer.rb +11 -18
  80. data/lib/rubygems/requirement.rb +157 -0
  81. data/lib/rubygems/rubygems_version.rb +1 -1
  82. data/lib/rubygems/security.rb +715 -457
  83. data/lib/rubygems/server.rb +77 -59
  84. data/lib/rubygems/source_index.rb +154 -83
  85. data/lib/rubygems/source_info_cache.rb +73 -30
  86. data/lib/rubygems/source_info_cache_entry.rb +12 -3
  87. data/lib/rubygems/specification.rb +378 -145
  88. data/lib/rubygems/uninstaller.rb +183 -0
  89. data/lib/rubygems/user_interaction.rb +38 -9
  90. data/lib/rubygems/validator.rb +53 -24
  91. data/lib/rubygems/version.rb +126 -289
  92. data/lib/rubygems/version_option.rb +49 -0
  93. data/pkgs/sources/lib/sources.rb +1 -4
  94. data/pkgs/sources/sources.gemspec +3 -3
  95. data/scripts/gemdoc.rb +0 -1
  96. data/setup.rb +166 -1505
  97. data/test/bogussources.rb +0 -1
  98. data/test/data/gem-private_key.pem +27 -0
  99. data/test/data/gem-public_cert.pem +20 -0
  100. data/test/functional.rb +3 -105
  101. data/test/gemutilities.rb +145 -24
  102. data/test/insure_session.rb +0 -1
  103. data/test/{test_datadir.rb → test_config.rb} +7 -13
  104. data/test/test_gem.rb +360 -9
  105. data/test/test_gem_builder.rb +34 -0
  106. data/test/{test_command.rb → test_gem_command.rb} +119 -62
  107. data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
  108. data/test/test_gem_commands_build_command.rb +75 -0
  109. data/test/test_gem_commands_cert_command.rb +122 -0
  110. data/test/test_gem_commands_check_command.rb +25 -0
  111. data/test/test_gem_commands_contents_command.rb +92 -0
  112. data/test/test_gem_commands_dependency_command.rb +108 -0
  113. data/test/test_gem_commands_environment_command.rb +117 -0
  114. data/test/test_gem_commands_fetch_command.rb +34 -0
  115. data/test/test_gem_commands_generate_index_command.rb +32 -0
  116. data/test/test_gem_commands_install_command.rb +160 -0
  117. data/test/test_gem_commands_mirror_command.rb +56 -0
  118. data/test/test_gem_commands_pristine_command.rb +100 -0
  119. data/test/test_gem_commands_query_command.rb +82 -0
  120. data/test/test_gem_commands_sources_command.rb +147 -0
  121. data/test/test_gem_commands_specification_command.rb +93 -0
  122. data/test/test_gem_commands_unpack_command.rb +55 -0
  123. data/test/test_gem_config_file.rb +210 -0
  124. data/test/test_gem_dependency.rb +89 -0
  125. data/test/test_gem_dependency_installer.rb +542 -0
  126. data/test/test_gem_dependency_list.rb +212 -0
  127. data/test/test_gem_doc_manager.rb +32 -0
  128. data/test/test_gem_ext_configure_builder.rb +13 -17
  129. data/test/test_gem_ext_ext_conf_builder.rb +9 -9
  130. data/test/test_gem_ext_rake_builder.rb +23 -11
  131. data/test/test_gem_format.rb +69 -0
  132. data/test/test_gem_gem_path_searcher.rb +57 -0
  133. data/test/test_gem_gem_runner.rb +35 -0
  134. data/test/test_gem_indexer.rb +119 -0
  135. data/test/test_gem_install_update_options.rb +40 -0
  136. data/test/test_gem_installer.rb +796 -0
  137. data/test/test_gem_local_remote_options.rb +84 -0
  138. data/test/test_gem_outdated_command.rb +11 -9
  139. data/test/test_gem_platform.rb +240 -0
  140. data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
  141. data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
  142. data/test/test_gem_requirement.rb +223 -0
  143. data/test/test_gem_server.rb +71 -0
  144. data/test/test_gem_source_index.rb +429 -0
  145. data/test/test_gem_source_info_cache.rb +79 -17
  146. data/test/test_gem_source_info_cache_entry.rb +11 -9
  147. data/test/test_gem_specification.rb +738 -0
  148. data/test/test_gem_stream_ui.rb +117 -0
  149. data/test/test_gem_validator.rb +70 -0
  150. data/test/test_gem_version.rb +191 -0
  151. data/test/test_gem_version_option.rb +77 -0
  152. data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
  153. data/test/test_open_uri.rb +1 -2
  154. data/test/test_package.rb +45 -34
  155. metadata +116 -141
  156. data/Releases +0 -127
  157. data/bin/gem_mirror +0 -73
  158. data/bin/gem_server +0 -6
  159. data/bin/gemlock +0 -127
  160. data/bin/gemri +0 -24
  161. data/bin/gemwhich +0 -89
  162. data/bin/index_gem_repository.rb +0 -302
  163. data/lib/gemconfigure.rb +0 -24
  164. data/lib/rubygems/gem_commands.rb +0 -273
  165. data/pkgs/sources/sources-0.0.1.gem +0 -0
  166. data/post-install.rb +0 -121
  167. data/test/brokenbuildgem.rb +0 -35
  168. data/test/data/PostMessage-0.0.1.gem +0 -0
  169. data/test/data/a-0.0.1.gem +0 -0
  170. data/test/data/a-0.0.2.gem +0 -0
  171. data/test/data/b-0.0.2.gem +0 -0
  172. data/test/data/broken-1.0.0.gem +0 -0
  173. data/test/data/broken_build/broken-build.gemspec +0 -20
  174. data/test/data/broken_build/ext/extconf.rb +0 -3
  175. data/test/data/broken_build/ext/foo.c +0 -1
  176. data/test/data/c-1.2.gem +0 -0
  177. data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
  178. data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
  179. data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
  180. data/test/data/gemhome/cache/c-1.2.gem +0 -0
  181. data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
  182. data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
  183. data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
  184. data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
  185. data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
  186. data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
  187. data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
  188. data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
  189. data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
  190. data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
  191. data/test/data/lib/code.rb +0 -1
  192. data/test/data/one/README.one +0 -1
  193. data/test/data/one/lib/one.rb +0 -9
  194. data/test/data/one/one-0.0.1.gem +0 -0
  195. data/test/data/one/one.gemspec +0 -17
  196. data/test/data/one/one.yaml +0 -40
  197. data/test/data/post_install.gemspec +0 -19
  198. data/test/functional_extension_gems.rb +0 -48
  199. data/test/functional_generate_yaml_index.rb +0 -104
  200. data/test/gemenvironment.rb +0 -59
  201. data/test/io_capture.rb +0 -33
  202. data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
  203. data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
  204. data/test/onegem.rb +0 -35
  205. data/test/test_builder.rb +0 -34
  206. data/test/test_check_command.rb +0 -34
  207. data/test/test_configfile.rb +0 -42
  208. data/test/test_dependency_list.rb +0 -169
  209. data/test/test_file_list.rb +0 -101
  210. data/test/test_format.rb +0 -49
  211. data/test/test_gem_sources_command.rb +0 -135
  212. data/test/test_gemloadpaths.rb +0 -51
  213. data/test/test_gempaths.rb +0 -170
  214. data/test/test_installer.rb +0 -369
  215. data/test/test_loadmanager.rb +0 -48
  216. data/test/test_process_commands.rb +0 -52
  217. data/test/test_source_index.rb +0 -231
  218. data/test/test_specific_extras.rb +0 -46
  219. data/test/test_specification.rb +0 -565
  220. data/test/test_user_interaction.rb +0 -48
  221. data/test/test_validator.rb +0 -59
  222. data/test/test_version_comparison.rb +0 -321
  223. data/test/testgem.rc +0 -7
  224. data/test/user_capture.rb +0 -7
  225. data/test/yaml_data.rb +0 -63
@@ -7,7 +7,6 @@
7
7
 
8
8
 
9
9
  require 'rubygems'
10
- Gem::manage_gems
11
10
 
12
11
  def install_session
13
12
  path_to_gem = File.join("redist", "session.gem")
@@ -6,27 +6,21 @@
6
6
  #++
7
7
 
8
8
  require 'test/unit'
9
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
9
10
  require 'rbconfig'
10
11
  require 'rubygems'
11
12
 
12
- class TestDataDir < Test::Unit::TestCase
13
- def test_original_dir
13
+ class TestConfig < RubyGemTestCase
14
+
15
+ def test_gem_original_datadir
14
16
  datadir = Config::CONFIG['datadir']
15
17
  assert_equal "#{datadir}/xyz", Config.gem_original_datadir('xyz')
16
18
  end
17
19
 
18
- def test_gem_dir_with_good_package
19
- gem 'sources'
20
- assert_match %r{gems/1.8/gems/sources-0.0.1/data/sources$}, Gem.datadir('sources')
21
- end
22
-
23
- def test_gem_dir_with_bad_package
24
- gem 'sources'
25
- assert_nil Gem.datadir('xyzzy')
26
- end
27
-
28
- def test_basic_dir
20
+ def test_datadir
29
21
  datadir = Config::CONFIG['datadir']
30
22
  assert_equal "#{datadir}/xyz", Config.datadir('xyz')
31
23
  end
24
+
32
25
  end
26
+
@@ -1,24 +1,375 @@
1
1
  require 'test/unit'
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
2
3
  require 'rubygems'
3
- require 'sources'
4
+ require 'rubygems/gem_openssl'
5
+ require 'pathname'
4
6
 
5
- class TestGem < Test::Unit::TestCase
7
+ class TestGem < RubyGemTestCase
8
+
9
+ def setup
10
+ super
11
+
12
+ @additional = %w[a b].map { |d| File.join @tempdir, d }
13
+ @default_dir_re = %r|/[Rr]uby/[Gg]ems/[0-9.]+|
14
+ end
15
+
16
+ def test_self_all_load_paths
17
+ util_make_gems
18
+
19
+ expected = [
20
+ File.join(@gemhome, *%W[gems #{@a0_0_1.full_name} lib]),
21
+ File.join(@gemhome, *%W[gems #{@a0_0_2.full_name} lib]),
22
+ File.join(@gemhome, *%W[gems #{@b0_0_2.full_name} lib]),
23
+ File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
24
+ File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
25
+ ]
26
+
27
+ assert_equal expected, Gem.all_load_paths.sort
28
+ end
29
+
30
+ def test_self_bindir
31
+ assert_equal File.join(@gemhome, 'bin'), Gem.bindir
32
+ assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Gem.dir)
33
+ assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Pathname.new(Gem.dir))
34
+ end
35
+
36
+ def test_self_bindir_default_dir
37
+ default = Gem.default_dir
38
+ bindir = (defined? RUBY_FRAMEWORK_VERSION) ? '/usr/bin' : Config::CONFIG['bindir']
39
+ assert_equal bindir, Gem.bindir(default)
40
+ assert_equal bindir, Gem.bindir(Pathname.new(default))
41
+ end
42
+
43
+ def test_self_clear_paths
44
+ Gem.dir
45
+ Gem.path
46
+ searcher = Gem.searcher
47
+ source_index = Gem.source_index
48
+
49
+ Gem.clear_paths
50
+
51
+ assert_equal nil, Gem.instance_variable_get(:@gem_home)
52
+ assert_equal nil, Gem.instance_variable_get(:@gem_path)
53
+ assert_not_equal searcher, Gem.searcher
54
+ assert_not_equal source_index, Gem.source_index
55
+ end
6
56
 
7
57
  def test_self_configuration
8
- expected = {}
9
- Gem.send :instance_variable_set, :@configuration, nil
58
+ expected = Gem::ConfigFile.new []
59
+ Gem.configuration = nil
10
60
 
11
61
  assert_equal expected, Gem.configuration
62
+ end
12
63
 
13
- Gem.configuration[:verbose] = true
14
- expected[:verbose] = true
64
+ def test_self_datadir
65
+ foo = nil
15
66
 
16
- assert_equal expected, Gem.configuration
17
- assert_equal true, Gem.configuration.verbose, 'method_missing on Hash'
67
+ Dir.chdir @tempdir do
68
+ FileUtils.mkdir_p 'data'
69
+ File.open File.join('data', 'foo.txt'), 'w' do |fp|
70
+ fp.puts 'blah'
71
+ end
72
+
73
+ foo = quick_gem 'foo' do |s| s.files = %w[data/foo.txt] end
74
+ install_gem foo
75
+ end
76
+
77
+ gem 'foo'
78
+
79
+ expected = File.join @gemhome, 'gems', foo.full_name, 'data', 'foo'
80
+
81
+ assert_equal expected, Gem.datadir('foo')
82
+ end
83
+
84
+ def test_self_datadir_nonexistent_package
85
+ assert_nil Gem.datadir('xyzzy')
86
+ end
87
+
88
+ def test_self_default_dir
89
+ assert_match @default_dir_re, Gem.default_dir
90
+ end
91
+
92
+ def test_self_default_sources
93
+ assert_equal %w[http://gems.rubyforge.org], Gem.default_sources
94
+ end
95
+
96
+ def test_self_dir
97
+ assert_equal @gemhome, Gem.dir
98
+
99
+ Gem::DIRECTORIES.each do |filename|
100
+ assert File.directory?(File.join(Gem.dir, filename)),
101
+ "expected #{filename} to exist"
102
+ end
103
+ end
104
+
105
+ def test_self_ensure_gem_directories
106
+ FileUtils.rm_r @gemhome
107
+ Gem.use_paths @gemhome
108
+
109
+ Gem.ensure_gem_subdirectories @gemhome
110
+
111
+ assert File.directory?(File.join(@gemhome, "cache"))
112
+ end
113
+
114
+ def test_self_ensure_gem_directories_missing_parents
115
+ gemdir = File.join @tempdir, 'a/b/c/gemdir'
116
+ FileUtils.rm_rf File.join(@tempdir, 'a') rescue nil
117
+ assert !File.exist?(File.join(@tempdir, 'a')),
118
+ "manually remove #{File.join @tempdir, 'a'}, tests are broken"
119
+ Gem.use_paths gemdir
120
+
121
+ Gem.ensure_gem_subdirectories gemdir
122
+
123
+ assert File.directory?("#{gemdir}/cache")
124
+ end
125
+
126
+ unless win_platform? then # only for FS that support write protection
127
+ def test_self_ensure_gem_directories_write_protected
128
+ gemdir = File.join @tempdir, "egd"
129
+ FileUtils.rm_r gemdir rescue nil
130
+ assert !File.exist?(gemdir), "manually remove #{gemdir}, tests are broken"
131
+ FileUtils.mkdir_p gemdir
132
+ FileUtils.chmod 0400, gemdir
133
+ Gem.use_paths gemdir
134
+
135
+ Gem.ensure_gem_subdirectories gemdir
136
+
137
+ assert !File.exist?("#{gemdir}/cache")
138
+ ensure
139
+ FileUtils.chmod 0600, gemdir
140
+ end
141
+
142
+ def test_self_ensure_gem_directories_write_protected_parents
143
+ parent = File.join(@tempdir, "egd")
144
+ gemdir = "#{parent}/a/b/c"
145
+
146
+ FileUtils.rm_r parent rescue nil
147
+ assert !File.exist?(parent), "manually remove #{parent}, tests are broken"
148
+ FileUtils.mkdir_p parent
149
+ FileUtils.chmod 0400, parent
150
+ Gem.use_paths(gemdir)
151
+
152
+ Gem.ensure_gem_subdirectories gemdir
153
+
154
+ assert !File.exist?("#{gemdir}/cache")
155
+ ensure
156
+ FileUtils.chmod 0600, parent
157
+ end
158
+ end
159
+
160
+ def test_ensure_ssl_available
161
+ orig_Gem_ssl_available = Gem.ssl_available?
162
+
163
+ Gem.ssl_available = true
164
+ assert_nothing_raised do Gem.ensure_ssl_available end
165
+
166
+ Gem.ssl_available = false
167
+ e = assert_raise Gem::Exception do Gem.ensure_ssl_available end
168
+ assert_equal 'SSL is not installed on this system', e.message
169
+ ensure
170
+ Gem.ssl_available = orig_Gem_ssl_available
171
+ end
172
+
173
+ def test_self_latest_load_paths
174
+ util_make_gems
175
+
176
+ expected = [
177
+ File.join(@gemhome, *%W[gems #{@a0_0_2.full_name} lib]),
178
+ File.join(@gemhome, *%W[gems #{@b0_0_2.full_name} lib]),
179
+ File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
180
+ File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
181
+ ]
182
+
183
+ assert_equal expected, Gem.latest_load_paths.sort
18
184
  end
19
185
 
20
186
  def test_self_loaded_specs
21
- assert_equal true, Gem.loaded_specs.keys.include?('sources')
187
+ foo = quick_gem 'foo'
188
+ install_gem foo
189
+ Gem.source_index = nil
190
+
191
+ Gem.activate 'foo', false
192
+
193
+ assert_equal true, Gem.loaded_specs.keys.include?('foo')
194
+ end
195
+
196
+ def test_self_path
197
+ assert_equal [Gem.dir], Gem.path
198
+ end
199
+
200
+ def test_self_path_ENV_PATH
201
+ Gem.clear_paths
202
+ path_count = Gem.path.size
203
+ Gem.clear_paths
204
+ util_ensure_gem_dirs
205
+
206
+ ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
207
+
208
+ assert_equal @additional, Gem.path[0,2]
209
+ assert_equal path_count + @additional.size, Gem.path.size
210
+ assert_match Gem.dir, Gem.path.last
211
+ end
212
+
213
+ def test_self_path_duplicate
214
+ Gem.clear_paths
215
+ util_ensure_gem_dirs
216
+ dirs = @additional + [@gemhome] + [File.join(@tempdir, 'a')]
217
+
218
+ ENV['GEM_HOME'] = @gemhome
219
+ ENV['GEM_PATH'] = dirs.join File::PATH_SEPARATOR
220
+
221
+ assert_equal @gemhome, Gem.dir
222
+ paths = [Gem.dir]
223
+ paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
224
+ assert_equal @additional + paths, Gem.path
225
+ end
226
+
227
+ def test_self_path_overlap
228
+ Gem.clear_paths
229
+
230
+ util_ensure_gem_dirs
231
+ ENV['GEM_HOME'] = @gemhome
232
+ ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
233
+
234
+ assert_equal @gemhome, Gem.dir
235
+ paths = [Gem.dir]
236
+ paths.insert(0, APPLE_GEM_HOME) if defined? APPLE_GEM_HOME
237
+ assert_equal @additional + paths, Gem.path
238
+ end
239
+
240
+ def test_self_platforms
241
+ assert_equal [Gem::Platform::RUBY, Gem::Platform.local], Gem.platforms
242
+ end
243
+
244
+ def test_self_prefix
245
+ file_name = File.expand_path __FILE__
246
+ assert_equal File.dirname(File.dirname(file_name)), Gem.prefix
247
+ end
248
+
249
+ def test_self_required_location
250
+ util_make_gems
251
+
252
+ assert_equal File.join(@tempdir, *%w[gemhome gems c-1.2 lib code.rb]),
253
+ Gem.required_location("c", "code.rb")
254
+ assert_equal File.join(@tempdir, *%w[gemhome gems a-0.0.1 lib code.rb]),
255
+ Gem.required_location("a", "code.rb", "<0.0.2")
256
+ assert_equal File.join(@tempdir, *%w[gemhome gems a-0.0.2 lib code.rb]),
257
+ Gem.required_location("a", "code.rb", "=0.0.2")
258
+ end
259
+
260
+ def test_self_searcher
261
+ assert_kind_of Gem::GemPathSearcher, Gem.searcher
262
+ end
263
+
264
+ def test_self_source_index
265
+ assert_kind_of Gem::SourceIndex, Gem.source_index
266
+ end
267
+
268
+ def test_self_sources
269
+ assert_equal %w[http://gems.example.com], Gem.sources
270
+ end
271
+
272
+ def test_ssl_available_eh
273
+ orig_Gem_ssl_available = Gem.ssl_available?
274
+
275
+ Gem.ssl_available = true
276
+ assert_equal true, Gem.ssl_available?
277
+
278
+ Gem.ssl_available = false
279
+ assert_equal false, Gem.ssl_available?
280
+ ensure
281
+ Gem.ssl_available = orig_Gem_ssl_available
282
+ end
283
+
284
+ def test_self_use_paths
285
+ util_ensure_gem_dirs
286
+
287
+ Gem.use_paths @gemhome, @additional
288
+
289
+ assert_equal @gemhome, Gem.dir
290
+ assert_equal @additional + [Gem.dir], Gem.path
291
+ end
292
+
293
+ def test_self_user_home
294
+ if ENV['HOME'] then
295
+ assert_equal ENV['HOME'], Gem.user_home
296
+ else
297
+ assert true, 'count this test'
298
+ end
299
+ end
300
+
301
+ def test_require_gem_autorequire
302
+ name = "AutorequireArray"
303
+ files = %w(a.rb b.rb)
304
+ gem = quick_gem(name) do |s|
305
+ s.files = files.map { |f| File.join("lib", f) }
306
+ s.autorequire = files
307
+ end
308
+
309
+ fullname = gem.full_name
310
+
311
+ write_file "gems/#{fullname}/lib/a.rb" do |io|
312
+ io.puts "$LOADED_A = true"
313
+ end
314
+
315
+ write_file "gems/#{fullname}/lib/b.rb" do |io|
316
+ io.puts "$LOADED_B = true"
317
+ end
318
+
319
+ Gem.source_index = nil
320
+
321
+ old_loaded = $".dup
322
+ old_verbose = $VERBOSE
323
+ $VERBOSE = nil
324
+ require_gem name
325
+ $VERBOSE = old_verbose
326
+ new_loaded = $".dup
327
+
328
+ if RUBY_VERSION > "1.9" then
329
+ files = files.map do |file|
330
+ File.join @gemhome, 'gems', gem.full_name, 'lib', file
331
+ end
332
+ end
333
+
334
+ assert_equal files, (new_loaded - old_loaded)
335
+ assert defined?($LOADED_A)
336
+ assert defined?($LOADED_B)
337
+ end
338
+
339
+ def test_require_gem_autorequire_string
340
+ name = "AutorequireString"
341
+ file = "c.rb"
342
+ gem = quick_gem(name) do |s|
343
+ s.files = File.join("lib", file)
344
+ s.autorequire = file
345
+ end
346
+
347
+ fullname = gem.full_name
348
+
349
+ write_file("gems/#{fullname}/lib/c.rb") do |io|
350
+ io.puts "$LOADED_C = true"
351
+ end
352
+
353
+ old_loaded = $".dup
354
+ old_verbose = $VERBOSE
355
+ $VERBOSE = nil
356
+ require_gem name
357
+ $VERBOSE = old_verbose
358
+ new_loaded = $".dup
359
+
360
+ if RUBY_VERSION > "1.9" then
361
+ file = File.join @gemhome, 'gems', gem.full_name, 'lib', file
362
+ end
363
+
364
+ assert_equal(Array(file), (new_loaded - old_loaded))
365
+ assert(defined? $LOADED_C)
366
+ end
367
+
368
+ def util_ensure_gem_dirs
369
+ Gem.ensure_gem_subdirectories @gemhome
370
+ @additional.each do |dir|
371
+ Gem.ensure_gem_subdirectories @gemhome
372
+ end
22
373
  end
23
374
 
24
375
  end
@@ -0,0 +1,34 @@
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 'test/unit'
8
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
9
+ require 'rubygems/builder'
10
+
11
+ class TestGemBuilder < RubyGemTestCase
12
+
13
+ def test_build
14
+ builder = Gem::Builder.new quick_gem('a')
15
+
16
+ use_ui @ui do
17
+ Dir.chdir @tempdir do
18
+ builder.build
19
+ end
20
+ end
21
+
22
+ assert_match %r|Successfully built RubyGem\n Name: a|, @ui.output
23
+ end
24
+
25
+ def test_build_validates
26
+ builder = Gem::Builder.new Gem::Specification.new
27
+
28
+ assert_raises Gem::InvalidSpecificationException do
29
+ builder.build
30
+ end
31
+ end
32
+
33
+ end
34
+