[rubygems/rubygems] Remove unnecessary nesting from standalone specs

Originally, all the specs in this file were put inside a shared examples
block, and since then all specs were run only changing the cwd (either
from root, or a subdirectory).

This was in https://github.com/rubygems/rubygems/commit/d7291700d016, to cover a fix in
the `bundler_path` method.

However, reverting that fix does not make any of the specs in either of
the main blocks fail! Only an unrelated spec of `bundle install
--standalone --local` fails.

The reason is that all specs set `path` to an absolute path, making the
fix essentially uncovered.

In order to simplify the file structure and improve runtime, I
completely removed the shared examples block, and only run main specs
for the root directory. Then I added a couple of extra specs to cover
the original bug fix.

This cuts runtime of this spec file in half, from 1m30s to 45s on my
laptop.

https://github.com/rubygems/rubygems/commit/cc506f17e0
This commit is contained in:
David Rodríguez 2025-07-03 08:53:56 +02:00 committed by Hiroshi SHIBATA
parent 9918ca1671
commit e95adbfa68

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
RSpec.shared_examples "bundle install --standalone" do
RSpec.describe "bundle install --standalone" do
shared_examples "common functionality" do
it "still makes the gems available to normal bundler" do
args = expected_gems.map {|k, v| "#{k} #{v}" }
@ -237,6 +237,8 @@ RSpec.shared_examples "bundle install --standalone" do
end
end
let(:cwd) { bundled_app }
describe "with Gemfiles using relative path sources and app moved to a different root" do
before do
FileUtils.mkdir_p bundled_app("app/vendor")
@ -511,16 +513,33 @@ RSpec.shared_examples "bundle install --standalone" do
end
end
RSpec.describe "bundle install --standalone" do
let(:cwd) { bundled_app }
include_examples("bundle install --standalone")
end
RSpec.describe "bundle install --standalone run in a subdirectory" do
let(:cwd) { bundled_app("bob").tap(&:mkpath) }
include_examples("bundle install --standalone")
before do
gemfile <<-G
source "https://gem.repo1"
gem "rails"
G
end
it "generates the script in the proper place" do
bundle :install, standalone: true, dir: cwd
expect(bundled_app("bundle/bundler/setup.rb")).to exist
end
context "when path set to a relative path" do
before do
bundle "config set --local path bundle"
end
it "generates the script in the proper place" do
bundle :install, standalone: true, dir: cwd
expect(bundled_app("bundle/bundler/setup.rb")).to exist
end
end
end
RSpec.describe "bundle install --standalone --local" do