summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-08-06 13:50:32 -0700
committerCarl Lerche <carllerche@mac.com>2010-08-06 13:50:32 -0700
commitfe2f5fc4de175370588d4fd0236f50973c5756c6 (patch)
treee95b717fec9b31ba6365f8f71fadd494b27cad1a
parentd8844d53d43ee32a95a399599921634364f47d46 (diff)
downloadbundler-fe2f5fc4de175370588d4fd0236f50973c5756c6.tar.gz
Add --frozen to disable updating the Gemfile.lock with changes to Gemfile (this is one of the features of --deployment that was not available on its own)
-rw-r--r--lib/bundler/cli.rb7
-rw-r--r--spec/install/deploy_spec.rb33
2 files changed, 34 insertions, 6 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 418eefaab5..81f2628344 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -115,6 +115,8 @@ module Bundler
"Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine"
method_option "system", :type => :boolean, :banner =>
"Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
+ method_option "frozen", :type => :boolean, :banner =>
+ "Do not allow the Gemfile.lock to be updated after this install"
method_option "deployment", :type => :boolean, :banner =>
"Install using defaults tuned for deployment environments"
method_option "production", :type => :boolean, :banner =>
@@ -152,11 +154,12 @@ module Bundler
exit 1
end
- if opts[:deployment]
+ if opts[:deployment] || opts[:frozen]
Bundler.frozen = true
unless Bundler.default_lockfile.exist?
- raise ProductionError, "The --deployment flag requires a Gemfile.lock. Please make " \
+ flag = opts[:deployment] ? '--deployment' : '--frozen'
+ raise ProductionError, "The #{flag} flag requires a Gemfile.lock. Please make " \
"sure you have checked your Gemfile.lock into version control " \
"before deploying."
end
diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb
index 28d25e97a5..792fb36982 100644
--- a/spec/install/deploy_spec.rb
+++ b/spec/install/deploy_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe "install with --deployment" do
+describe "install with --deployment or --frozen" do
before do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -8,22 +8,32 @@ describe "install with --deployment" do
G
end
- it "fails without a lockfile" do
+ it "fails without a lockfile and says that --deployment requires a lock" do
bundle "install --deployment"
out.should include("The --deployment flag requires a Gemfile.lock")
end
+ it "fails without a lockfile and says that --frozen requires a lock" do
+ bundle "install --frozen"
+ out.should include("The --frozen flag requires a Gemfile.lock")
+ end
+
describe "with an existing lockfile" do
before do
bundle "install"
end
- it "works if you didn't change anything" do
+ it "works with the --deployment flag if you didn't change anything" do
bundle "install --deployment", :exit_status => true
exitstatus.should == 0
end
- it "explodes if you make a change and don't check in the lockfile" do
+ it "works with the --frozen flag if you didn't change anything" do
+ bundle "install --frozen", :exit_status => true
+ exitstatus.should == 0
+ end
+
+ it "explodes with the --deployment flag if you make a change and don't check in the lockfile" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -38,6 +48,21 @@ describe "install with --deployment" do
out.should_not include("You have changed in the Gemfile")
end
+ it "explodes with the --frozen flag if you make a change and don't check in the lockfile" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ gem "rack-obama"
+ G
+
+ bundle "install --frozen"
+ out.should include("You have modified your Gemfile")
+ out.should include("You have added to the Gemfile")
+ out.should include("* rack-obama")
+ out.should_not include("You have deleted from the Gemfile")
+ out.should_not include("You have changed in the Gemfile")
+ end
+
it "explodes if you remove a gem and don't check in the lockfile" do
gemfile <<-G
source "file://#{gem_repo1}"