diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-16 00:14:16 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-16 00:14:16 +0000 |
commit | 28918eac58eb6e2681d10839ac0d1430b2a4f1f9 (patch) | |
tree | 3c2c9e36118efe1d9406acdd14c186788879bea3 /test/rubygems/test_gem_stub_specification.rb | |
parent | cfe1458078b8cf36e490c516977c52e1faa9e88a (diff) | |
download | ruby-28918eac58eb6e2681d10839ac0d1430b2a4f1f9.tar.gz |
* lib/rubygems: Update to RubyGems master commit 2a74263. This fixes
several bugs in RubyGems 2.2.0.preview.1.
* test/rubygems: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_stub_specification.rb')
-rw-r--r-- | test/rubygems/test_gem_stub_specification.rb | 133 |
1 files changed, 123 insertions, 10 deletions
diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb index 6feb96eb4f..e315e2c01a 100644 --- a/test/rubygems/test_gem_stub_specification.rb +++ b/test/rubygems/test_gem_stub_specification.rb @@ -6,15 +6,38 @@ class TestStubSpecification < Gem::TestCase FOO = File.join SPECIFICATIONS, "foo-0.0.1.gemspec" BAR = File.join SPECIFICATIONS, "bar-0.0.2.gemspec" - def test_basic - stub = Gem::StubSpecification.new(FOO) - assert_equal "foo", stub.name - assert_equal Gem::Version.new("0.0.1"), stub.version - assert_equal Gem::Platform.new("mswin32"), stub.platform - assert_equal ["lib", "lib/f oo/ext"], stub.require_paths + def setup + super + + @foo = Gem::StubSpecification.new FOO + end + + def test_initialize + assert_equal "foo", @foo.name + assert_equal Gem::Version.new("0.0.1"), @foo.version + assert_equal Gem::Platform.new("mswin32"), @foo.platform + assert_equal ["lib", "lib/f oo/ext"], @foo.require_paths + end + + def test_initialize_extension + stub = stub_with_extension + + gem_dir = File.join stub.gems_dir, stub.full_name + + lib = Pathname File.join gem_dir, 'lib' + + ext_install_dir = + Pathname(stub.extension_install_dir).relative_path_from lib + ext_install_dir = ext_install_dir.to_s + + assert_equal 'stub_e', stub.name + assert_equal v(2), stub.version + assert_equal Gem::Platform::RUBY, stub.platform + assert_equal ['lib', ext_install_dir], stub.require_paths + assert_equal %w[ext/stub_e/extconf.rb], stub.extensions end - def test_missing_stubline + def test_initialize_missing_stubline stub = Gem::StubSpecification.new(BAR) assert_equal "bar", stub.name assert_equal Gem::Version.new("0.0.2"), stub.version @@ -22,9 +45,99 @@ class TestStubSpecification < Gem::TestCase assert_equal ["lib"], stub.require_paths end + def test_contains_requirable_file_eh + stub = stub_without_extension + code_rb = File.join stub.gem_dir, 'lib', 'code.rb' + FileUtils.mkdir_p File.dirname code_rb + FileUtils.touch code_rb + + assert stub.contains_requirable_file? 'code' + end + + def test_contains_requirable_file_eh_extension + stub_with_extension do |stub| + extconf_rb = File.join stub.gem_dir, stub.extensions.first + FileUtils.mkdir_p File.dirname extconf_rb + + open extconf_rb, 'w' do |f| + f.write <<-'RUBY' + open 'Makefile', 'w' do |f| + f.puts "clean:\n\techo cleaned" + f.puts "default:\n\techo built" + f.puts "install:\n\techo installed" + end + RUBY + end + + refute stub.contains_requirable_file? 'nonexistent' + + assert_path_exists stub.extension_install_dir + end + end + + def test_full_require_paths + stub = stub_with_extension + + expected = [ + File.join(stub.full_gem_path, 'lib'), + stub.extension_install_dir, + ] + + assert_equal expected, stub.full_require_paths + end + def test_to_spec - stub = Gem::StubSpecification.new(FOO) - assert stub.to_spec.is_a?(Gem::Specification) - assert_equal "foo", stub.to_spec.name + assert @foo.to_spec.is_a?(Gem::Specification) + assert_equal "foo", @foo.to_spec.name end + + def stub_with_extension + spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec' + open spec, 'w' do |io| + io.write <<-STUB +# -*- encoding: utf-8 -*- +# stub: stub_e 2 ruby lib +# stub: ext/stub_e/extconf.rb + +Gem::Specification.new do |s| + s.name = 'stub_e' + s.version = Gem::Version.new '2' + s.extensions = ['ext/stub_e/extconf.rb'] end + STUB + + io.flush + + stub = Gem::StubSpecification.new io.path + + yield stub if block_given? + + return stub + end + end + + def stub_without_extension + spec = File.join @gemhome, 'specifications', 'stub-2.gemspec' + open spec, 'w' do |io| + io.write <<-STUB +# -*- encoding: utf-8 -*- +# stub: stub 2 ruby lib + +Gem::Specification.new do |s| + s.name = 'stub' + s.version = Gem::Version.new '2' +end + STUB + + io.flush + + stub = Gem::StubSpecification.new io.path + + yield stub if block_given? + + return stub + end + end + +end + |