summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-02-10 22:11:18 -0800
committerCarl Lerche <carllerche@mac.com>2010-02-10 22:11:18 -0800
commit5f5ac21b4161b1638ac196e554439d2aab9799e4 (patch)
treeb4ca2dc33d30cbd992219ce5a87319c4e5f90e4f
parentfc55262bc6183baefb329b9088a2d5966a7e33be (diff)
downloadbundler-5f5ac21b4161b1638ac196e554439d2aab9799e4.tar.gz
Generate .bundle/environment.rb on Bundle.setup if the bundle is locked and .bundle/environment.rb does not exist.
-rw-r--r--lib/bundler/runtime.rb10
-rw-r--r--spec/lock/gems_spec.rb3
-rw-r--r--spec/lock/git_spec.rb2
-rw-r--r--spec/runtime/setup_spec.rb17
4 files changed, 28 insertions, 4 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index a3d1fa07b3..494e758f79 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -5,6 +5,10 @@ module Bundler
include SharedHelpers
def setup(*groups)
+ if locked? # && !rb_lock_file.exist?
+ write_rb_lock
+ end
+
# Has to happen first
clean_load_path
@@ -111,11 +115,15 @@ module Bundler
specs.map { |s| s.load_paths }.flatten
end
+ def rb_lock_file
+ root.join(".bundle/environment.rb")
+ end
+
def write_rb_lock
shared_helpers = File.read(File.expand_path("../shared_helpers.rb", __FILE__))
template = File.read(File.expand_path("../templates/environment.erb", __FILE__))
erb = ERB.new(template, nil, '-')
- File.open("#{root}/.bundle/environment.rb", 'w') do |f|
+ File.open(rb_lock_file, 'w') do |f|
f.puts erb.result(binding)
end
end
diff --git a/spec/lock/gems_spec.rb b/spec/lock/gems_spec.rb
index 6950d10133..7d3a879b50 100644
--- a/spec/lock/gems_spec.rb
+++ b/spec/lock/gems_spec.rb
@@ -1,8 +1,7 @@
require File.expand_path('../../spec_helper', __FILE__)
-describe "gemfile lock with gems" do
+describe "bundle lock with gems" do
before :each do
- in_app_root
system_gems "rack-0.9.1"
gemfile <<-G
source "file://#{gem_repo1}"
diff --git a/spec/lock/git_spec.rb b/spec/lock/git_spec.rb
index d36d10439d..a0b72e9e33 100644
--- a/spec/lock/git_spec.rb
+++ b/spec/lock/git_spec.rb
@@ -1,6 +1,6 @@
require File.expand_path('../../spec_helper', __FILE__)
-describe "gemfile lock with git" do
+describe "bundle lock with git" do
it "doesn't break right after running lock" do
build_git "foo"
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 582424b26a..982e024bac 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -75,4 +75,21 @@ describe "Bundler.setup" do
out.should == "WIN"
end
end
+
+ describe "when locked" do
+ it "regenerates .bundle/environment.rb if it does not exist" do
+ system_gems "rack-1.0.0"
+
+ gemfile <<-G
+ gem "rack"
+ G
+
+ bundle :lock
+
+ bundled_app('.bundle/environment.rb').delete
+
+ should_be_installed "rack 1.0.0"
+ bundled_app('.bundle/environment.rb').should exist
+ end
+ end
end \ No newline at end of file