diff options
Diffstat (limited to 'test/rubygems/test_gem_stub_specification.rb')
-rw-r--r-- | test/rubygems/test_gem_stub_specification.rb | 83 |
1 files changed, 34 insertions, 49 deletions
diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb index e008391ef7..fe30a78c0b 100644 --- a/test/rubygems/test_gem_stub_specification.rb +++ b/test/rubygems/test_gem_stub_specification.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative "helper" require "rubygems/stub_specification" @@ -10,7 +11,7 @@ class TestStubSpecification < Gem::TestCase super @base_dir = __dir__ - @gems_dir = File.join __dir__, 'gem' + @gems_dir = File.join __dir__, "gem" @foo = Gem::StubSpecification.gemspec_stub FOO, @base_dir, @gems_dir end @@ -25,24 +26,24 @@ class TestStubSpecification < Gem::TestCase def test_initialize_extension stub = stub_with_extension - assert_equal 'stub_e', stub.name + 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 [stub.extension_dir, "lib"], stub.require_paths assert_equal %w[ext/stub_e/extconf.rb], stub.extensions end def test_initialize_version stub = stub_with_version - assert_equal 'stub_v', stub.name + assert_equal "stub_v", stub.name assert_equal v(2), stub.version end def test_initialize_with_empty_version stub = stub_without_version - assert_equal 'stub_v', stub.name + assert_equal "stub_v", stub.name assert_equal v(0), stub.version end @@ -57,21 +58,21 @@ class TestStubSpecification < Gem::TestCase def test_contains_requirable_file_eh stub = stub_without_extension - code_rb = File.join stub.gem_dir, 'lib', 'code.rb' + 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' + assert stub.contains_requirable_file? "code" end def test_contains_requirable_file_eh_extension pend "I guess making the stub match the running platform should work" if Gem.java_platform? stub_with_extension do |stub| _, err = capture_output do - refute stub.contains_requirable_file? 'nonexistent' + refute stub.contains_requirable_file? "nonexistent" end - expected = "Ignoring stub_e-2 because its extensions are not built. " + + expected = "Ignoring stub_e-2 because its extensions are not built. " \ "Try: gem pristine stub_e --version 2\n" assert_equal expected, err @@ -82,7 +83,7 @@ class TestStubSpecification < Gem::TestCase stub = stub_with_extension expected = [ - File.join(stub.full_gem_path, 'lib'), + File.join(stub.full_gem_path, "lib"), stub.extension_dir, ] @@ -92,32 +93,32 @@ class TestStubSpecification < Gem::TestCase def test_lib_dirs_glob stub = stub_without_extension - assert_equal File.join(stub.full_gem_path, 'lib'), stub.lib_dirs_glob + assert_equal File.join(stub.full_gem_path, "lib"), stub.lib_dirs_glob end def test_lib_dirs_glob_with_extension stub = stub_with_extension - assert_equal File.join(stub.full_gem_path, 'lib'), stub.lib_dirs_glob + assert_equal File.join(stub.full_gem_path, "lib"), stub.lib_dirs_glob end def test_matches_for_glob stub = stub_without_extension - code_rb = File.join stub.gem_dir, 'lib', 'code.rb' + code_rb = File.join stub.gem_dir, "lib", "code.rb" FileUtils.mkdir_p File.dirname code_rb FileUtils.touch code_rb - assert_equal code_rb, stub.matches_for_glob('code*').first + assert_equal code_rb, stub.matches_for_glob("code*").first end def test_matches_for_glob_with_bundler_inline stub = stub_with_extension - code_rb = File.join stub.gem_dir, 'lib', 'code.rb' + code_rb = File.join stub.gem_dir, "lib", "code.rb" FileUtils.mkdir_p File.dirname code_rb FileUtils.touch code_rb stub.stub(:raw_require_paths, nil) do - assert_equal code_rb, stub.matches_for_glob('code*').first + assert_equal code_rb, stub.matches_for_glob("code*").first end end @@ -127,7 +128,7 @@ class TestStubSpecification < Gem::TestCase extconf_rb = File.join s.gem_dir, s.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - File.open extconf_rb, 'w' do |f| + File.open extconf_rb, "w" do |f| f.write <<-'RUBY' File.open 'Makefile', 'w' do |f| f.puts "clean:\n\techo clean" @@ -146,10 +147,10 @@ class TestStubSpecification < Gem::TestCase end def test_missing_extensions_eh_default_gem - spec = new_default_spec 'default', 1 - spec.extensions << 'extconf.rb' + spec = new_default_spec "default", 1 + spec.extensions << "extconf.rb" - File.open spec.loaded_from, 'w' do |io| + File.open spec.loaded_from, "w" do |io| io.write spec.to_ruby_for_cache end @@ -167,7 +168,7 @@ class TestStubSpecification < Gem::TestCase real_foo.activate assert_equal @foo.version, Gem.loaded_specs[@foo.name].version, - 'sanity check' + "sanity check" assert_same real_foo, @foo.to_spec end @@ -180,25 +181,9 @@ class TestStubSpecification < Gem::TestCase assert bar.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_get :@ignored - end - - def test_to_spec_missing_extensions - stub = stub_with_extension - - capture_output do - stub.contains_requirable_file? 'nonexistent' - end - - assert stub.to_spec.instance_variable_get :@ignored - end - def stub_with_version - spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec' - File.open spec, 'w' do |io| + spec = File.join @gemhome, "specifications", "stub_e-2.gemspec" + File.open spec, "w" do |io| io.write <<-STUB # -*- encoding: utf-8 -*- # stub: stub_v 2 ruby lib @@ -211,7 +196,7 @@ end io.flush - stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems') + stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, "gems") yield stub if block_given? @@ -220,8 +205,8 @@ end end def stub_without_version - spec = File.join @gemhome, 'specifications', 'stub-2.gemspec' - File.open spec, 'w' do |io| + spec = File.join @gemhome, "specifications", "stub-2.gemspec" + File.open spec, "w" do |io| io.write <<-STUB # -*- encoding: utf-8 -*- # stub: stub_v ruby lib @@ -234,7 +219,7 @@ end io.flush - stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems') + stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, "gems") yield stub if block_given? @@ -243,8 +228,8 @@ end end def stub_with_extension - spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec' - File.open spec, 'w' do |io| + spec = File.join @gemhome, "specifications", "stub_e-2.gemspec" + File.open spec, "w" do |io| io.write <<-STUB # -*- encoding: utf-8 -*- # stub: stub_e 2 ruby lib @@ -260,7 +245,7 @@ end io.flush - stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems') + stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, "gems") yield stub if block_given? @@ -269,8 +254,8 @@ end end def stub_without_extension - spec = File.join @gemhome, 'specifications', 'stub-2.gemspec' - File.open spec, 'w' do |io| + spec = File.join @gemhome, "specifications", "stub-2.gemspec" + File.open spec, "w" do |io| io.write <<-STUB # -*- encoding: utf-8 -*- # stub: stub 2 ruby lib @@ -283,7 +268,7 @@ end io.flush - stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems') + stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, "gems") yield stub if block_given? |