Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tests and fix for Bundler.require removing gems from

  • Loading branch information...
commit 5ff5cbc15d734e235f7129cdca72d9050eb5e520 1 parent 9bed2b6
@indirect indirect authored
Showing with 65 additions and 3 deletions.
  1. +4 −1 lib/bundler.rb
  2. +61 −2 spec/runtime/setup_spec.rb
View
5 lib/bundler.rb
@@ -93,9 +93,12 @@ def bin_path
end
def setup(*groups)
+ # Just return if all groups are already loaded
+ return @setup if defined?(@setup)
+
if groups.empty?
# Load all groups, but only once
- @setup ||= load.setup
+ @setup = load.setup
else
@completed_groups ||= []
# Figure out which groups haven't been loaded yet
View
63 spec/runtime/setup_spec.rb
@@ -1,6 +1,65 @@
require "spec_helper"
describe "Bundler.setup" do
+ describe "with no arguments" do
+ it "makes all groups available" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", :group => :test
+ G
+
+ ruby <<-RUBY
+ require 'rubygems'
+ require 'bundler'
+ Bundler.setup
+
+ require 'rack'
+ puts RACK
+ RUBY
+ err.should == ""
+ out.should == "1.0.0"
+ end
+ end
+
+ describe "when called with groups" do
+ before(:each) do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", :group => :test
+ G
+ end
+
+ it "doesn't make all groups available" do
+ ruby <<-RUBY
+ require 'rubygems'
+ require 'bundler'
+ Bundler.setup(:default)
+
+ begin
+ require 'rack'
+ rescue LoadError
+ puts "WIN"
+ end
+ RUBY
+ err.should == ""
+ out.should == "WIN"
+ end
+
+ it "leaves all groups available if they were already" do
+ ruby <<-RUBY
+ require 'rubygems'
+ require 'bundler'
+ Bundler.setup
+ Bundler.setup(:default)
+
+ require 'rack'
+ puts RACK
+ RUBY
+ err.should == ""
+ out.should == "1.0.0"
+ end
+ end
+
it "raises if the Gemfile was not yet installed" do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -611,8 +670,8 @@ def Bundler.require(path)
Bundler.load
RUBY
- err.should be_empty
- out.should be_empty
+ err.should == ""
+ out.should == ""
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.