[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
This commit is contained in:
David Rodríguez 2024-11-28 22:32:14 +01:00 committed by git
parent ee7ff4a12b
commit 8b75164381

View File

@ -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