From 9d4f37f51fb2ffdef5e318afb3cb81516dcba4f7 Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 17 Jun 2008 22:04:18 +0000 Subject: Update RubyGems to 1.1.1 r1778 (almost 1.2) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rubygems/test_gem_specification.rb | 83 ++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 7 deletions(-) (limited to 'test/rubygems/test_gem_specification.rb') diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 20eb12479f..003ded7bc0 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -213,6 +213,15 @@ end assert_equal 'old_platform', same_spec.original_platform end + def test_add_dependency_with_explicit_type + gem = quick_gem "awesome", "1.0" do |awesome| + awesome.add_development_dependency "monkey" + end + + monkey = gem.dependencies.detect { |d| d.name == "monkey" } + assert_equal(:development, monkey.type) + end + def test_author assert_equal 'A User', @a1.author end @@ -282,6 +291,20 @@ end assert_equal [rake, jabber, pqa], @a1.dependencies end + def test_dependencies_scoped_by_type + gem = quick_gem "awesome", "1.0" do |awesome| + awesome.add_runtime_dependency "bonobo", [] + awesome.add_development_dependency "monkey", [] + end + + bonobo = Gem::Dependency.new("bonobo", []) + monkey = Gem::Dependency.new("monkey", [], :development) + + assert_equal([bonobo, monkey], gem.dependencies) + assert_equal([bonobo], gem.runtime_dependencies) + assert_equal([monkey], gem.development_dependencies) + end + def test_description assert_equal 'This is a test description', @a1.description end @@ -423,6 +446,15 @@ end @a1.full_gem_path end + def test_full_gem_path_double_slash + gemhome = @gemhome.sub(/\w\//, '\&/') + @a1.loaded_from = File.join gemhome, 'specifications', + "#{@a1.full_name}.gemspec" + + assert_equal File.join(@gemhome, 'gems', @a1.full_name), + @a1.full_gem_path + end + def test_full_name assert_equal 'a-1', @a1.full_name @@ -531,6 +563,17 @@ end assert_equal ['A working computer'], @a1.requirements end + def test_runtime_dependencies_legacy + # legacy gems don't have a type + @a1.runtime_dependencies.each do |dep| + dep.instance_variable_set :@type, nil + end + + expected = %w[rake jabber4r pqa] + + assert_equal expected, @a1.runtime_dependencies.map { |d| d.name } + end + def test_spaceship_name s1 = quick_gem 'a', '1' s2 = quick_gem 'b', '1' @@ -570,6 +613,8 @@ end end def test_to_ruby + @a2.add_runtime_dependency 'b', '1' + @a2.dependencies.first.instance_variable_set :@type, nil @a2.required_rubygems_version = Gem::Requirement.new '> 0' ruby_code = @a2.to_ruby @@ -578,8 +623,6 @@ end s.name = %q{a} s.version = \"2\" - s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION} if s.respond_to? :specification_version= - s.required_rubygems_version = Gem::Requirement.new(\"> 0\") if s.respond_to? :required_rubygems_version= s.authors = [\"A User\"] s.date = %q{#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}} @@ -591,6 +634,19 @@ end s.require_paths = [\"lib\"] s.rubygems_version = %q{#{Gem::RubyGemsVersion}} s.summary = %q{this is a summary} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION} + + if current_version >= 3 then + s.add_runtime_dependency(%q, [\"= 1\"]) + else + s.add_dependency(%q, [\"= 1\"]) + end + else + s.add_dependency(%q, [\"= 1\"]) + end end " @@ -613,8 +669,6 @@ end s.version = \"1\" s.platform = Gem::Platform.new(#{expected_platform}) - s.specification_version = 2 if s.respond_to? :specification_version= - s.required_rubygems_version = Gem::Requirement.new(\">= 0\") if s.respond_to? :required_rubygems_version= s.authors = [\"A User\"] s.date = %q{#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}} @@ -633,9 +687,24 @@ end s.summary = %q{this is a summary} s.test_files = [\"test/suite.rb\"] - s.add_dependency(%q, [\"> 0.4\"]) - s.add_dependency(%q, [\"> 0.0.0\"]) - s.add_dependency(%q, [\"> 0.4\", \"<= 0.6\"]) + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if current_version >= 3 then + s.add_runtime_dependency(%q, [\"> 0.4\"]) + s.add_runtime_dependency(%q, [\"> 0.0.0\"]) + s.add_runtime_dependency(%q, [\"> 0.4\", \"<= 0.6\"]) + else + s.add_dependency(%q, [\"> 0.4\"]) + s.add_dependency(%q, [\"> 0.0.0\"]) + s.add_dependency(%q, [\"> 0.4\", \"<= 0.6\"]) + end + else + s.add_dependency(%q, [\"> 0.4\"]) + s.add_dependency(%q, [\"> 0.0.0\"]) + s.add_dependency(%q, [\"> 0.4\", \"<= 0.6\"]) + end end " -- cgit v1.2.3