From c65a44d3569d916a3e2691e8524736767aee2504 Mon Sep 17 00:00:00 2001 From: "Samuel E. Giddins" Date: Sun, 22 Mar 2015 00:56:32 -0700 Subject: [Setup] Fix multiple non-additive invocations of Bundler.setup with different groups --- lib/bundler.rb | 7 +------ spec/runtime/setup_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/bundler.rb b/lib/bundler.rb index 83c066e5e5..478afd9bf4 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -120,12 +120,7 @@ module Bundler # Load all groups, but only once @setup = load.setup else - @completed_groups ||= [] - # Figure out which groups haven't been loaded yet - unloaded = groups - @completed_groups - # Record groups that are now loaded - @completed_groups = groups - unloaded.any? ? load.setup(*groups) : load + load.setup(*groups) end end diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 02ce0de369..2834689db1 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -90,6 +90,21 @@ describe "Bundler.setup" do expect(err).to eq("") expect(out).to match("WIN") end + + it "handles multiple non-additive invocations" do + ruby <<-RUBY + require 'bundler' + Bundler.setup(:default, :test) + Bundler.setup(:default) + require 'rack' + + puts "FAIL" + RUBY + + expect(err).to match("rack") + expect(err).to match("LoadError") + expect(out).not_to match("FAIL") + end end it "raises if the Gemfile was not yet installed" do -- cgit v1.2.1