summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2021-10-28 09:51:14 +0200
committergit <svn-admin@ruby-lang.org>2021-11-01 02:01:36 +0900
commit4e7e057692578204a6fb2f7170bb8c5803f0f9e0 (patch)
tree1b49f1ec166c22c22f06c5b4fb599c1a4267966e /spec
parent13a9597c7ca83fced5738e9345660ae6aef87eb7 (diff)
[rubygems/rubygems] Memoize materialized specs when requiring `bundler/setup`
Calling `Bundler.definition.specs` will memoize materialized specs. However, requiring `bundler/setup` will end up materializing the same set of specs, but not memoize them. This change makes things consistent. https://github.com/rubygems/rubygems/commit/e4c2b52824
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/runtime/setup_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb
index b35b7a233c..3cf373fe1c 100644
--- a/spec/bundler/runtime/setup_spec.rb
+++ b/spec/bundler/runtime/setup_spec.rb
@@ -1468,5 +1468,21 @@ end
expect(last_command.stdboth).to eq("true")
end
+
+ it "memoizes initial set of specs when requiring bundler/setup, so that even if further code mutates dependencies, Bundler.definition.specs is not affected" do
+ install_gemfile <<~G
+ source "#{file_uri_for(gem_repo1)}"
+ gem "yard"
+ gem "rack", :group => :test
+ G
+
+ ruby <<-RUBY, :raise_on_error => false
+ require "bundler/setup"
+ Bundler.require(:test).select! {|d| (d.groups & [:test]).any? }
+ puts Bundler.definition.specs.map(&:name).join(", ")
+ RUBY
+
+ expect(out).to include("rack, yard")
+ end
end
end