aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_stub_specification.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-14 03:30:02 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-14 03:30:02 +0000
commit4de117a61517e839f2c45eaf45d56fc243d6d5b2 (patch)
tree7cb5af7a7eb513e5dddf5e343746b1611e628387 /test/rubygems/test_gem_stub_specification.rb
parente548c09d429a5136285ea81aed418685359ed124 (diff)
downloadruby-4de117a61517e839f2c45eaf45d56fc243d6d5b2.tar.gz
* lib/rubygems: Update to RubyGems 2.4.1 master(713ab65)
Complete history at: https://github.com/rubygems/rubygems/blob/master/History.txt#L3-L216 * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_stub_specification.rb')
-rw-r--r--test/rubygems/test_gem_stub_specification.rb94
1 files changed, 71 insertions, 23 deletions
diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb
index c4c07597f5..d992567a5c 100644
--- a/test/rubygems/test_gem_stub_specification.rb
+++ b/test/rubygems/test_gem_stub_specification.rb
@@ -23,16 +23,11 @@ class TestStubSpecification < Gem::TestCase
def test_initialize_extension
stub = stub_with_extension
- ext_install_dir = Pathname(stub.extension_dir)
- full_gem_path = Pathname(stub.full_gem_path)
- relative_install_dir = ext_install_dir.relative_path_from full_gem_path
- relative_install_dir = relative_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 [relative_install_dir, 'lib'], stub.require_paths
- assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
+ assert_equal 'stub_e', stub.name
+ assert_equal v(2), stub.version
+ assert_equal Gem::Platform::RUBY, stub.platform
+ assert_equal [stub.extension_dir, 'lib'], stub.require_paths
+ assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
end
def test_initialize_missing_stubline
@@ -55,22 +50,14 @@ class TestStubSpecification < Gem::TestCase
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
+ _, err = capture_io do
+ refute stub.contains_requirable_file? 'nonexistent'
end
- refute stub.contains_requirable_file? 'nonexistent'
+ expected = "Ignoring stub_e-2 because its extensions are not built. " +
+ "Try: gem pristine stub_e-2\n"
- assert_path_exists stub.extension_dir
+ assert_equal expected, err
end
end
@@ -85,9 +72,70 @@ class TestStubSpecification < Gem::TestCase
assert_equal expected, stub.full_require_paths
end
+ def test_missing_extensions_eh
+ stub = stub_with_extension do |s|
+ extconf_rb = File.join s.gem_dir, s.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 clean"
+ f.puts "default:\n\techo built"
+ f.puts "install:\n\techo installed"
+ end
+ RUBY
+ end
+ end
+
+ assert stub.missing_extensions?
+
+ stub.build_extensions
+
+ refute stub.missing_extensions?
+ end
+
+ def test_missing_extensions_eh_default_gem
+ spec = new_default_spec 'default', 1
+ spec.extensions << 'extconf.rb'
+
+ open spec.loaded_from, 'w' do |io|
+ io.write spec.to_ruby_for_cache
+ end
+
+ default_spec = Gem::StubSpecification.new spec.loaded_from
+
+ refute default_spec.missing_extensions?
+ end
+
+ def test_missing_extensions_eh_none
+ refute @foo.missing_extensions?
+ end
+
def test_to_spec
+ real_foo = util_spec @foo.name, @foo.version
+ real_foo.activate
+
+ assert_equal @foo.version, Gem.loaded_specs[@foo.name].version,
+ 'sanity check'
+
+ assert_same real_foo, @foo.to_spec
+ end
+
+ def test_to_spec_activated
assert @foo.to_spec.is_a?(Gem::Specification)
assert_equal "foo", @foo.to_spec.name
+ refute @foo.to_spec.instance_variable_defined? :@ignored
+ end
+
+ def test_to_spec_missing_extensions
+ stub = stub_with_extension
+
+ capture_io do
+ stub.contains_requirable_file? 'nonexistent'
+ end
+
+ assert stub.to_spec.instance_variable_get :@ignored
end
def stub_with_extension