From 8b7516438100ff379e92ebc2b524cb9c16f3392c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 28 Nov 2024 22:32:14 +0100 Subject: [PATCH] [rubygems/rubygems] Unify specs testing Bundler.setup failing behavior They had slightly different behavior in Bundler 2 and Bundler 3 because Bundler 3 will auto-clean after `bundle install`, so one of them system installed gems won't be present when `Bundler.setup` fails. We can unify the specs by moving installing system gems to _after_ `bundle install`, so the behavior in both cases is the same. Also, only this spec actually needs these gems installed, so we can move that from the `before` block to the body of the spec. https://github.com/rubygems/rubygems/commit/b7251ec9c6 --- spec/bundler/commands/exec_spec.rb | 35 +++--------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index d0898502a2..02e2188287 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -723,8 +723,6 @@ RSpec.describe "bundle exec" do RUBY before do - system_gems(%w[myrack-1.0.0 myrack-0.9.1], path: default_bundle_path) - bundled_app(path).open("w") {|f| f << executable } bundled_app(path).chmod(0o755) @@ -870,8 +868,10 @@ RSpec.describe "bundle exec" do end end - context "when Bundler.setup fails", bundler: "< 3" do + context "when Bundler.setup fails" do before do + system_gems(%w[myrack-1.0.0 myrack-0.9.1], path: default_bundle_path) + gemfile <<-G source "https://gem.repo1" gem 'myrack', '2' @@ -900,35 +900,6 @@ Run `bundle install` to install missing gems. end end - context "when Bundler.setup fails", bundler: "3" do - before do - gemfile <<-G - source "https://gem.repo1" - gem 'myrack', '2' - G - ENV["BUNDLER_FORCE_TTY"] = "true" - end - - let(:exit_code) { Bundler::GemNotFound.new.status_code } - let(:expected) { "" } - let(:expected_err) { <<-EOS.strip } -Could not find gem 'myrack (= 2)' in locally installed gems. - -The source contains the following gems matching 'myrack': - * myrack-1.0.0 -Run `bundle install` to install missing gems. - EOS - - it "runs" do - skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform? - - subject - expect(exitstatus).to eq(exit_code) - expect(err).to eq(expected_err) - expect(out).to eq(expected) - end - end - context "when Bundler.setup fails and Gemfile is not the default" do before do gemfile "CustomGemfile", <<-G