rubygems-update 0.9.5 → 1.0.0

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 (53) hide show
  1. data/ChangeLog +135 -0
  2. data/Rakefile +3 -1
  3. data/lib/rubygems.rb +27 -38
  4. data/lib/rubygems/commands/install_command.rb +2 -0
  5. data/lib/rubygems/commands/mirror_command.rb +8 -2
  6. data/lib/rubygems/commands/query_command.rb +3 -1
  7. data/lib/rubygems/commands/server_command.rb +3 -3
  8. data/lib/rubygems/commands/unpack_command.rb +11 -4
  9. data/lib/rubygems/commands/update_command.rb +114 -108
  10. data/lib/rubygems/defaults.rb +46 -0
  11. data/lib/rubygems/dependency_installer.rb +13 -2
  12. data/lib/rubygems/indexer.rb +1 -1
  13. data/lib/rubygems/install_update_options.rb +7 -0
  14. data/lib/rubygems/installer.rb +66 -11
  15. data/lib/rubygems/package.rb +2 -1
  16. data/lib/rubygems/platform.rb +24 -30
  17. data/lib/rubygems/remote_fetcher.rb +7 -3
  18. data/lib/rubygems/require_paths_builder.rb +15 -0
  19. data/lib/rubygems/rubygems_version.rb +1 -1
  20. data/lib/rubygems/security.rb +1 -1
  21. data/lib/rubygems/server.rb +18 -3
  22. data/lib/rubygems/source_index.rb +20 -23
  23. data/lib/rubygems/source_info_cache.rb +3 -3
  24. data/lib/rubygems/specification.rb +64 -31
  25. data/lib/rubygems/uninstaller.rb +1 -1
  26. data/lib/rubygems/validator.rb +3 -2
  27. data/lib/rubygems/version.rb +10 -3
  28. data/setup.rb +30 -6
  29. data/test/gemutilities.rb +23 -13
  30. data/test/gemutilities.rbc +0 -0
  31. data/test/mockgemui.rbc +0 -0
  32. data/test/test_gem.rb +46 -76
  33. data/test/test_gem.rbc +0 -0
  34. data/test/test_gem_commands_build_command.rb +12 -12
  35. data/test/test_gem_commands_dependency_command.rb +10 -10
  36. data/test/test_gem_commands_mirror_command.rb +9 -4
  37. data/test/test_gem_commands_query_command.rb +7 -3
  38. data/test/test_gem_commands_server_command.rb +27 -0
  39. data/test/test_gem_commands_unpack_command.rb +20 -2
  40. data/test/test_gem_format.rb +1 -1
  41. data/test/test_gem_indexer.rb +5 -5
  42. data/test/test_gem_install_update_options.rb +1 -1
  43. data/test/test_gem_installer.rb +149 -60
  44. data/test/test_gem_platform.rb +19 -0
  45. data/test/test_gem_remote_fetcher.rb +19 -2
  46. data/test/test_gem_server.rb +44 -1
  47. data/test/test_gem_source_index.rb +2 -2
  48. data/test/test_gem_specification.rb +300 -168
  49. data/test/test_gem_version.rb +15 -0
  50. data/test/test_kernel.rb +19 -19
  51. metadata +46 -42
  52. data/lib/rubygems/remote_installer.rb +0 -195
  53. data/test/test_gem_remote_installer.rb +0 -161
@@ -5,6 +5,19 @@ require 'rbconfig'
5
5
 
6
6
  class TestGemPlatform < RubyGemTestCase
7
7
 
8
+ def test_self_const_missing
9
+ consts = [:DARWIN, :LINUX_586, :MSWIN32, :PPC_DARWIN, :WIN32, :X86_LINUX]
10
+
11
+ consts.each do |const|
12
+ e = assert_raise NameError do
13
+ Gem::Platform.const_missing const
14
+ end
15
+
16
+ assert_equal "#{const} has been removed, use CURRENT instead",
17
+ e.message
18
+ end
19
+ end
20
+
8
21
  def test_self_local
9
22
  util_set_arch 'i686-darwin8.10.1'
10
23
 
@@ -19,6 +32,7 @@ class TestGemPlatform < RubyGemTestCase
19
32
  end
20
33
 
21
34
  def test_self_new
35
+ assert_equal Gem::Platform.local, Gem::Platform.new(Gem::Platform::CURRENT)
22
36
  assert_equal Gem::Platform::RUBY, Gem::Platform.new(Gem::Platform::RUBY)
23
37
  assert_equal Gem::Platform::RUBY, Gem::Platform.new(nil)
24
38
  assert_equal Gem::Platform::RUBY, Gem::Platform.new('')
@@ -59,10 +73,15 @@ class TestGemPlatform < RubyGemTestCase
59
73
  'i386-mingw32' => ['x86', 'mingw32', nil],
60
74
  'i386-mswin32' => ['x86', 'mswin32', nil],
61
75
  'i386-mswin32_80' => ['x86', 'mswin32', '80'],
76
+ 'i386-mswin32-80' => ['x86', 'mswin32', '80'],
77
+ 'x86-mswin32' => ['x86', 'mswin32', nil],
78
+ 'x86-mswin32_60' => ['x86', 'mswin32', '60'],
79
+ 'x86-mswin32-60' => ['x86', 'mswin32', '60'],
62
80
  'i386-netbsdelf' => ['x86', 'netbsdelf', nil],
63
81
  'i386-openbsd4.0' => ['x86', 'openbsd', '4.0'],
64
82
  'i386-solaris2.10' => ['x86', 'solaris', '2.10'],
65
83
  'i386-solaris2.8' => ['x86', 'solaris', '2.8'],
84
+ 'mswin32' => ['x86', 'mswin32', nil],
66
85
  'x86_64-linux' => ['x86_64', 'linux', nil],
