Skip to content

Commit e95adbf

Browse files
deivid-rodriguezhsbt
authored andcommitted
[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 ruby/rubygems@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. ruby/rubygems@cc506f17e0
1 parent 9918ca1 commit e95adbf

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

spec/bundler/install/gems/standalone_spec.rb

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
RSpec.shared_examples "bundle install --standalone" do
3+
RSpec.describe "bundle install --standalone" do
44
shared_examples "common functionality" do
55
it "still makes the gems available to normal bundler" do
66
args = expected_gems.map {|k, v| "#{k} #{v}" }
@@ -237,6 +237,8 @@
237237
end
238238
end
239239

240+
let(:cwd) { bundled_app }
241+
240242
describe "with Gemfiles using relative path sources and app moved to a different root" do
241243
before do
242244
FileUtils.mkdir_p bundled_app("app/vendor")
@@ -511,16 +513,33 @@
511513
end
512514
end
513515

514-
RSpec.describe "bundle install --standalone" do
515-
let(:cwd) { bundled_app }
516-
517-
include_examples("bundle install --standalone")
518-
end
519-
520516
RSpec.describe "bundle install --standalone run in a subdirectory" do
521517
let(:cwd) { bundled_app("bob").tap(&:mkpath) }
522518

523-
include_examples("bundle install --standalone")
519+
before do
520+
gemfile <<-G
521+
source "https://gem.repo1"
522+
gem "rails"
523+
G
524+
end
525+
526+
it "generates the script in the proper place" do
527+
bundle :install, standalone: true, dir: cwd
528+
529+
expect(bundled_app("bundle/bundler/setup.rb")).to exist
530+
end
531+
532+
context "when path set to a relative path" do
533+
before do
534+
bundle "config set --local path bundle"
535+
end
536+
537+
it "generates the script in the proper place" do
538+
bundle :install, standalone: true, dir: cwd
539+
540+
expect(bundled_app("bundle/bundler/setup.rb")).to exist
541+
end
542+
end
524543
end
525544

526545
RSpec.describe "bundle install --standalone --local" do

0 commit comments

Comments
 (0)