Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Don't call #setup after loading env.rb in Bundler.load
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Apr 10, 2010
1 parent 4f58bc6 commit 2c8d6ae
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
8 changes: 5 additions & 3 deletions lib/bundler.rb
Expand Up @@ -66,9 +66,11 @@ def bundle_path
end

def setup(*groups)
if groups.empty? || @all_groups_loaded
return @setup if @setup

if groups.empty?
# Load all groups, but only once
@all_groups_loaded ||= load.setup
@setup = load.setup
else
# Figure out which groups haven't been loaded yet
unloaded = groups - (@completed_groups || [])
Expand All @@ -86,7 +88,7 @@ def require(*groups)
def load
@load ||= begin
if current_env_file?
SharedHelpers.gem_loaded = true
@gem_loaded = true
Kernel.require env_file
Bundler
else
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/templates/environment.erb
Expand Up @@ -74,5 +74,5 @@ module Bundler
end

# Set up load paths unless this file is being loaded after the Bundler gem
setup unless gem_loaded
setup unless @gem_loaded
end
39 changes: 34 additions & 5 deletions spec/runtime/load_spec.rb
@@ -1,7 +1,6 @@
require File.expand_path('../../spec_helper', __FILE__)

describe "Bundler.load" do

before :each do
system_gems "rack-1.0.0"
# clear memoized method results
Expand Down Expand Up @@ -68,14 +67,43 @@
end
end

describe "not hurting brittle rubygems" do
describe "when locked" do
before :each do
system_gems "activerecord-2.3.2", "activesupport-2.3.2"
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
bundle :lock
end

it "loads env.rb instead of the runtime" do
ruby <<-R
require 'bundler'
Bundler.load
puts Bundler.instance_eval{ @runtime }
R
out.should == "nil"
end

it "does not invoke setup inside env.rb" do
ruby <<-R, :expect_err => true
require 'bundler'
Bundler.load
if $LOAD_PATH.grep(/rack/i).any?
puts "nooo"
else
puts "hurrah"
end
R

out.should == "hurrah"
end
end

describe "not hurting brittle rubygems" do
it "does not inject #source into the generated YAML of the gem specs" do
system_gems "activerecord-2.3.2", "activesupport-2.3.2"
gemfile <<-G
source "file://#{gem_repo1}"
gem "activerecord"
G

Expand All @@ -85,4 +113,5 @@
end
end
end
end

end

0 comments on commit 2c8d6ae

Please sign in to comment.