From e95adbfa68f583c4a67fdc4b0ba4eca85fa44b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 3 Jul 2025 08:53:56 +0200 Subject: [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 --- spec/bundler/install/gems/standalone_spec.rb | 35 +++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb index e0f87572da..8073559479 100644 --- a/spec/bundler/install/gems/standalone_spec.rb +++ b/spec/bundler/install/gems/standalone_spec.rb @@ -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 -- cgit v1.2.3