rubygems-update 1.3.1 → 1.3.2

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 (128) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +24 -0
  3. data/.document +4 -3
  4. data/ChangeLog +382 -1
  5. data/Manifest.txt +214 -0
  6. data/README +1 -49
  7. data/Rakefile +124 -191
  8. data/bin/gem +1 -4
  9. data/cruise_config.rb +22 -0
  10. data/doc/release_notes/rel_1_3_1.rdoc +3 -3
  11. data/doc/release_notes/rel_1_3_2.rdoc +119 -0
  12. data/lib/gauntlet_rubygems.rb +50 -0
  13. data/lib/rubygems.rb +250 -25
  14. data/lib/rubygems/builder.rb +62 -60
  15. data/lib/rubygems/command.rb +421 -319
  16. data/lib/rubygems/command_manager.rb +153 -125
  17. data/lib/rubygems/commands/check_command.rb +12 -7
  18. data/lib/rubygems/commands/cleanup_command.rb +11 -2
  19. data/lib/rubygems/commands/contents_command.rb +42 -18
  20. data/lib/rubygems/commands/generate_index_command.rb +91 -15
  21. data/lib/rubygems/commands/install_command.rb +33 -47
  22. data/lib/rubygems/commands/query_command.rb +36 -20
  23. data/lib/rubygems/commands/rdoc_command.rb +62 -68
  24. data/lib/rubygems/commands/search_command.rb +26 -32
  25. data/lib/rubygems/commands/setup_command.rb +353 -0
  26. data/lib/rubygems/commands/sources_command.rb +5 -0
  27. data/lib/rubygems/commands/specification_command.rb +23 -3
  28. data/lib/rubygems/commands/uninstall_command.rb +71 -61
  29. data/lib/rubygems/commands/unpack_command.rb +14 -12
  30. data/lib/rubygems/commands/update_command.rb +26 -5
  31. data/lib/rubygems/defaults.rb +16 -3
  32. data/lib/rubygems/dependency.rb +38 -7
  33. data/lib/rubygems/dependency_installer.rb +7 -4
  34. data/lib/rubygems/digest/digest_adapter.rb +42 -33
  35. data/lib/rubygems/digest/sha1.rb +6 -1
  36. data/lib/rubygems/digest/sha2.rb +5 -0
  37. data/lib/rubygems/doc_manager.rb +31 -11
  38. data/lib/rubygems/ext/ext_conf_builder.rb +2 -1
  39. data/lib/rubygems/ext/rake_builder.rb +6 -2
  40. data/lib/rubygems/format.rb +63 -63
  41. data/lib/rubygems/gem_openssl.rb +14 -2
  42. data/lib/rubygems/gem_path_searcher.rb +7 -3
  43. data/lib/rubygems/gem_runner.rb +59 -39
  44. data/lib/rubygems/indexer.rb +450 -109
  45. data/lib/rubygems/install_update_options.rb +13 -1
  46. data/lib/rubygems/installer.rb +25 -22
  47. data/lib/rubygems/local_remote_options.rb +5 -3
  48. data/lib/rubygems/old_format.rb +124 -120
  49. data/lib/rubygems/package/tar_header.rb +25 -3
  50. data/lib/rubygems/package/tar_input.rb +5 -5
  51. data/lib/rubygems/package/tar_output.rb +2 -0
  52. data/lib/rubygems/package/tar_reader.rb +19 -0
  53. data/lib/rubygems/package/tar_reader/entry.rb +43 -0
  54. data/lib/rubygems/package/tar_writer.rb +65 -3
  55. data/lib/rubygems/package_task.rb +117 -0
  56. data/lib/rubygems/platform.rb +12 -8
  57. data/lib/rubygems/remote_fetcher.rb +43 -24
  58. data/lib/rubygems/require_paths_builder.rb +14 -12
  59. data/lib/rubygems/requirement.rb +15 -6
  60. data/lib/rubygems/rubygems_version.rb +14 -1
  61. data/lib/rubygems/source_index.rb +38 -16
  62. data/lib/rubygems/source_info_cache_entry.rb +2 -2
  63. data/lib/rubygems/spec_fetcher.rb +43 -20
  64. data/lib/rubygems/specification.rb +1122 -947
  65. data/lib/rubygems/text.rb +30 -0
  66. data/lib/rubygems/timer.rb +14 -11
  67. data/lib/rubygems/uninstaller.rb +25 -5
  68. data/lib/rubygems/user_interaction.rb +294 -264
  69. data/lib/rubygems/validator.rb +70 -36
  70. data/lib/rubygems/version.rb +97 -33
  71. data/lib/rubygems/version_option.rb +1 -0
  72. data/setup.rb +11 -306
  73. data/test/foo/discover.rb +0 -0
  74. data/test/gem_installer_test_case.rb +22 -11
  75. data/test/gem_package_tar_test_case.rb +0 -14
  76. data/test/gemutilities.rb +89 -8
  77. data/test/mockgemui.rb +2 -1
  78. data/test/rubygems_plugin.rb +16 -0
  79. data/test/test_gem.rb +107 -36
  80. data/test/test_gem_command.rb +3 -13
  81. data/test/test_gem_command_manager.rb +1 -14
  82. data/test/test_gem_commands_cert_command.rb +1 -1
  83. data/test/test_gem_commands_contents_command.rb +63 -0
  84. data/test/test_gem_commands_environment_command.rb +1 -1
  85. data/test/test_gem_commands_generate_index_command.rb +104 -1
  86. data/test/test_gem_commands_install_command.rb +95 -0
  87. data/test/test_gem_commands_pristine_command.rb +3 -3
  88. data/test/test_gem_commands_query_command.rb +46 -0
  89. data/test/test_gem_commands_sources_command.rb +9 -5
  90. data/test/test_gem_commands_specification_command.rb +31 -0
  91. data/test/test_gem_commands_uninstall_command.rb +3 -2
  92. data/test/test_gem_commands_unpack_command.rb +3 -2
  93. data/test/test_gem_commands_update_command.rb +12 -7
  94. data/test/test_gem_dependency.rb +62 -11
  95. data/test/test_gem_dependency_installer.rb +18 -5
  96. data/test/test_gem_dependency_list.rb +6 -6
  97. data/test/test_gem_doc_manager.rb +7 -1
  98. data/test/test_gem_ext_configure_builder.rb +8 -10
  99. data/test/test_gem_ext_ext_conf_builder.rb +14 -8
  100. data/test/test_gem_gem_path_searcher.rb +1 -1
  101. data/test/test_gem_gem_runner.rb +11 -0
  102. data/test/test_gem_indexer.rb +398 -21
  103. data/test/test_gem_install_update_options.rb +20 -6
  104. data/test/test_gem_installer.rb +22 -14
  105. data/test/test_gem_local_remote_options.rb +2 -1
  106. data/test/test_gem_package_tar_header.rb +3 -3
  107. data/test/test_gem_package_tar_input.rb +3 -3
  108. data/test/test_gem_package_tar_output.rb +2 -2
  109. data/test/test_gem_package_task.rb +70 -0
  110. data/test/test_gem_platform.rb +12 -6
  111. data/test/test_gem_remote_fetcher.rb +23 -1
  112. data/test/test_gem_source_index.rb +32 -21
  113. data/test/test_gem_spec_fetcher.rb +77 -5
  114. data/test/test_gem_specification.rb +274 -1
  115. data/test/test_gem_uninstaller.rb +34 -4
  116. data/test/test_gem_version.rb +94 -4
  117. data/test/test_gem_version_option.rb +13 -0
  118. data/test/test_kernel.rb +4 -4
  119. data/util/CL2notes +56 -0
  120. data/util/gem_prelude.rb.template +251 -0
  121. metadata +30 -20
  122. metadata.gz.sig +3 -4
  123. data/TODO +0 -1
  124. data/scripts/buildtests.rb +0 -31
  125. data/scripts/gemdoc.rb +0 -67
  126. data/scripts/runtest.rb +0 -40
  127. data/scripts/specdoc.rb +0 -171
  128. data/scripts/upload_gemdoc.rb +0 -140