67
86
  'x86_64-openbsd3.9' => ['x86_64', 'openbsd', '3.9'],
68
87
  'x86_64-openbsd4.0' => ['x86_64', 'openbsd', '4.0'],
@@ -140,11 +140,12 @@ gems:
140
140
  raise SocketError
141
141
  end
142
142
 
143
+ uri = 'http://gems.example.com/yaml'
143
144
  e = assert_raise Gem::RemoteFetcher::FetchError do
144
- fetcher.fetch_size 'http://gems.example.com/yaml'
145
+ fetcher.fetch_size uri
145
146
  end
146
147
 
147
- assert_equal 'SocketError (SocketError)', e.message
148
+ assert_equal "SocketError (SocketError)\n\tgetting size of #{uri}", e.message
148
149
  end
149
150
 
150
151
  def test_no_proxy
@@ -231,6 +232,22 @@ gems:
231
232
  assert_equal 'EOFError: EOFError reading uri', e.message
232
233
  end
233
234
 
235
+ def test_fetch_path_open_uri_http_error
236
+ fetcher = Gem::RemoteFetcher.new nil
237
+
238
+ def fetcher.open_uri_or_path(uri)
239
+ io = StringIO.new 'went boom'
240
+ err = OpenURI::HTTPError.new 'error', io
241
+ raise err
242
+ end
243
+
244
+ e = assert_raise Gem::RemoteFetcher::FetchError do
245
+ fetcher.fetch_path 'uri'
246
+ end
247
+
248
+ assert_equal "OpenURI::HTTPError: error reading uri\n\twent boom", e.message
249
+ end
250
+
234
251
  def test_fetch_path_socket_error
235
252
  fetcher = Gem::RemoteFetcher.new nil
236
253
 
@@ -4,6 +4,7 @@ require 'rubygems/server'
4
4
  require 'stringio'
5
5
 
6
6
  class Gem::Server
7
+ attr_accessor :source_index
7
8
  attr_reader :server
8
9
  end
9
10
 
@@ -25,6 +26,7 @@ class TestGemServer < RubyGemTestCase
25
26
 
26
27
  @server.quick @req, @res
27
28
 
29
+ assert_equal 200, @res.status, @res.body
28
30
  assert_match %r| \d\d:\d\d:\d\d |, @res['date']
29
31
  assert_equal 'text/plain', @res['content-type']
30
32
  assert_equal "a-1", @res.body
@@ -36,6 +38,7 @@ class TestGemServer < RubyGemTestCase
36
38
 
37
39
  @server.quick @req, @res
38
40
 
41
+ assert_equal 200, @res.status, @res.body
39
42
  assert_match %r| \d\d:\d\d:\d\d |, @res['date']
40
43
  assert_equal 'text/plain', @res['content-type']
41
44
  assert_equal "a-1", Zlib::Inflate.inflate(@res.body)
@@ -47,6 +50,7 @@ class TestGemServer < RubyGemTestCase
47
50
 
48
51
  @server.quick @req, @res
49
52
 
53
+ assert_equal 200, @res.status, @res.body
50
54
  assert @res['date']
51
55
  assert_equal 'text/plain', @res['content-type']
52
56
  yaml = Zlib::Inflate.inflate(@res.body)
@@ -55,15 +59,54 @@ class TestGemServer < RubyGemTestCase
55
59
  assert_match %r|version: "1"|, yaml
56
60
  end
57
61
 
62
+ def test_quick_a_1_mswin32_gemspec_rz
63
+ a1_p = quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
64
+ si = Gem::SourceIndex.new @a1.full_name => @a1, a1_p.full_name => a1_p
65
+ @server.source_index = si
66
+
67
+ data = StringIO.new "GET /quick/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
68
+ @req.parse data
69
+
70
+ @server.quick @req, @res
71
+
72
+ assert_equal 200, @res.status, @res.body
73
+ assert @res['date']
74
+ assert_equal 'text/plain', @res['content-type']
75
+ yaml = Zlib::Inflate.inflate(@res.body)
76
+ assert_match %r|Gem::Specification|, yaml
77
+ assert_match %r|name: a|, yaml
78
+ assert_match %r|version: "1"|, yaml
79
+ end
80
+
81
+ def test_quick_common_substrings
82
+ ab1 = quick_gem 'ab', '1'
83
+ si = Gem::SourceIndex.new @a1.full_name => @a1, ab1.full_name => ab1
84
+ @server.source_index = si
85
+
86
+ data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
87
+ @req.parse data
88
+
89
+ @server.quick @req, @res
90
+
91
+ assert_equal 200, @res.status, @res.body
92
+ assert @res['date']
93
+ assert_equal 'text/plain', @res['content-type']
94
+ yaml = Zlib::Inflate.inflate @res.body
95
+ assert_match %r|Gem::Specification|, yaml
96
+ assert_match %r|name: a$|, yaml
97
+ assert_match %r|version: "1"|, yaml
98
+ end
99
+
58
100
  def test_quick_z_9_gemspec_rz
59
101
  data = StringIO.new "GET /quick/z-9.gemspec.rz HTTP/1.0\r\n\r\n"
60
102
  @req.parse data
61
103
 
62
104
  @server.quick @req, @res
63
105
 
106
+ assert_equal 404, @res.status, @res.body
64
107
  assert_match %r| \d\d:\d\d:\d\d |, @res['date']
65
108
  assert_equal 'text/plain', @res['content-type']
66
- assert_equal '', @res.body
109
+ assert_equal 'No gems found matching "z" "9" nil', @res.body
67
110
  assert_equal 404, @res.status
68
111
  end
69
112
 
@@ -178,7 +178,7 @@ class TestGemSourceIndex < RubyGemTestCase
178
178
  end
179
179
 
