Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes a bug where lockfiles were being updated or created even in the…

… face of errors
  • Loading branch information...
commit 4803fda05bb38f4152168fb3e53997d9c7df83df 1 parent 9f8db4e
Carlhuda authored
View
4 lib/bundler/environment.rb
@@ -36,8 +36,10 @@ def lock
env_file = root.join('.bundle/environment.rb')
env_file.rmtree if env_file.exist?
+ contents = @definition.to_lock
+
File.open(root.join('Gemfile.lock'), 'w') do |f|
- f.puts @definition.to_lock
+ f.puts contents
end
end
View
24 spec/install/gems/simple_case_spec.rb
@@ -11,6 +11,30 @@
out.should =~ /no dependencies/
end
+ it "does not make a lockfile if the install fails" do
+ install_gemfile <<-G, :expect_err => true
+ raise StandardError, "FAIL"
+ G
+
+ err.should =~ /FAIL \(StandardError\)/
+ bundled_app("Gemfile.lock").should_not exist
+ end
+
+ it "doesn't delete the lockfile if one already exists" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem 'rack'
+ G
+
+ lockfile = File.read(bundled_app("Gemfile.lock"))
+
+ install_gemfile <<-G, :expect_err => true
+ raise StandardError, "FAIL"
+ G
+
+ File.read(bundled_app("Gemfile.lock")).should == lockfile
+ end
+
it "fetches gems" do
install_gemfile <<-G
source "file://#{gem_repo1}"
View
61 spec/runtime/setup_spec.rb
@@ -1,6 +1,67 @@
require "spec_helper"
describe "Bundler.setup" do
+ it "raises if the Gemfile was not yet installed" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ ruby <<-R
+ require 'rubygems'
+ require 'bundler'
+
+ begin
+ Bundler.setup
+ puts "FAIL"
+ rescue Bundler::GemNotFound
+ puts "WIN"
+ end
+ R
+
+ out.should == "WIN"
+ end
+
+ it "doesn't create a Gemfile.lock if the setup fails" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ ruby <<-R, :expect_err => true
+ require 'rubygems'
+ require 'bundler'
+
+ Bundler.setup
+ R
+
+ bundled_app("Gemfile.lock").should_not exist
+ end
+
+ it "doesn't change the Gemfile.lock if the setup fails" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ lockfile = File.read(bundled_app("Gemfile.lock"))
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ gem "nosuchgem", "10.0"
+ G
+
+ ruby <<-R, :expect_err => true
+ require 'rubygems'
+ require 'bundler'
+
+ Bundler.setup
+ R
+
+ File.read(bundled_app("Gemfile.lock")).should == lockfile
+ end
+
it "uses BUNDLE_GEMFILE to locate the gemfile if present" do
gemfile <<-G
source "file://#{gem_repo1}"
Please sign in to comment.
Something went wrong with that request. Please try again.