@@ -10,22 +10,31 @@ class TestGemSpecFetcher < RubyGemTestCase
10
10
 
11
11
  util_setup_fake_fetcher
12
12
 
13
+ @a_pre = quick_gem 'a', '1.a'
13
14
  @source_index.add_spec @pl1
15
+ @source_index.add_spec @a_pre
14
16
 
15
17
  @specs = @source_index.gems.sort.map do |name, spec|
16
18
  [spec.name, spec.version, spec.original_platform]
17
19
  end.sort
18
20
 
19
- @fetcher.data["#{@gem_repo}specs.#{Gem.marshal_version}.gz"] =
20
- util_gzip(Marshal.dump(@specs))
21
-
22
21
  @latest_specs = @source_index.latest_specs.sort.map do |spec|
23
22
  [spec.name, spec.version, spec.original_platform]
24
23
  end
25
24
 
25
+ @prerelease_specs = @source_index.prerelease_gems.sort.map do |name, spec|
26
+ [spec.name, spec.version, spec.original_platform]
27
+ end.sort
28
+
29
+ @fetcher.data["#{@gem_repo}specs.#{Gem.marshal_version}.gz"] =
30
+ util_gzip(Marshal.dump(@specs))
31
+
26
32
  @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] =
27
33
  util_gzip(Marshal.dump(@latest_specs))
