From b933b8efc84aa2e79b4f43417d6480661f781726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 11 Feb 2019 14:51:40 +0100 Subject: Remove unused variable --- spec/runtime/setup_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 2816410a7e..740e803dc2 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -804,7 +804,6 @@ end let(:gem_home) { Dir.mktmpdir } let(:symlinked_gem_home) { Tempfile.new("gem_home").path } let(:bundler_dir) { ruby_core? ? File.expand_path("../../../..", __FILE__) : File.expand_path("../../..", __FILE__) } - let(:bundler_lib) { File.join(bundler_dir, "lib") } before do FileUtils.ln_sf(gem_home, symlinked_gem_home) -- cgit v1.2.1 From f70c9c80c1e242d893b94e62ff919e08263d507c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 3 Apr 2019 22:10:18 +0200 Subject: Fix missing tmpdir require When running `bin/rspec spec/runtime/setup_spec.rb -e symlink`, you'll get an "undefined method `mktmpdir' for Dir:Class" error. This commit fixes that. --- spec/runtime/setup_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 740e803dc2..7d178cdcc1 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "tmpdir" + RSpec.describe "Bundler.setup" do describe "with no arguments" do it "makes all groups available" do -- cgit v1.2.1 From 5fd31c066541d80f31d8f59e6692381c1538aa79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 3 Apr 2019 22:11:37 +0200 Subject: Fix missing tempfile require When running `bin/rspec spec/runtime/setup_spec.rb -e symlink`, you'll get an "uninitialized constant `Tempfile`" error. This commit fixes that. --- spec/runtime/setup_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 7d178cdcc1..448ee7f03a 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "tmpdir" +require "tempfile" RSpec.describe "Bundler.setup" do describe "with no arguments" do -- cgit v1.2.1 From fb4f0a81768e6dfb5c2112f9d6f1d8e0b3096c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 4 Apr 2019 10:54:20 +0200 Subject: Fix incorrect specification name in spec --- spec/runtime/setup_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 448ee7f03a..aa24c3a736 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -807,6 +807,7 @@ end let(:gem_home) { Dir.mktmpdir } let(:symlinked_gem_home) { Tempfile.new("gem_home").path } let(:bundler_dir) { ruby_core? ? File.expand_path("../../../..", __FILE__) : File.expand_path("../../..", __FILE__) } + let(:full_name) { "bundler-#{Bundler::VERSION}" } before do FileUtils.ln_sf(gem_home, symlinked_gem_home) @@ -815,14 +816,14 @@ end Dir.mkdir(gems_dir) Dir.mkdir(specifications_dir) - FileUtils.ln_s(bundler_dir, File.join(gems_dir, "bundler-#{Bundler::VERSION}")) + FileUtils.ln_s(bundler_dir, File.join(gems_dir, full_name)) gemspec_file = ruby_core? ? "#{bundler_dir}/lib/bundler/bundler.gemspec" : "#{bundler_dir}/bundler.gemspec" gemspec = File.read(gemspec_file). sub("Bundler::VERSION", %("#{Bundler::VERSION}")) gemspec = gemspec.lines.reject {|line| line =~ %r{lib/bundler/version} }.join - File.open(File.join(specifications_dir, "bundler.gemspec"), "wb") do |f| + File.open(File.join(specifications_dir, "#{full_name}.gemspec"), "wb") do |f| f.write(gemspec) end end -- cgit v1.2.1 From 8805d984636dbcf7d33969744e68a5aba729898e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 3 Apr 2019 22:12:48 +0200 Subject: Read gemspec binarily When running `bin/rspec spec/runtime/setup_spec.rb -e symlink`, I get an "invalid byte sequence in US-ASCII" error. This commit fixes that. --- spec/runtime/setup_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index aa24c3a736..d1cc970ddf 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -819,7 +819,7 @@ end FileUtils.ln_s(bundler_dir, File.join(gems_dir, full_name)) gemspec_file = ruby_core? ? "#{bundler_dir}/lib/bundler/bundler.gemspec" : "#{bundler_dir}/bundler.gemspec" - gemspec = File.read(gemspec_file). + gemspec = File.binread(gemspec_file). sub("Bundler::VERSION", %("#{Bundler::VERSION}")) gemspec = gemspec.lines.reject {|line| line =~ %r{lib/bundler/version} }.join -- cgit v1.2.1 From 7ca4e5bb4e80a0ed1845b7f609279003898345ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 4 Apr 2019 12:14:06 +0200 Subject: Fix symlink spec on ruby 2.6 In rubies where there's no default bundler gem, the original test requiring that `bundler/setup` doesn't fail to load was correct. But in rubies where there's a default bundler gem the bug would manifest in a different way, by loading the incorrect default copy of bundler. So we instead check that the copy of bundler that we load is the (expected) symlinked one. --- spec/runtime/setup_spec.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index d1cc970ddf..ac8170d2e1 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -828,20 +828,18 @@ end end end - # Can't make this pass on 2.6 since the ruby standard library has the same $LOAD_PATH - # entry as bundler (since it's a default gem) - it "should successfully require 'bundler/setup'", :ruby_repo, :ruby => "< 2.6" do + it "should not remove itself from the LOAD_PATH and require a different copy of 'bundler/setup'", :ruby_repo do install_gemfile "" - ruby <<-'R', :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true - # Remove any bundler that's not the current bundler from $LOAD_PATH - $LOAD_PATH.each do |path| - $LOAD_PATH.delete(path) if File.exist?("#{path}/bundler.rb") + ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true + TracePoint.trace(:class) do |tp| + puts "OMG" if tp.path.include?("bundler") && !tp.path.start_with?("#{File.expand_path("../..", __dir__)}") end - puts (require 'bundler/setup') + gem 'bundler', '#{Bundler::VERSION}' + require 'bundler/setup' R - expect(out).to eql("true") + expect(out).to be_empty end end -- cgit v1.2.1