From 156629291e003da57c85fcdda4199da0fb07833a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 26 Apr 2019 17:09:06 +0200 Subject: [PATCH 1/8] Make spec easier to debug --- spec/runtime/setup_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 51de4eb38a0..3866bebb445 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -833,7 +833,9 @@ def clean_load_path(lp) 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__)}") + if tp.path.include?("bundler") && !tp.path.start_with?("#{File.expand_path("../..", __dir__)}") + puts "OMG. Defining a class from another bundler at \#{tp.path}:\#{tp.lineno}" + end end gem 'bundler', '#{Bundler::VERSION}' require 'bundler/setup' From 7ac854dea100036f68c9a6db063db73ff0328a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 26 Apr 2019 19:02:03 +0200 Subject: [PATCH 2/8] Remove redundant assertion --- spec/commands/exec_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 8167aee3ae7..3045f7229ef 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -453,7 +453,6 @@ it "works when unlocked" do bundle "exec 'cd #{tmp("gems")} && rackup'" expect(out).to eq("1.0.0") - expect(out).to include("1.0.0") end it "works when locked" do From c688337e24f24bc36b64f4cdb21a54e5e55eb27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 26 Apr 2019 19:02:19 +0200 Subject: [PATCH 3/8] More specific assertion 1.0.0 is such a common output, and it was hiding a crash in the test. --- spec/commands/exec_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 3045f7229ef..b9be5d7c023 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -40,7 +40,7 @@ bundle "exec 'cd #{tmp("gems")} && rackup'" - expect(out).to include("1.0.0") + expect(out).to eq("1.0.0") end it "works when exec'ing something else" do @@ -458,7 +458,7 @@ it "works when locked" do expect(the_bundle).to be_locked bundle "exec 'cd #{tmp("gems")} && rackup'" - expect(out).to include("1.0.0") + expect(out).to eq("1.0.0") end end From ca5e0bd3cfcaf0bb1e3f775a308a9927bde1c468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 3 Apr 2019 19:03:36 +0200 Subject: [PATCH 4/8] Cleanup constant only used once --- Rakefile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index ffd59872d07..170dec5e4ec 100644 --- a/Rakefile +++ b/Rakefile @@ -3,12 +3,6 @@ $:.unshift File.expand_path("../lib", __FILE__) require "benchmark" -RUBYGEMS_REPO = if `git -C "#{File.expand_path("..")}" remote --verbose 2> #{IO::NULL}` =~ /rubygems/i - File.expand_path("..") -else - File.expand_path("tmp/rubygems") -end - def development_dependencies @development_dependencies ||= Gem::Specification.load("bundler.gemspec").development_dependencies end @@ -139,7 +133,11 @@ namespace :spec do end task "setup_co" do - ENV["RGV"] = RUBYGEMS_REPO + ENV["RGV"] = if `git -C "#{File.expand_path("..")}" remote --verbose 2> #{IO::NULL}` =~ /rubygems/i + File.expand_path("..") + else + File.expand_path("tmp/rubygems") + end end task "co" => "setup_co" From 22de94d3b419cc6413758bd3decbf96381dbef9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 25 Sep 2018 15:36:56 -0300 Subject: [PATCH 5/8] Reuse `gemfile` spec helper --- spec/commands/config_spec.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb index a087eeb206f..c0ef3bb70c5 100644 --- a/spec/commands/config_spec.rb +++ b/spec/commands/config_spec.rb @@ -478,12 +478,10 @@ RSpec.describe "setting gemfile via config" do context "when only the non-default Gemfile exists" do it "persists the gemfile location to .bundle/config" do - File.open(bundled_app("NotGemfile"), "w") do |f| - f.write <<-G - source "#{file_uri_for(gem_repo1)}" - gem 'rack' - G - end + gemfile bundled_app("NotGemfile"), <<-G + source "#{file_uri_for(gem_repo1)}" + gem 'rack' + G bundle "config set --local gemfile #{bundled_app("NotGemfile")}" expect(File.exist?(".bundle/config")).to eq(true) From 102d6229d40d9608317cbd7c961417969bab8a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 24 May 2019 18:57:46 +0200 Subject: [PATCH 6/8] Remove unused filter --- spec/spec_helper.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 444f3a3cf3a..a90d8e98857 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -71,7 +71,6 @@ def self.ruby=(ruby) config.filter_run_excluding :ruby => RequirementChecker.against(RUBY_VERSION) config.filter_run_excluding :rubygems => RequirementChecker.against(Gem::VERSION) config.filter_run_excluding :git => RequirementChecker.against(git_version) - config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master") config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0]) config.filter_run_excluding :ruby_repo => !(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]).nil? config.filter_run_excluding :non_windows => Gem.win_platform? From e6a03f11029ea631077331697137e9680649d8b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 4 Jul 2019 22:14:19 +0200 Subject: [PATCH 7/8] Reuse `lockfile` spec helper --- spec/commands/clean_spec.rb | 4 +--- spec/install/gemfile/git_spec.rb | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index 17a533ef19e..2243a72b3d8 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -568,9 +568,7 @@ def should_not_have_gems(*gems) gemfile_lock.each_with_index do |line, index| gemfile_lock[index] = line[0..(11 + 7)] if line.include?(" revision:") end - File.open(bundled_app("Gemfile.lock"), "w") do |file| - file.print gemfile_lock.join("\n") - end + lockfile(bundled_app("Gemfile.lock"), gemfile_lock.join("\n")) bundle "install", forgotten_command_line_options(:path => "vendor/bundle") diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index fe51650f763..f2dcd33d7df 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -1003,10 +1003,8 @@ update_git "valim" new_revision = revision_for(lib_path("valim-1.0")) - lockfile = File.read(bundled_app("Gemfile.lock")) - File.open(bundled_app("Gemfile.lock"), "w") do |file| - file.puts lockfile.gsub(/revision: #{old_revision}/, "revision: #{new_revision}") - end + old_lockfile = File.read(bundled_app("Gemfile.lock")) + lockfile(bundled_app("Gemfile.lock"), old_lockfile.gsub(/revision: #{old_revision}/, "revision: #{new_revision}")) bundle "install" From 1bd96607802d9b78cc6a9443dc73bb336a82ba54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 27 Mar 2019 18:22:09 +0100 Subject: [PATCH 8/8] Fix typos --- spec/bundler/plugin/installer_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/bundler/plugin/installer_spec.rb b/spec/bundler/plugin/installer_spec.rb index 65f6b4ab6b8..c7e0d067462 100644 --- a/spec/bundler/plugin/installer_spec.rb +++ b/spec/bundler/plugin/installer_spec.rb @@ -66,7 +66,7 @@ expect(spec.full_name).to eq "ga-plugin-1.0" end - it "has expected full gem path" do + it "has expected full_gem_path" do rev = revision_for(lib_path("ga-plugin")) expect(result["ga-plugin"].full_gem_path). to eq(Bundler::Plugin.root.join("bundler", "gems", "ga-plugin-#{rev[0..11]}").to_s) @@ -89,7 +89,7 @@ expect(spec.full_name).to eq "ga-plugin-1.0" end - it "has expected full gem path" do + it "has expected full_gem_path" do rev = revision_for(lib_path("ga-plugin")) expect(result["ga-plugin"].full_gem_path). to eq(Bundler::Plugin.root.join("bundler", "gems", "ga-plugin-#{rev[0..11]}").to_s) @@ -105,7 +105,7 @@ expect(result["re-plugin"]).to be_kind_of(Bundler::RemoteSpecification) end - it "has expected full_gem)path" do + it "has expected full_gem_path" do expect(result["re-plugin"].full_gem_path). to eq(global_plugin_gem("re-plugin-1.0").to_s) end @@ -121,7 +121,7 @@ expect(result["ma-plugin"]).to be_kind_of(Bundler::RemoteSpecification) end - it "has expected full_gem)path" do + it "has expected full_gem_path" do expect(result["re-plugin"].full_gem_path).to eq(global_plugin_gem("re-plugin-1.0").to_s) expect(result["ma-plugin"].full_gem_path).to eq(global_plugin_gem("ma-plugin-1.0").to_s) end