28
34
 
35
+ @fetcher.data["#{@gem_repo}prerelease_specs.#{Gem.marshal_version}.gz"] =
36
+ util_gzip(Marshal.dump(@prerelease_specs))
37
+
29
38
  @sf = Gem::SpecFetcher.new
30
39
  end
31
40
 
@@ -34,6 +43,8 @@ class TestGemSpecFetcher < RubyGemTestCase
34
43
  util_zip(Marshal.dump(@a1))
35
44
  @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a2.full_name}.gemspec.rz"] =
36
45
  util_zip(Marshal.dump(@a2))
46
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a_pre.full_name}.gemspec.rz"] =
47
+ util_zip(Marshal.dump(@a_pre))
37
48
 
38
49
  dep = Gem::Dependency.new 'a', 1
39
50
  specs_and_sources = @sf.fetch dep, true
@@ -54,6 +65,8 @@ class TestGemSpecFetcher < RubyGemTestCase
54
65
  util_zip(Marshal.dump(@a1))
55
66
  @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a2.full_name}.gemspec.rz"] =
56
67
  util_zip(Marshal.dump(@a2))
68
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a_pre.full_name}.gemspec.rz"] =
69
+ util_zip(Marshal.dump(@a_pre))
57
70
 
58
71
  dep = Gem::Dependency.new 'a', 1
59
72
  specs_and_sources = @sf.fetch dep
@@ -65,6 +78,24 @@ class TestGemSpecFetcher < RubyGemTestCase
65
78
  assert_equal [[@a2.full_name, @gem_repo]], spec_names
66
79
  end
67
80
 
81
+ def test_fetch_prerelease
82
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.full_name}.gemspec.rz"] =
83
+ util_zip(Marshal.dump(@a1))
84
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a2.full_name}.gemspec.rz"] =
85
+ util_zip(Marshal.dump(@a2))
86
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a_pre.full_name}.gemspec.rz"] =
87
+ util_zip(Marshal.dump(@a_pre))
88
+
89
+ dep = Gem::Dependency.new 'a', '1.a'
90
+ specs_and_sources = @sf.fetch dep, false, true, true
91
+
92
+ spec_names = specs_and_sources.map do |spec, source_uri|
93
+ [spec.full_name, source_uri]
94
+ end
95
+
96
+ assert_equal [[@a_pre.full_name, @gem_repo]], spec_names
97
+ end
98
+
68
99
  def test_fetch_legacy_repo
