diff options
-rw-r--r-- | test/rubygems/test_gem_specification.rb | 336 |
1 files changed, 317 insertions, 19 deletions
@@ -53,6 +53,7 @@ end s.test_file = 'test/suite.rb' s.requirements << 'A working computer' s.rubyforge_project = 'example' s.add_dependency 'rake', '> 0.4' s.add_dependency 'jabber4r', '> 0.0.0' @@ -91,6 +92,7 @@ end files has_rdoc homepage name platform post_install_message @@ -195,8 +197,8 @@ end assert_equal [], spec.requirements assert_equal [], spec.dependencies assert_equal 'bin', spec.bindir - assert_equal false, spec.has_rdoc - assert_equal false, spec.has_rdoc? assert_equal '>= 0', spec.required_ruby_version.to_s assert_equal '>= 0', spec.required_rubygems_version.to_s end @@ -216,6 +218,80 @@ end assert_equal "1.3.5", spec.version.to_s end def test__dump @a2.platform = Gem::Platform.local @a2.instance_variable_set :@original_platform, 'old_platform' @@ -355,7 +431,7 @@ end s.homepage = %q{http://www.spice-of-life.net/download/cgikit/} s.autorequire = %q{cgikit} s.bindir = nil - s.has_rdoc = nil s.required_ruby_version = nil s.platform = nil s.files = ["lib/cgikit", "lib/cgikit.rb", "lib/cgikit/components", "..."] @@ -490,7 +566,7 @@ end 'i386-mswin32_80' => 'a-1-x86-mswin32-80', 'i386-mingw32' => 'a-1-x86-mingw32' } - test_cases.each do |arch, expected| util_set_arch arch @a1.platform = 'current' @@ -502,18 +578,49 @@ end assert @a1.has_rdoc? end def test_hash assert_equal @a1.hash, @a1.hash assert_equal @a1.hash, @a1.dup.hash refute_equal @a1.hash, @a2.hash end def test_lib_files @a1.files = %w[lib/foo.rb Rakefile] assert_equal %w[lib/foo.rb], @a1.lib_files end def test_name assert_equal 'a', @a1.name end @@ -568,6 +675,12 @@ end assert_equal Gem::Platform.new('ppc-darwin'), @a1.platform end def test_require_paths @a1.require_path = 'lib' assert_equal %w[lib], @a1.require_paths @@ -646,7 +759,6 @@ Gem::Specification.new do |s| s.description = %q{This is a test description} s.email = %q{[email protected]} s.files = [\"lib/code.rb\"] - s.has_rdoc = true s.homepage = %q{http://example.com} s.require_paths = [\"lib\"] s.rubygems_version = %q{#{Gem::RubyGemsVersion}} @@ -698,8 +810,8 @@ Gem::Specification.new do |s| s.executables = [\"exec\"] s.extensions = [\"ext/a/extconf.rb\"] s.files = [\"lib/code.rb\", \"test/suite.rb\", \"bin/exec\", \"ext/a/extconf.rb\"] - s.has_rdoc = %q{true} s.homepage = %q{http://example.com} s.require_paths = [\"lib\"] s.requirements = [\"A working computer\"] s.rubyforge_project = %q{example} @@ -709,7 +821,7 @@ Gem::Specification.new do |s| if s.respond_to? :specification_version then current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 2 if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q<rake>, [\"> 0.4\"]) @@ -797,12 +909,16 @@ end end def test_validate Dir.chdir @tempdir do assert @a1.validate end end def test_validate_authors Dir.chdir @tempdir do @a1.authors = [] @@ -819,10 +935,28 @@ end end assert_equal 'authors must be Array of Strings', e.message end end def test_validate_autorequire Dir.chdir @tempdir do @a1.autorequire = 'code' @@ -835,7 +969,50 @@ end end end def test_validate_email Dir.chdir @tempdir do @a1.email = '' @@ -844,10 +1021,28 @@ end end assert_equal "WARNING: no email specified\n", @ui.error, 'error' end end def test_validate_empty e = assert_raises Gem::InvalidSpecificationException do Gem::Specification.new.validate end @@ -856,8 +1051,11 @@ end end def test_validate_executables FileUtils.mkdir_p File.join(@tempdir, 'bin') File.open File.join(@tempdir, 'bin', 'exec'), 'w' do end use_ui @ui do Dir.chdir @tempdir do @@ -865,45 +1063,94 @@ end end end assert_equal '', @ui.output, 'output' assert_equal "WARNING: bin/exec is missing #! line\n", @ui.error, 'error' end def test_validate_empty_require_paths - @a1.require_paths = [] - e = assert_raises Gem::InvalidSpecificationException do - @a1.validate end - assert_equal 'specification must have at least one require_path', e.message end def test_validate_homepage Dir.chdir @tempdir do - @a1.homepage = '' use_ui @ui do @a1.validate end assert_equal "WARNING: no homepage specified\n", @ui.error, 'error' - end - end - def test_validate_has_rdoc - Dir.chdir @tempdir do - @a1.has_rdoc = false use_ui @ui do @a1.validate end - assert_equal "WARNING: RDoc will not be generated (has_rdoc == false)\n", - @ui.error, 'error' end end def test_validate_platform_legacy Dir.chdir @tempdir do @a1.platform = 'mswin32' assert @a1.validate @@ -917,6 +1164,8 @@ end end def test_validate_rubyforge_project Dir.chdir @tempdir do @a1.rubyforge_project = '' @@ -930,6 +1179,8 @@ end end def test_validate_rubygems_version @a1.rubygems_version = "3" e = assert_raises Gem::InvalidSpecificationException do @a1.validate @@ -939,7 +1190,26 @@ end e.message end def test_validate_summary Dir.chdir @tempdir do @a1.summary = '' @@ -948,6 +1218,22 @@ end end assert_equal "WARNING: no summary specified\n", @ui.error, 'error' end end @@ -955,5 +1241,17 @@ end assert_equal Gem::Version.new('1'), @a1.version end end |