180
180
  def test_latest_specs
181
- spec = quick_gem @gem1.name, '0.0.1'
181
+ spec = quick_gem @gem1.name, '1'
182
182
  @source_index.add_spec spec
183
183
 
184
184
  expected = [
@@ -223,7 +223,7 @@ class TestGemSourceIndex < RubyGemTestCase
223
223
 
224
224
  def test_search
225
225
  assert_equal [@gem1, @gem4], @source_index.search("gem_one")
226
- assert_equal [@gem1], @source_index.search("gem_one", "= 0.0.2")
226
+ assert_equal [@gem1], @source_index.search("gem_one", "= 2")
227
227
 
228
228
  assert_equal [], @source_index.search("bogusstring")
229
229
  assert_equal [], @source_index.search("gem_one", "= 3.2.1")
@@ -47,12 +47,13 @@ end
47
47
  def setup
48
48
  super
49
49
 
50
- @a0_0_1 = quick_gem 'a', '0.0.1' do |s|
50
+ @a1 = quick_gem 'a', '1' do |s|
51
51
  s.executable = 'exec'
52
52
  s.extensions << 'ext/a/extconf.rb'
53
53
  s.has_rdoc = 'true'
54
54
  s.test_file = 'test/suite.rb'
55
55
  s.requirements << 'A working computer'
56
+ s.rubyforge_project = 'example'
56
57
 
57
58
  s.add_dependency 'rake', '> 0.4'
58
59
  s.add_dependency 'jabber4r', '> 0.0.0'
@@ -62,9 +63,14 @@ end
62
63
  s.files = %w[lib/code.rb]
63
64
  end
64
65
 
65
- @a0_0_2 = quick_gem 'a', '0.0.2' do |s|
66
+ @a2 = quick_gem 'a', '2' do |s|
66
67
  s.files = %w[lib/code.rb]
67
68
  end
69
+
70
+ FileUtils.mkdir_p File.join(@tempdir, 'bin')
71
+ File.open File.join(@tempdir, 'bin', 'exec'), 'w' do |fp|
72
+ fp.puts "#!#{Gem.ruby}"
73
+ end
68
74
  end
69
75
 
70
76
  def test_self_attribute_names
@@ -107,10 +113,10 @@ end
107
113
  end
108
114
 
109
115
  def test_self_load
110
- spec = File.join @gemhome, 'specifications', "#{@a0_0_2.full_name}.gemspec"
116
+ spec = File.join @gemhome, 'specifications', "#{@a2.full_name}.gemspec"
111
117
  gs = Gem::Specification.load spec
112
118
 
113
- assert_equal @a0_0_2, gs
119
+ assert_equal @a2, gs
114
120
  end
115
121
 
116
122
  def test_self_load_legacy_ruby
@@ -119,7 +125,7 @@ end
119
125
  assert_equal '0.4.0', s.version.to_s
120
126
  assert_equal true, s.has_rdoc?
121
127
  assert_equal Gem::Specification::TODAY, s.date
122
- assert s.required_ruby_version.satisfied_by?(Gem::Version.new('0.0.1'))
128
+ assert s.required_ruby_version.satisfied_by?(Gem::Version.new('1'))
123
129
  assert_equal false, s.has_unit_tests?
124
130
  end
125
131
 
@@ -129,7 +135,7 @@ end
129
135
  assert_equal '0.4.0', s.version.to_s
130
136
  assert_equal true, s.has_rdoc?
131
137
  #assert_equal Date.today, s.date
132
- #assert s.required_ruby_version.satisfied_by?(Gem::Version.new('0.0.1'))
138
+ #assert s.required_ruby_version.satisfied_by?(Gem::Version.new('1'))
133
139
  assert_equal false, s.has_unit_tests?
134
140
  end
135
141
 
@@ -197,10 +203,10 @@ end
197
203
  end
198
204
 
199
205
  def test__dump
200
- @a0_0_2.platform = Gem::Platform.local
201
- @a0_0_2.instance_variable_set :@original_platform, 'old_platform'
206
+ @a2.platform = Gem::Platform.local
207
+ @a2.instance_variable_set :@original_platform, 'old_platform'
202
208
 
203
- data = Marshal.dump @a0_0_2
209
+ data = Marshal.dump @a2
204
210
 
205
211
  same_spec = Marshal.load data
206
212
 
@@ -208,64 +214,64 @@ end
208
214
  end
209
215
 
210
216
  def test_author
211
- assert_equal 'A User', @a0_0_1.author
217
+ assert_equal 'A User', @a1.author
212
218
  end
213
219
 
214
220
  def test_authors
215
- assert_equal ['A User'], @a0_0_1.authors
221
+ assert_equal ['A User'], @a1.authors
216
222
  end
217
223
 
218
224
  def test_bindir_equals
219
- @a0_0_1.bindir = 'apps'
225
+ @a1.bindir = 'apps'
220
226
 
221
- assert_equal 'apps', @a0_0_1.bindir
227
+ assert_equal 'apps', @a1.bindir
222
228
  end
223
229
 
224
230
  def test_bindir_equals_nil
225
- @a0_0_2.bindir = nil
226
- @a0_0_2.executable = 'app'
231
+ @a2.bindir = nil
232
+ @a2.executable = 'app'
227
233
 
228
- assert_equal nil, @a0_0_2.bindir
229
- assert_equal %w[lib/code.rb app], @a0_0_2.files
234
+ assert_equal nil, @a2.bindir
235
+ assert_equal %w[lib/code.rb app], @a2.files
230
236
  end
231
237
 
232
238
  def test_date
233
- assert_equal Gem::Specification::TODAY, @a0_0_1.date
239
+ assert_equal Gem::Specification::TODAY, @a1.date
234
240
  end
235
241
 
236
242
  def test_date_equals_date
237
- @a0_0_1.date = Date.new(2003, 9, 17)
238
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
243
+ @a1.date = Date.new(2003, 9, 17)
244
+ assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
239
245
  end
240
246
 
241
247
  def test_date_equals_string
242
- @a0_0_1.date = '2003-09-17'
243
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
248
+ @a1.date = '2003-09-17'
249
+ assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
244
250
  end
245
251
 
246
252
  def test_date_equals_time
247
- @a0_0_1.date = Time.local(2003, 9, 17, 0,0,0)
248
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
253
+ @a1.date = Time.local(2003, 9, 17, 0,0,0)
254
+ assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
249
255
  end
250
256
 
251
257
  def test_date_equals_time_local
252
258
  # HACK PDT
253
- @a0_0_1.date = Time.local(2003, 9, 17, 19,50,0)
254
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
259
+ @a1.date = Time.local(2003, 9, 17, 19,50,0)
260
+ assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
255
261
  end
256
262
 
257
263
  def test_date_equals_time_utc
258
264
  # HACK PDT
259
- @a0_0_1.date = Time.local(2003, 9, 17, 19,50,0)
260
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
265
+ @a1.date = Time.local(2003, 9, 17, 19,50,0)
266
+ assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
261
267
  end
262
268
 
263
269
  def test_default_executable
264
- assert_equal 'exec', @a0_0_1.default_executable
270
+ assert_equal 'exec', @a1.default_executable
265
271
 
266
- @a0_0_1.default_executable = nil
267
- @a0_0_1.instance_variable_set :@executables, nil
268
- assert_equal nil, @a0_0_1.default_executable
272
+ @a1.default_executable = nil
273
+ @a1.instance_variable_set :@executables, nil
274
+ assert_equal nil, @a1.default_executable
269
275
  end
270
276
 
271
277
  def test_dependencies
@@ -273,11 +279,11 @@ end
273
279
  jabber = Gem::Dependency.new 'jabber4r', '> 0.0.0'
274
280
  pqa = Gem::Dependency.new 'pqa', ['> 0.4', '<= 0.6']
275
281
 
276
- assert_equal [rake, jabber, pqa], @a0_0_1.dependencies
282
+ assert_equal [rake, jabber, pqa], @a1.dependencies
277
283
  end
278
284
 
279
285
  def test_description
280
- assert_equal 'This is a test description', @a0_0_1.description
286
+ assert_equal 'This is a test description', @a1.description
281
287
  end
282
288
 
283
289
  def test_eql_eh
@@ -290,10 +296,10 @@ end
290
296
  end
291
297
 
292
298
  def test_equals2
293
- assert_equal @a0_0_1, @a0_0_1
294
- assert_equal @a0_0_1, @a0_0_1.dup
295
- assert_not_equal @a0_0_1, @a0_0_2
296
- assert_not_equal @a0_0_1, Object.new
299
+ assert_equal @a1, @a1
300
+ assert_equal @a1, @a1.dup
301
+ assert_not_equal @a1, @a2
302
+ assert_not_equal @a1, Object.new
297
303
  end
298
304
 
299
305
  # The cgikit specification was reported to be causing trouble in at least
@@ -322,42 +328,42 @@ end
322
328
  end
323
329
 
324
330
  def test_equals2_default_executable
325
- spec = @a0_0_1.dup
331
+ spec = @a1.dup
326
332
  spec.default_executable = 'xx'
327
333
 
328
- assert_not_equal @a0_0_1, spec
329
- assert_not_equal spec, @a0_0_1
334
+ assert_not_equal @a1, spec
335
+ assert_not_equal spec, @a1
330
336
  end
331
337
 
332
338
  def test_equals2_extensions
333
- spec = @a0_0_1.dup
339
+ spec = @a1.dup
334
340
  spec.extensions = 'xx'
335
341
 
336
- assert_not_equal @a0_0_1, spec
337
- assert_not_equal spec, @a0_0_1
342
+ assert_not_equal @a1, spec
343
+ assert_not_equal spec, @a1
338
344
  end
339
345
 
340
346
  def test_executables
341
- @a0_0_1.executable = 'app'
342
- assert_equal %w[app], @a0_0_1.executables
347
+ @a1.executable = 'app'
348
+ assert_equal %w[app], @a1.executables
343
349
  end
344
350
 
345
351
  def test_executable_equals
346
- @a0_0_2.executable = 'app'
347
- assert_equal 'app', @a0_0_2.executable
348
- assert_equal %w[lib/code.rb bin/app], @a0_0_2.files
352
+ @a2.executable = 'app'
353
+ assert_equal 'app', @a2.executable
354
+ assert_equal %w[lib/code.rb bin/app], @a2.files
349
355
  end
350
356
 
351
357
  def test_extensions
352
- assert_equal ['ext/a/extconf.rb'], @a0_0_1.extensions
358
+ assert_equal ['ext/a/extconf.rb'], @a1.extensions
353
359
  end
354
360
 
355
361
  def test_files
356
- @a0_0_1.files = %w(files bin/common)
357
- @a0_0_1.test_files = %w(test_files bin/common)
358
- @a0_0_1.executables = %w(executables common)
359
- @a0_0_1.extra_rdoc_files = %w(extra_rdoc_files bin/common)
360
- @a0_0_1.extensions = %w(extensions bin/common)
362
+ @a1.files = %w(files bin/common)
363
+ @a1.test_files = %w(test_files bin/common)
364
+ @a1.executables = %w(executables common)
365
+ @a1.extra_rdoc_files = %w(extra_rdoc_files bin/common)
366
+ @a1.extensions = %w(extensions bin/common)
361
367
 
362
368
  expected = %w[
363
369
  bin/common
@@ -367,113 +373,123 @@ end
367
373
  files
368
374
  test_files
369
375
  ]
370
- assert_equal expected, @a0_0_1.files.sort
376
+ assert_equal expected, @a1.files.sort
371
377
  end
372
378
 
373
379
  def test_files_duplicate
374
- @a0_0_2.files = %w[a b c d b]
375
- @a0_0_2.extra_rdoc_files = %w[x y z x]
376
- @a0_0_2.normalize
380
+ @a2.files = %w[a b c d b]
381
+ @a2.extra_rdoc_files = %w[x y z x]
382
+ @a2.normalize
377
383
 
378
- assert_equal %w[a b c d x y z], @a0_0_2.files
379
- assert_equal %w[x y z], @a0_0_2.extra_rdoc_files
384
+ assert_equal %w[a b c d x y z], @a2.files
385
+ assert_equal %w[x y z], @a2.extra_rdoc_files
380
386
  end
381
387
 
382
388
  def test_files_extra_rdoc_files
383
- @a0_0_2.files = %w[a b c d]
384
- @a0_0_2.extra_rdoc_files = %w[x y z]
385
- @a0_0_2.normalize
386
- assert_equal %w[a b c d x y z], @a0_0_2.files
389
+ @a2.files = %w[a b c d]
390
+ @a2.extra_rdoc_files = %w[x y z]
391
+ @a2.normalize
392
+ assert_equal %w[a b c d x y z], @a2.files
387
393
  end
388
394
 
389
395
  def test_files_non_array
390
- @a0_0_1.files = "F"
391
- @a0_0_1.test_files = "TF"
392
- @a0_0_1.executables = "X"
393
- @a0_0_1.extra_rdoc_files = "ERF"
394
- @a0_0_1.extensions = "E"
396
+ @a1.files = "F"
397
+ @a1.test_files = "TF"
398
+ @a1.executables = "X"
399
+ @a1.extra_rdoc_files = "ERF"
400
+ @a1.extensions = "E"
395
401
 
396
- assert_equal %w[E ERF F TF bin/X], @a0_0_1.files.sort
402
+ assert_equal %w[E ERF F TF bin/X], @a1.files.sort
397
403
  end
398
404
 
399
405
  def test_files_non_array_pathological
400
- @a0_0_1.instance_variable_set :@files, "F"
401
- @a0_0_1.instance_variable_set :@test_files, "TF"
402
- @a0_0_1.instance_variable_set :@extra_rdoc_files, "ERF"
403
- @a0_0_1.instance_variable_set :@extensions, "E"
404
- @a0_0_1.instance_variable_set :@executables, "X"
406
+ @a1.instance_variable_set :@files, "F"
407
+ @a1.instance_variable_set :@test_files, "TF"
408
+ @a1.instance_variable_set :@extra_rdoc_files, "ERF"
409
+ @a1.instance_variable_set :@extensions, "E"
410
+ @a1.instance_variable_set :@executables, "X"
411
+
412
+ assert_equal %w[E ERF F TF bin/X], @a1.files.sort
413
+ assert_kind_of Integer, @a1.hash
414
+ end
405
415
 
406
- assert_equal %w[E ERF F TF bin/X], @a0_0_1.files.sort
407
- assert_kind_of Integer, @a0_0_1.hash
416
+ def test_full_gem_path
417
+ assert_equal File.join(@gemhome, 'gems', @a1.full_name),
418
+ @a1.full_gem_path
419
+
420
+ @a1.original_platform = 'mswin32'
421
+
422
+ assert_equal File.join(@gemhome, 'gems', @a1.original_name),
423
+ @a1.full_gem_path
408
424
  end
409
425
 
410
426
  def test_full_name
411
- assert_equal 'a-0.0.1', @a0_0_1.full_name
427
+ assert_equal 'a-1', @a1.full_name
412
428
 
413
- @a0_0_1.platform = Gem::Platform.new ['universal', 'darwin', nil]
414
- assert_equal 'a-0.0.1-universal-darwin', @a0_0_1.full_name
429
+ @a1.platform = Gem::Platform.new ['universal', 'darwin', nil]
430
+ assert_equal 'a-1-universal-darwin', @a1.full_name
415
431
 
416
- @a0_0_1.instance_variable_set :@new_platform, 'mswin32'
417
- assert_equal 'a-0.0.1-mswin32', @a0_0_1.full_name, 'legacy'
432
+ @a1.instance_variable_set :@new_platform, 'mswin32'
433
+ assert_equal 'a-1-mswin32', @a1.full_name, 'legacy'
418
434
 
419
435
  return if win_platform?
420
436
 
421
- @a0_0_1.platform = 'current'
422
- assert_equal 'a-0.0.1-x86-darwin-8', @a0_0_1.full_name
437
+ @a1.platform = 'current'
438
+ assert_equal 'a-1-x86-darwin-8', @a1.full_name
423
439
  end
424
440
 
425
441
  def test_full_name_windows
426
442
  test_cases = {
427
- 'i386-mswin32' => 'a-0.0.1-x86-mswin32-60',
428
- 'i386-mswin32_80' => 'a-0.0.1-x86-mswin32-80',
429
- 'i386-mingw32' => 'a-0.0.1-x86-mingw32'
443
+ 'i386-mswin32' => 'a-1-x86-mswin32-60',
444
+ 'i386-mswin32_80' => 'a-1-x86-mswin32-80',
445
+ 'i386-mingw32' => 'a-1-x86-mingw32'
430
446
  }
431
447
 
432
448
  test_cases.each do |arch, expected|
433
449
  util_set_arch arch
434
- @a0_0_1.platform = 'current'
435
- assert_equal expected, @a0_0_1.full_name
450
+ @a1.platform = 'current'
451
+ assert_equal expected, @a1.full_name
436
452
  end
437
453
  end
438
454
 
439
455
  def test_has_rdoc_eh
440
- assert_equal true, @a0_0_1.has_rdoc?
456
+ assert_equal true, @a1.has_rdoc?
441
457
  end
442
458
 
443
459
  def test_hash
444
- assert_equal @a0_0_1.hash, @a0_0_1.hash
445
- assert_equal @a0_0_1.hash, @a0_0_1.dup.hash
446
- assert_not_equal @a0_0_1.hash, @a0_0_2.hash
460
+ assert_equal @a1.hash, @a1.hash
461
+ assert_equal @a1.hash, @a1.dup.hash
462
+ assert_not_equal @a1.hash, @a2.hash
447
463
  end
448
464
 
449
465
  def test_lib_files
450
- @a0_0_1.files = %w[lib/foo.rb Rakefile]
466
+ @a1.files = %w[lib/foo.rb Rakefile]
451
467
 
452
- assert_equal %w[lib/foo.rb], @a0_0_1.lib_files
468
+ assert_equal %w[lib/foo.rb], @a1.lib_files
453
469
  end
454
470
 
455
471
  def test_name
456
- assert_equal 'a', @a0_0_1.name
472
+ assert_equal 'a', @a1.name
457
473
  end
458
474
 
459
475
  def test_original_name
460
- assert_equal 'a-0.0.1', @a0_0_1.full_name
476
+ assert_equal 'a-1', @a1.full_name
461
477
 
462
- @a0_0_1.platform = 'i386-linux'
463
- @a0_0_1.instance_variable_set :@original_platform, 'i386-linux'
464
- assert_equal 'a-0.0.1-i386-linux', @a0_0_1.original_name
478
+ @a1.platform = 'i386-linux'
479
+ @a1.instance_variable_set :@original_platform, 'i386-linux'
480
+ assert_equal 'a-1-i386-linux', @a1.original_name
465
481
  end
466
482
 
467
483
  def test_platform
468
- assert_equal Gem::Platform::RUBY, @a0_0_1.platform
484
+ assert_equal Gem::Platform::RUBY, @a1.platform
469
485
  end
470
486
 
471
487
  def test_platform_equals
472
- @a0_0_1.platform = nil
473
- assert_equal Gem::Platform::RUBY, @a0_0_1.platform
488
+ @a1.platform = nil
489
+ assert_equal Gem::Platform::RUBY, @a1.platform
474
490
 
475
- @a0_0_1.platform = Gem::Platform::RUBY
476
- assert_equal Gem::Platform::RUBY, @a0_0_1.platform
491
+ @a1.platform = Gem::Platform::RUBY
492
+ assert_equal Gem::Platform::RUBY, @a1.platform
477
493
 
478
494
  test_cases = {
479
495
  'i386-mswin32' => ['x86', 'mswin32', '60'],
@@ -484,29 +500,35 @@ end
484
500
 
485
501
  test_cases.each do |arch, expected|
486
502
  util_set_arch arch
487
- @a0_0_1.platform = Gem::Platform::CURRENT
488
- assert_equal Gem::Platform.new(expected), @a0_0_1.platform
503
+ @a1.platform = Gem::Platform::CURRENT
504
+ assert_equal Gem::Platform.new(expected), @a1.platform
489
505
  end
490
506
  end
491
507
 
508
+ def test_platform_equals_current
509
+ @a1.platform = Gem::Platform::CURRENT
510
+ assert_equal Gem::Platform.local, @a1.platform
511
+ assert_equal Gem::Platform.local.to_s, @a1.original_platform
512
+ end
513
+
492
514
  def test_platform_equals_legacy
493
- @a0_0_1.platform = Gem::Platform::WIN32
494
- assert_equal Gem::Platform::MSWIN32, @a0_0_1.platform
515
+ @a1.platform = 'mswin32'
516
+ assert_equal Gem::Platform.new('x86-mswin32'), @a1.platform
495
517
 
496
- @a0_0_1.platform = Gem::Platform::LINUX_586
497
- assert_equal Gem::Platform::X86_LINUX, @a0_0_1.platform
518
+ @a1.platform = 'i586-linux'
519
+ assert_equal Gem::Platform.new('x86-linux'), @a1.platform
498
520
 
499
- @a0_0_1.platform = Gem::Platform::DARWIN
500
- assert_equal Gem::Platform::PPC_DARWIN, @a0_0_1.platform
521
+ @a1.platform = 'powerpc-darwin'
522
+ assert_equal Gem::Platform.new('ppc-darwin'), @a1.platform
501
523
  end
502
524
 
503
525
  def test_require_paths
504
- @a0_0_1.require_path = 'lib'
505
- assert_equal %w[lib], @a0_0_1.require_paths
526
+ @a1.require_path = 'lib'
527
+ assert_equal %w[lib], @a1.require_paths
506
528
  end
507
529
 
508
530
  def test_requirements
509
- assert_equal ['A working computer'], @a0_0_1.requirements
531
+ assert_equal ['A working computer'], @a1.requirements
510
532
  end
511
533
 
512
534
  def test_spaceship_name
@@ -539,28 +561,22 @@ end
539
561
  end
540
562
 
541
563
  def test_summary
542
- assert_equal 'this is a summary', @a0_0_1.summary
564
+ assert_equal 'this is a summary', @a1.summary
543
565
  end
544
566
 
545
567
  def test_test_files
546
- @a0_0_1.test_file = 'test/suite.rb'
547
- assert_equal ['test/suite.rb'], @a0_0_1.test_files
548
- end
549
-
550
- def test_test_suite_file
551
- @a0_0_2.test_suite_file = 'test/suite.rb'
552
- assert_equal ['test/suite.rb'], @a0_0_2.test_files
553
- # XXX: what about the warning?
568
+ @a1.test_file = 'test/suite.rb'
569
+ assert_equal ['test/suite.rb'], @a1.test_files
554
570
  end
555
571
 
556
572
  def test_to_ruby
557
- @a0_0_2.required_rubygems_version = Gem::Requirement.new '> 0'
573
+ @a2.required_rubygems_version = Gem::Requirement.new '> 0'
558
574
 
559
- ruby_code = @a0_0_2.to_ruby
575
+ ruby_code = @a2.to_ruby
560
576
 
561
577
  expected = "Gem::Specification.new do |s|
562
578
  s.name = %q{a}
563
- s.version = \"0.0.2\"
579
+ s.version = \"2\"
564
580
 
565
581
  s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION} if s.respond_to? :specification_version=
566
582
 
@@ -582,17 +598,20 @@ end
582
598
 
583
599
  same_spec = eval ruby_code
584
600
 
585
- assert_equal @a0_0_2, same_spec
601
+ assert_equal @a2, same_spec
586
602
  end
587
603
 
588
604
  def test_to_ruby_fancy
589
- @a0_0_1.platform = Gem::Platform::PPC_DARWIN
590
- ruby_code = @a0_0_1.to_ruby
605
+ @a1.platform = Gem::Platform.local
606
+ ruby_code = @a1.to_ruby
607
+
608
+ local = Gem::Platform.local
609
+ expected_platform = "[#{local.cpu.inspect}, #{local.os.inspect}, #{local.version.inspect}]"
591
610
 
592
611
  expected = "Gem::Specification.new do |s|
593
612
  s.name = %q{a}
594
- s.version = \"0.0.1\"
595
- s.platform = Gem::Platform.new([\"ppc\", \"darwin\", nil])
613
+ s.version = \"1\"
614
+ s.platform = Gem::Platform.new(#{expected_platform})
596
615
 
597
616
  s.specification_version = 2 if s.respond_to? :specification_version=
598
617
 
@@ -609,6 +628,7 @@ end
609
628
  s.homepage = %q{http://example.com}
610
629
  s.require_paths = [\"lib\"]
611
630
  s.requirements = [\"A working computer\"]
631
+ s.rubyforge_project = %q{example}
612
632
  s.rubygems_version = %q{#{Gem::RubyGemsVersion}}
613
633
  s.summary = %q{this is a summary}
614
634
  s.test_files = [\"test/suite.rb\"]
@@ -623,7 +643,7 @@ end
623
643
 
624
644
  same_spec = eval ruby_code
625
645
 
626
- assert_equal @a0_0_1, same_spec
646
+ assert_equal @a1, same_spec
627
647
  end
628
648
 
629
649
  def test_to_ruby_legacy
@@ -635,10 +655,10 @@ end
635
655
  end
636
656
 
637
657
  def test_to_ruby_platform
638
- @a0_0_2.platform = Gem::Platform.local
639
- @a0_0_2.instance_variable_set :@original_platform, 'old_platform'
658
+ @a2.platform = Gem::Platform.local
659
+ @a2.instance_variable_set :@original_platform, 'old_platform'
640
660
 
641
- ruby_code = @a0_0_2.to_ruby
661
+ ruby_code = @a2.to_ruby
642
662
 
643
663
  same_spec = eval ruby_code
644
664
 
@@ -646,28 +666,34 @@ end
646
666
  end
647
667
 
648
668
  def test_to_yaml
649
- yaml_str = @a0_0_1.to_yaml
669
+ yaml_str = @a1.to_yaml
650
670
  same_spec = YAML.load(yaml_str)
651
671
 
652
- assert_equal @a0_0_1, same_spec
672
+ assert_equal @a1, same_spec
653
673
  end
654
674
 
655
675
  def test_to_yaml_fancy
656
- @a0_0_1.platform = Gem::Platform::PPC_DARWIN
657
- yaml_str = @a0_0_1.to_yaml
676
+ @a1.platform = Gem::Platform.local
677
+ yaml_str = @a1.to_yaml
658
678
 
659
679
  same_spec = YAML.load(yaml_str)
660
680
 
661
- assert_equal Gem::Platform::PPC_DARWIN, same_spec.platform
681
+ assert_equal Gem::Platform.local, same_spec.platform
662
682
 
663
- assert_equal @a0_0_1, same_spec
683
+ assert_equal @a1, same_spec
664
684
  end
665
685
 
666
- def test_to_yaml_legacy_platform
667
- @a0_0_1.platform = 'powerpc-darwin7.9.0'
668
- @a0_0_1.instance_variable_set :@original_platform, 'powerpc-darwin7.9.0'
686
+ def test_to_yaml_platform_empty_string
687
+ @a1.instance_variable_set :@original_platform, ''
669
688
 
670
- yaml_str = @a0_0_1.to_yaml
689
+ assert_match %r|^platform: ruby$|, @a1.to_yaml
690
+ end
691
+
692
+ def test_to_yaml_platform_legacy
693
+ @a1.platform = 'powerpc-darwin7.9.0'
694
+ @a1.instance_variable_set :@original_platform, 'powerpc-darwin7.9.0'
695
+
696
+ yaml_str = @a1.to_yaml
671
697
 
672
698
  same_spec = YAML.load(yaml_str)
673
699
 
@@ -675,8 +701,61 @@ end
675
701
  assert_equal 'powerpc-darwin7.9.0', same_spec.original_platform
676
702
  end
677
703
 
704
+ def test_to_yaml_platform_nil
705
+ @a1.instance_variable_set :@original_platform, nil
706
+
707
+ assert_match %r|^platform: ruby$|, @a1.to_yaml
708
+ end
709
+
678
710
  def test_validate
679
- assert @a0_0_1.validate
711
+ Dir.chdir @tempdir do
712
+ assert @a1.validate
713
+ end
714
+ end
715
+
716
+ def test_validate_authors
717
+ Dir.chdir @tempdir do
718
+ @a1.authors = []
719
+
720
+ use_ui @ui do
721
+ @a1.validate
722
+ end
723
+
724
+ assert_equal "WARNING: no author specified\n", @ui.error, 'error'
725
+
726
+ @a1.authors = [Object.new]
727
+
728
+ e = assert_raise Gem::InvalidSpecificationException do
729
+ @a1.validate
730
+ end
731
+
732
+ assert_equal 'authors must be Array of Strings', e.message
733
+ end
734
+ end
735
+
736
+ def test_validate_autorequire
737
+ Dir.chdir @tempdir do
738
+ @a1.autorequire = 'code'
739
+
740
+ use_ui @ui do
741
+ @a1.validate
742
+ end
743
+
744
+ assert_equal "WARNING: deprecated autorequire specified\n",
745
+ @ui.error, 'error'
746
+ end
747
+ end
748
+
749
+ def test_validate_email
750
+ Dir.chdir @tempdir do
751
+ @a1.email = ''
752
+
753
+ use_ui @ui do
754
+ @a1.validate
755
+ end
756
+
757
+ assert_equal "WARNING: no email specified\n", @ui.error, 'error'
758
+ end
680
759
  end
681
760
 
682
761
  def test_validate_empty
@@ -687,51 +766,104 @@ end
687
766
  assert_equal 'missing value for attribute name', e.message
688
767
  end
689
768
 
769
+ def test_validate_executables
770
+ FileUtils.mkdir_p File.join(@tempdir, 'bin')
771
+ File.open File.join(@tempdir, 'bin', 'exec'), 'w' do end
772
+
773
+ use_ui @ui do
774
+ Dir.chdir @tempdir do
775
+ assert @a1.validate
776
+ end
777
+ end
778
+
779
+ assert_equal '', @ui.output, 'output'
780
+ assert_equal "WARNING: bin/exec is missing #! line\n", @ui.error, 'error'
781
+ end
782
+
690
783
  def test_validate_empty_require_paths
691
- @a0_0_1.require_paths = []
784
+ @a1.require_paths = []
692
785
  e = assert_raise Gem::InvalidSpecificationException do
693
- @a0_0_1.validate
786
+ @a1.validate
694
787
  end
695
788
 
696
789
  assert_equal 'specification must have at least one require_path', e.message
697
790
  end
698
791
 
699
- def test_validate_platform_bad
700
- @a0_0_1.platform = Object.new
701
- assert_raise Gem::InvalidSpecificationException do @a0_0_1.validate end
792
+ def test_validate_homepage
793
+ Dir.chdir @tempdir do
794
+ @a1.homepage = ''
702
795
 
703
- @a0_0_1.platform = "my-custom-platform"
704
- e = assert_raise Gem::InvalidSpecificationException do
705
- @a0_0_1.validate
796
+ use_ui @ui do
797
+ @a1.validate
798
+ end
799
+
800
+ assert_equal "WARNING: no homepage specified\n", @ui.error, 'error'
706
801
  end
802
+ end
707
803
 
708
- assert_equal 'invalid platform "my-custom-platform", see Gem::Platform',
709
- e.message
804
+ def test_validate_has_rdoc
805
+ Dir.chdir @tempdir do
806
+ @a1.has_rdoc = false
807
+
808
+ use_ui @ui do
809
+ @a1.validate
810
+ end
811
+
812
+ assert_equal "WARNING: RDoc will not be generated (has_rdoc == false)\n",
813
+ @ui.error, 'error'
814
+ end
710
815
  end
711
816
 
712
817
  def test_validate_platform_legacy
713
- @a0_0_1.platform = Gem::Platform::WIN32
714
- assert @a0_0_1.validate
818
+ Dir.chdir @tempdir do
819
+ @a1.platform = 'mswin32'
820
+ assert @a1.validate
821
+
822
+ @a1.platform = 'i586-linux'
823
+ assert @a1.validate
824
+
825
+ @a1.platform = 'powerpc-darwin'
826
+ assert @a1.validate
827
+ end
828
+ end
715
829
 
716
- @a0_0_1.platform = Gem::Platform::LINUX_586
717
- assert @a0_0_1.validate
830
+ def test_validate_rubyforge_project
831
+ Dir.chdir @tempdir do
832
+ @a1.rubyforge_project = ''
718
833
 
719
- @a0_0_1.platform = Gem::Platform::DARWIN
720
- assert @a0_0_1.validate
834
+ use_ui @ui do
835
+ @a1.validate
836
+ end
837
+
838
+ assert_equal "WARNING: no rubyforge_project specified\n",
839
+ @ui.error, 'error'
840
+ end
721
841
  end
722
842
 
723
843
  def test_validate_rubygems_version
724
- @a0_0_1.rubygems_version = "3"
844
+ @a1.rubygems_version = "3"
725
845
  e = assert_raise Gem::InvalidSpecificationException do
726
- @a0_0_1.validate
846
+ @a1.validate
727
847
  end
728
848
 
729
849
  assert_equal "expected RubyGems version #{Gem::RubyGemsVersion}, was 3",
730
850
  e.message
731
851
  end
732
852
 
853
+ def test_validate_summary
854
+ Dir.chdir @tempdir do
855
+ @a1.summary = ''
856
+
857
+ use_ui @ui do
858
+ @a1.validate
859
+ end
860
+
861
+ assert_equal "WARNING: no summary specified\n", @ui.error, 'error'
862
+ end
863
+ end
864
+
733
865
  def test_version
734
- assert_equal Gem::Version.new('0.0.1'), @a0_0_1.version
866
+ assert_equal Gem::Version.new('1'), @a1.version
735
867
  end
736
868
 
737
869
  end