69
100
  @fetcher.data.delete "#{@gem_repo}specs.#{Gem.marshal_version}.gz"
70
101
  @fetcher.data["#{@gem_repo}yaml"] = ''
@@ -186,6 +217,17 @@ RubyGems will revert to legacy indexes degrading performance.
186
217
  assert_equal expected, specs
187
218
  end
188
219
 
220
+ def test_find_matching_prerelease
221
+ dep = Gem::Dependency.new 'a', '1.a'
222
+ specs = @sf.find_matching dep, false, true, true
223
+
224
+ expected = [
225
+ [['a', Gem::Version.new('1.a'), Gem::Platform::RUBY], @gem_repo],
226
+ ]
227
+
228
+ assert_equal expected, specs
229
+ end
230
+
189
231
  def test_find_matching_platform
190
232
  util_set_arch 'i386-linux'
191
233
 
@@ -237,7 +279,7 @@ RubyGems will revert to legacy indexes degrading performance.
237
279
  def test_list_cache
238
280
  specs = @sf.list
239
281
 
240
- assert !specs[@uri].empty?
282
+ refute specs[@uri].empty?
241
283
 
242
284
  @fetcher.data["#{@gem_repo}/latest_specs.#{Gem.marshal_version}.gz"] = nil
243
285
 
@@ -249,7 +291,7 @@ RubyGems will revert to legacy indexes degrading performance.
249
291
  def test_list_cache_all
250
292
  specs = @sf.list true
251
293
 
252
- assert !specs[@uri].empty?
294
+ refute specs[@uri].empty?
253
295
 
254
296
  @fetcher.data["#{@gem_repo}/specs.#{Gem.marshal_version}.gz"] = nil
255
297
 
@@ -268,6 +310,12 @@ RubyGems will revert to legacy indexes degrading performance.
268
310
  assert_equal [@specs], specs.values, 'specs file not loaded'
269
311
  end
270
312
 
313
+ def test_list_prerelease
314
+ specs = @sf.list false, true
315
+
316
+ assert_equal @prerelease_specs, specs[@uri].sort
317
+ end
318
+
271
319
  def test_load_specs
272
320
  specs = @sf.load_specs @uri, 'specs'
273
321
 
@@ -308,5 +356,29 @@ RubyGems will revert to legacy indexes degrading performance.
308
356
  assert_equal @latest_specs, latest_specs
309
357
  end
310
358
 
359
+ def test_load_specs_cached_empty
360
+ @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] =
361
+ proc do
362
+ @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] =
363
+ util_gzip(Marshal.dump(@latest_specs))
364
+
365
+ nil
366
+ end
367
+
368
+ cache_dir = File.join Gem.user_home, '.gem', 'specs', 'gems.example.com%80'
369
+
370
+ FileUtils.mkdir_p cache_dir
371
+
372
+ cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}"
373
+
374
+ open cache_file, 'wb' do |io|
375
+ io.write Marshal.dump(@latest_specs)[0, 10]
376
+ end
377
+
378
+ latest_specs = @sf.load_specs @uri, 'latest_specs'
379
+
380
+ assert_equal @latest_specs, latest_specs
381
+ end
382
+
311
383
  end
312
384
 
@@ -53,6 +53,7 @@ end
53
53
  s.test_file = 'test/suite.rb'
54
54
  s.requirements << 'A working computer'
55
55
  s.rubyforge_project = 'example'
56
+ s.license = 'MIT'
56
57
 
57
58
  s.add_dependency 'rake', '> 0.4'
58
59
  s.add_dependency 'jabber4r', '> 0.0.0'
@@ -91,6 +92,7 @@ end
91
92
  files
92
93
  has_rdoc
93
94
  homepage
95
+ licenses
94
96
  name
95
97
  platform
96
98
  post_install_message
@@ -216,6 +218,80 @@ end
216
218
  assert_equal "1.3.5", spec.version.to_s
217
219
  end
218
220
 
221
+ def test_initialize_copy
222
+ spec = Gem::Specification.new do |s|
223
+ s.name = "blah"
224
+ s.version = "1.3.5"
225
+ s.summary = 'summary'
226
+ s.description = 'description'
227
+ s.authors = 'author a', 'author b'
228
+ s.licenses = 'BSD'
229
+ s.files = 'lib/file.rb'
230
+ s.test_files = 'test/file.rb'
231
+ s.rdoc_options = '--foo'
232
+ s.extra_rdoc_files = 'README.txt'
233
+ s.executables = 'exec'
234
+ s.extensions = 'ext/extconf.rb'
235
+ s.requirements = 'requirement'
236
+ s.add_dependency 'some_gem'
237
+ end
238
+
239
+ new_spec = spec.dup
240
+
241
+ assert_equal "blah", spec.name
242
+ assert_same spec.name, new_spec.name
243
+
244
+ assert_equal "1.3.5", spec.version.to_s
245
+ assert_same spec.version, new_spec.version
246
+
247
+ assert_equal Gem::Platform::RUBY, spec.platform
248
+ assert_same spec.platform, new_spec.platform
249
+
250
+ assert_equal 'summary', spec.summary
251
+ assert_same spec.summary, new_spec.summary
252
+
253
+ assert_equal %w[lib/file.rb test/file.rb bin/exec README.txt
254
+ ext/extconf.rb],
255
+ spec.files
256
+ refute_same spec.files, new_spec.files, 'files'
257
+
258
+ assert_equal %w[test/file.rb], spec.test_files
259
+ refute_same spec.test_files, new_spec.test_files, 'test_files'
260
+
261
+ assert_equal %w[--foo], spec.rdoc_options
262
+ refute_same spec.rdoc_options, new_spec.rdoc_options, 'rdoc_options'
263
+
264
+ assert_equal %w[README.txt], spec.extra_rdoc_files
265
+ refute_same spec.extra_rdoc_files, new_spec.extra_rdoc_files,
266
+ 'extra_rdoc_files'
267
+
268
+ assert_equal %w[exec], spec.executables
269
+ refute_same spec.executables, new_spec.executables, 'executables'
270
+
271
+ assert_equal %w[ext/extconf.rb], spec.extensions
272
+ refute_same spec.extensions, new_spec.extensions, 'extensions'
273
+
274
+ assert_equal %w[requirement], spec.requirements
275
+ refute_same spec.requirements, new_spec.requirements, 'requirements'
276
+
277
+ assert_equal [Gem::Dependency.new('some_gem', Gem::Requirement.default)],
278
+ spec.dependencies
279
+ refute_same spec.dependencies, new_spec.dependencies, 'dependencies'
280
+
281
+ assert_equal 'bin', spec.bindir
282
+ assert_same spec.bindir, new_spec.bindir
283
+
284
+ assert_equal false, spec.has_rdoc
285
+ assert_same spec.has_rdoc, new_spec.has_rdoc
286
+
287
+ assert_equal '>= 0', spec.required_ruby_version.to_s
288
+ assert_same spec.required_ruby_version, new_spec.required_ruby_version
289
+
290
+ assert_equal '>= 0', spec.required_rubygems_version.to_s
291
+ assert_same spec.required_rubygems_version,
292
+ new_spec.required_rubygems_version
293
+ end
294
+
219
295
  def test__dump
220
296
  @a2.platform = Gem::Platform.local
221
297
  @a2.instance_variable_set :@original_platform, 'old_platform'
@@ -514,6 +590,14 @@ end
514
590
  assert_equal %w[lib/foo.rb], @a1.lib_files
515
591
  end
516
592
 
593
+ def test_license
594
+ assert_equal 'MIT', @a1.license
595
+ end
596
+
597
+ def test_licenses
598
+ assert_equal ['MIT'], @a1.licenses
599
+ end
600
+
517
601
  def test_name
518
602
  assert_equal 'a', @a1.name
519
603
  end
@@ -568,6 +652,12 @@ end
568
652
  assert_equal Gem::Platform.new('ppc-darwin'), @a1.platform
569
653
  end
570
654
 
655
+ def test_prerelease_spec_adds_required_rubygems_version
656
+ @prerelease = quick_gem('tardis', '2.2.0.a')
657
+ refute @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new('1.3.1'))
658
+ assert @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new('1.4.0'))
659
+ end
660
+
571
661
  def test_require_paths
572
662
  @a1.require_path = 'lib'
573
663
  assert_equal %w[lib], @a1.require_paths
@@ -700,6 +790,7 @@ Gem::Specification.new do |s|
700
790
  s.files = [\"lib/code.rb\", \"test/suite.rb\", \"bin/exec\", \"ext/a/extconf.rb\"]
701
791
  s.has_rdoc = %q{true}
702
792
  s.homepage = %q{http://example.com}
793
+ s.licenses = [\"MIT\"]
703
794
  s.require_paths = [\"lib\"]
704
795
  s.requirements = [\"A working computer\"]
705
796
  s.rubyforge_project = %q{example}
@@ -709,7 +800,7 @@ Gem::Specification.new do |s|
709
800
 
710
801
  if s.respond_to? :specification_version then
711
802
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
712
- s.specification_version = 2
803
+ s.specification_version = 3
713
804
 
714
805
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
715
806
  s.add_runtime_dependency(%q<rake>, [\"> 0.4\"])
@@ -797,12 +888,16 @@ end
797
888
  end
798
889
 
799
890
  def test_validate
891
+ util_setup_validate
892
+
800
893
  Dir.chdir @tempdir do
801
894
  assert @a1.validate
802
895
  end
803
896
  end
804
897
 
805
898
  def test_validate_authors
899
+ util_setup_validate
900
+
806
901
  Dir.chdir @tempdir do
807
902
  @a1.authors = []
808
903
 
@@ -819,10 +914,28 @@ end
819
914
  end
820
915
 
821
916
  assert_equal 'authors must be Array of Strings', e.message
917
+
918
+ @a1.authors = ['FIXME (who is writing this software)']
919
+
920
+ e = assert_raises Gem::InvalidSpecificationException do
921
+ @a1.validate
922
+ end
923
+
924
+ assert_equal '"FIXME" or "TODO" is not an author', e.message
925
+
926
+ @a1.authors = ['TODO (who is writing this software)']
927
+
928
+ e = assert_raises Gem::InvalidSpecificationException do
929
+ @a1.validate
930
+ end
931
+
932
+ assert_equal '"FIXME" or "TODO" is not an author', e.message
822
933
  end
823
934
  end
824
935
 
825
936
  def test_validate_autorequire
937
+ util_setup_validate
938
+
826
939
  Dir.chdir @tempdir do
827
940
  @a1.autorequire = 'code'
828
941
 
@@ -835,7 +948,50 @@ end
835
948
  end
836
949
  end
837
950
 
951
+ def test_validate_description
952
+ util_setup_validate
953
+
954
+ Dir.chdir @tempdir do
955
+ @a1.description = ''
956
+
957
+ use_ui @ui do
958
+ @a1.validate
959
+ end
960
+
961
+ assert_equal "WARNING: no description specified\n", @ui.error, 'error'
962
+
963
+ @ui = MockGemUi.new
964
+ @a1.summary = 'this is my summary'
965
+ @a1.description = @a1.summary
966
+
967
+ use_ui @ui do
968
+ @a1.validate
969
+ end
970
+
971
+ assert_equal "WARNING: description and summary are identical\n",
972
+ @ui.error, 'error'
973
+
974
+ @a1.description = 'FIXME (describe your package)'
975
+
976
+ e = assert_raises Gem::InvalidSpecificationException do
977
+ @a1.validate
978
+ end
979
+
980
+ assert_equal '"FIXME" or "TODO" is not a description', e.message
981
+
982
+ @a1.description = 'TODO (describe your package)'
983
+
984
+ e = assert_raises Gem::InvalidSpecificationException do
985
+ @a1.validate
986
+ end
987
+
988
+ assert_equal '"FIXME" or "TODO" is not a description', e.message
989
+ end
990
+ end
991
+
838
992
  def test_validate_email
993
+ util_setup_validate
994
+
839
995
  Dir.chdir @tempdir do
840
996
  @a1.email = ''
841
997
 
@@ -844,10 +1000,28 @@ end
844
1000
  end
845
1001
 
846
1002
  assert_equal "WARNING: no email specified\n", @ui.error, 'error'
1003
+
1004
+ @a1.email = 'FIXME (your e-mail)'
1005
+
1006
+ e = assert_raises Gem::InvalidSpecificationException do
1007
+ @a1.validate
1008
+ end
1009
+
1010
+ assert_equal '"FIXME" or "TODO" is not an email address', e.message
1011
+
1012
+ @a1.email = 'TODO (your e-mail)'
1013
+
1014
+ e = assert_raises Gem::InvalidSpecificationException do
1015
+ @a1.validate
1016
+ end
1017
+
1018
+ assert_equal '"FIXME" or "TODO" is not an email address', e.message
847
1019
  end
848
1020
  end
849
1021
 
850
1022
  def test_validate_empty
1023
+ util_setup_validate
1024
+
851
1025
  e = assert_raises Gem::InvalidSpecificationException do
852
1026
  Gem::Specification.new.validate
853
1027
  end
@@ -856,6 +1030,8 @@ end
856
1030
  end
857
1031
 
858
1032
  def test_validate_executables
1033
+ util_setup_validate
1034
+
859
1035
  FileUtils.mkdir_p File.join(@tempdir, 'bin')
860
1036
  File.open File.join(@tempdir, 'bin', 'exec'), 'w' do end
861
1037
 
@@ -870,6 +1046,8 @@ end
870
1046
  end
871
1047
 
872
1048
  def test_validate_empty_require_paths
1049
+ util_setup_validate
1050
+
873
1051
  @a1.require_paths = []
874
1052
  e = assert_raises Gem::InvalidSpecificationException do
875
1053
  @a1.validate
@@ -878,7 +1056,28 @@ end
878
1056
  assert_equal 'specification must have at least one require_path', e.message
879
1057
  end
880
1058
 
1059
+ def test_validate_files
1060
+ util_setup_validate
1061
+
1062
+ @a1.files += ['lib', 'lib2']
1063
+
1064
+ Dir.chdir @tempdir do
1065
+ FileUtils.ln_s '/root/path', 'lib2' unless vc_windows?
1066
+
1067
+ e = assert_raises Gem::InvalidSpecificationException do
1068
+ @a1.validate
1069
+ end
1070
+
1071
+ assert_equal '["lib2"] are not files', e.message
1072
+ end
1073
+
1074
+ assert_equal %w[lib/code.rb test/suite.rb bin/exec ext/a/extconf.rb lib2],
1075
+ @a1.files
1076
+ end
1077
+
881
1078
  def test_validate_homepage
1079
+ util_setup_validate
1080
+
882
1081
  Dir.chdir @tempdir do
883
1082
  @a1.homepage = ''
884
1083
 
@@ -887,10 +1086,20 @@ end
887
1086
  end
888
1087
 
889
1088
  assert_equal "WARNING: no homepage specified\n", @ui.error, 'error'
1089
+
1090
+ @a1.homepage = 'over at my cool site'
1091
+
1092
+ e = assert_raises Gem::InvalidSpecificationException do
1093
+ @a1.validate
1094
+ end
1095
+
1096
+ assert_equal '"over at my cool site" is not a URI', e.message
890
1097
  end
891
1098
  end
892
1099
 
893
1100
  def test_validate_has_rdoc
1101
+ util_setup_validate
1102
+
894
1103
  Dir.chdir @tempdir do
895
1104
  @a1.has_rdoc = false
896
1105
 
@@ -903,7 +1112,20 @@ end
903
1112
  end
904
1113
  end
905
1114
 
1115
+ def test_validate_name
1116
+ util_setup_validate
1117
+
1118
+ e = assert_raises Gem::InvalidSpecificationException do
1119
+ @a1.name = :json
1120
+ @a1.validate
1121
+ end
1122
+
1123
+ assert_equal 'invalid value for attribute name: ":json"', e.message
1124
+ end
1125
+
906
1126
  def test_validate_platform_legacy
1127
+ util_setup_validate
1128
+
907
1129
  Dir.chdir @tempdir do
908
1130
  @a1.platform = 'mswin32'
909
1131
  assert @a1.validate
@@ -917,6 +1139,8 @@ end
917
1139
  end
918
1140
 
919
1141
  def test_validate_rubyforge_project
1142
+ util_setup_validate
1143
+
920
1144
  Dir.chdir @tempdir do
921
1145
  @a1.rubyforge_project = ''
922
1146
 
@@ -930,6 +1154,8 @@ end
930
1154
  end
931
1155
 
932
1156
  def test_validate_rubygems_version
1157
+ util_setup_validate
1158
+
933
1159
  @a1.rubygems_version = "3"
934
1160
  e = assert_raises Gem::InvalidSpecificationException do
935
1161
  @a1.validate
@@ -939,7 +1165,26 @@ end
939
1165
  e.message
940
1166
  end
941
1167
 
1168
+ def test_validate_specification_version
1169
+ util_setup_validate
1170
+
1171
+ Dir.chdir @tempdir do
1172
+ @a1.specification_version = '1.0'
1173
+
1174
+ e = assert_raises Gem::InvalidSpecificationException do
1175
+ use_ui @ui do
1176
+ @a1.validate
1177
+ end
1178
+ end
1179
+
1180
+ err = 'specification_version must be a Fixnum (did you mean version?)'
1181
+ assert_equal err, e.message
1182
+ end
1183
+ end
1184
+
942
1185
  def test_validate_summary
1186
+ util_setup_validate
1187
+
943
1188
  Dir.chdir @tempdir do
944
1189
  @a1.summary = ''
945
1190
 
@@ -948,6 +1193,22 @@ end
948
1193
  end
949
1194
 
950
1195
  assert_equal "WARNING: no summary specified\n", @ui.error, 'error'
1196
+
1197
+ @a1.summary = 'FIXME (describe your package)'
1198
+
1199
+ e = assert_raises Gem::InvalidSpecificationException do
1200
+ @a1.validate
1201
+ end
1202
+
1203
+ assert_equal '"FIXME" or "TODO" is not a summary', e.message
1204
+
1205
+ @a1.summary = 'TODO (describe your package)'
1206
+
1207
+ e = assert_raises Gem::InvalidSpecificationException do
1208
+ @a1.validate
1209
+ end
1210
+
1211
+ assert_equal '"FIXME" or "TODO" is not a summary', e.message
951
1212
  end
952
1213
  end
953
1214
 
@@ -955,5 +1216,17 @@ end
955
1216
  assert_equal Gem::Version.new('1'), @a1.version
956
1217
  end
957
1218
 
1219
+ def util_setup_validate
1220
+ Dir.chdir @tempdir do
1221
+ FileUtils.mkdir_p File.join('ext', 'a')
1222
+ FileUtils.mkdir_p 'lib'
1223
+ FileUtils.mkdir_p 'test'
1224
+
1225
+ FileUtils.touch File.join('ext', 'a', 'extconf.rb')
1226
+ FileUtils.touch File.join('lib', 'code.rb')
1227
+ FileUtils.touch File.join('test', 'suite.rb')
1228
+ end
1229
+ end
1230
+
958
1231
  end
959
1232