summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-07-08 17:35:15 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-07-12 15:09:55 -0500
commitb5f9e10b53a829e3471492bae7b87c43d60de4f4 (patch)
tree0360efcf4e165166c4cce93f4f71fceae280acae
parent6b2d04b892dfa9ac9b93d4cba80d59195d71449f (diff)
downloadbundler-b5f9e10b53a829e3471492bae7b87c43d60de4f4.tar.gz
Fix deployment specs under 2.0
-rw-r--r--lib/bundler/cli/install.rb8
-rw-r--r--lib/bundler/cli/outdated.rb18
-rw-r--r--lib/bundler/definition.rb9
-rw-r--r--spec/commands/check_spec.rb8
-rw-r--r--spec/commands/inject_spec.rb8
-rw-r--r--spec/commands/outdated_spec.rb27
-rw-r--r--spec/commands/package_spec.rb3
-rw-r--r--spec/commands/update_spec.rb15
-rw-r--r--spec/install/deploy_spec.rb23
9 files changed, 94 insertions, 25 deletions
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 3ff3438baf..35a0aa7b58 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -44,7 +44,11 @@ module Bundler
options[:local] = true if Bundler.app_cache.exist?
- Bundler.settings[:frozen] = true unless Bundler.feature_flag.deployment_means_frozen?
+ if Bundler.feature_flag.deployment_means_frozen?
+ Bundler.settings.temporary(:deployment => true)
+ else
+ Bundler.settings[:frozen] ||= true
+ end
end
# When install is called with --no-deployment, disable deployment mode
@@ -177,7 +181,7 @@ module Bundler
def normalize_settings
Bundler.settings[:path] = nil if options[:system]
- Bundler.settings[:path] = "vendor/bundle" if options[:deployment] && !Bundler.feature_flag.deployment_means_frozen?
+ Bundler.settings[:path] = "vendor/bundle" if options[:deployment]
Bundler.settings[:path] = options["path"] if options["path"]
Bundler.settings[:path] ||= "bundle" if options["standalone"]
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 20d6ed01fa..07e17df981 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -214,13 +214,19 @@ module Bundler
end
def check_for_deployment_mode
- if Bundler.frozen?
- raise ProductionError, "You are trying to check outdated gems in " \
- "deployment mode. Run `bundle outdated` elsewhere.\n" \
- "\nIf this is a development machine, remove the " \
- "#{Bundler.default_gemfile} freeze" \
- "\nby running `bundle install --no-deployment`."
+ return unless Bundler.frozen?
+ suggested_command = if Bundler.settings.locations("frozen")[:global]
+ "bundle config --delete frozen"
+ elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
+ "bundle config --delete deployment"
+ else
+ "bundle install --no-deployment"
end
+ raise ProductionError, "You are trying to check outdated gems in " \
+ "deployment mode. Run `bundle outdated` elsewhere.\n" \
+ "\nIf this is a development machine, remove the " \
+ "#{Bundler.default_gemfile} freeze" \
+ "\nby running `#{suggested_command}`."
end
def update_present_via_semver_portions(current_spec, active_spec, options)
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 074291414b..23b61ffd01 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -376,8 +376,13 @@ module Bundler
"updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
unless explicit_flag
-
- suggested_command = Bundler.settings.locations("frozen")[:global] == "1" ? "bundle config --delete frozen" : "bundle install --no-deployment"
+ suggested_command = if Bundler.settings.locations("frozen")[:global]
+ "bundle config --delete frozen"
+ elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
+ "bundle config --delete deployment"
+ else
+ "bundle install --no-deployment"
+ end
msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
"freeze \nby running `#{suggested_command}`."
end
diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb
index bed9fa1aa9..b16d86e6b6 100644
--- a/spec/commands/check_spec.rb
+++ b/spec/commands/check_spec.rb
@@ -214,17 +214,17 @@ RSpec.describe "bundle check" do
end
it "fails when there's no lock file and frozen is set" do
- gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "foo"
G
- bundle "install"
- bundle "install --deployment"
+ bundle! "config deployment true"
+ bundle! :install
FileUtils.rm(bundled_app("Gemfile.lock"))
bundle :check
- expect(exitstatus).not_to eq(0) if exitstatus
+ expect(last_command).to be_failure
end
context "--path" do
diff --git a/spec/commands/inject_spec.rb b/spec/commands/inject_spec.rb
index 78f6565d99..80d22ee286 100644
--- a/spec/commands/inject_spec.rb
+++ b/spec/commands/inject_spec.rb
@@ -79,7 +79,11 @@ Usage: "bundle inject GEM VERSION"
context "when frozen" do
before do
bundle "install"
- bundle "config --local frozen 1"
+ if Bundler.feature_flag.bundler_2_mode?
+ bundle! "config --local deployment true"
+ else
+ bundle! "config --local frozen true"
+ end
end
it "injects anyway" do
@@ -96,7 +100,7 @@ Usage: "bundle inject GEM VERSION"
it "restores frozen afterwards" do
bundle "inject 'rack-obama' '> 0'"
config = YAML.load(bundled_app(".bundle/config").read)
- expect(config["BUNDLE_FROZEN"]).to eq("1")
+ expect(config["BUNDLE_DEPLOYMENT"] || config["BUNDLE_FROZEN"]).to eq("true")
end
it "doesn't allow Gemfile changes" do
diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb
index 3ef955fe23..7e2a71e067 100644
--- a/spec/commands/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
@@ -405,7 +405,7 @@ RSpec.describe "bundle outdated" do
expect(out).to include("Installing foo 1.0")
end
- context "after bundle install --deployment" do
+ context "after bundle install --deployment", :bundler => "< 2" do
before do
install_gemfile <<-G, :deployment => true
source "file://#{gem_repo2}"
@@ -419,7 +419,7 @@ RSpec.describe "bundle outdated" do
update_repo2 { build_gem "activesupport", "3.0" }
bundle "outdated"
- expect(exitstatus).to_not be_zero if exitstatus
+ expect(last_command).to be_failure
expect(out).to include("You are trying to check outdated gems in deployment mode.")
expect(out).to include("Run `bundle outdated` elsewhere.")
expect(out).to include("If this is a development machine, remove the ")
@@ -427,6 +427,29 @@ RSpec.describe "bundle outdated" do
end
end
+ context "after bundle config deployment true" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+
+ gem "rack"
+ gem "foo"
+ G
+ bundle! "config deployment true"
+ end
+
+ it "outputs a helpful message about being in deployment mode" do
+ update_repo2 { build_gem "activesupport", "3.0" }
+
+ bundle "outdated"
+ expect(last_command).to be_failure
+ expect(out).to include("You are trying to check outdated gems in deployment mode.")
+ expect(out).to include("Run `bundle outdated` elsewhere.")
+ expect(out).to include("If this is a development machine, remove the ")
+ expect(out).to include("Gemfile freeze\nby running `bundle config --delete deployment`.")
+ end
+ end
+
context "update available for a gem on a different platform" do
before do
install_gemfile <<-G
diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb
index 9b0de7f4e4..d2854f122f 100644
--- a/spec/commands/package_spec.rb
+++ b/spec/commands/package_spec.rb
@@ -205,6 +205,7 @@ RSpec.describe "bundle package" do
subject { bundle "package --frozen" }
it "tries to install with frozen" do
+ bundle! "config deployment true"
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -216,7 +217,7 @@ RSpec.describe "bundle package" do
expect(out).to include("You have added to the Gemfile")
expect(out).to include("* rack-obama")
bundle "env"
- expect(out).to include("frozen")
+ expect(out).to include("frozen").or include("deployment")
end
end
end
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index a0f0245046..49a2ceafd1 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -198,7 +198,7 @@ RSpec.describe "bundle update" do
end
describe "in a frozen bundle" do
- it "should fail loudly" do
+ it "should fail loudly", :bundler => "< 2" do
bundle! "install --deployment"
bundle "update", :all => bundle_update_requires_all?
@@ -207,11 +207,18 @@ RSpec.describe "bundle update" do
expect(exitstatus).not_to eq(0) if exitstatus
end
- it "should suggest different command when frozen is set globally" do
+ it "should suggest different command when frozen is set globally", :bundler => "< 2" do
bundle! "config --global frozen 1"
bundle "update", :all => bundle_update_requires_all?
- expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
- expect(out).to match(/freeze \nby running `bundle config --delete frozen`./m)
+ expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
+ and match(/freeze \nby running `bundle config --delete frozen`./m)
+ end
+
+ it "should suggest different command when frozen is set globally", :bundler => "2" do
+ bundle! "config --global deployment true"
+ bundle "update", :all => bundle_update_requires_all?
+ expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
+ and match(/freeze \nby running `bundle config --delete deployment`./m)
end
end
diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb
index b4ab5d495f..e5a71609ed 100644
--- a/spec/install/deploy_spec.rb
+++ b/spec/install/deploy_spec.rb
@@ -163,7 +163,7 @@ RSpec.describe "install with --deployment or --frozen" do
expect(out).to include("The path `#{lib_path("path_gem-1.0")}` does not exist.")
end
- it "can have --frozen set via an environment variable" do
+ it "can have --frozen set via an environment variable", :bundler => "< 2" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -179,6 +179,22 @@ RSpec.describe "install with --deployment or --frozen" do
expect(out).not_to include("You have changed in the Gemfile")
end
+ it "can have --deployment set via an environment variable" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ gem "rack-obama"
+ G
+
+ ENV["BUNDLE_DEPLOYMENT"] = "true"
+ bundle "install"
+ expect(out).to include("deployment mode")
+ expect(out).to include("You have added to the Gemfile")
+ expect(out).to include("* rack-obama")
+ expect(out).not_to include("You have deleted from the Gemfile")
+ expect(out).not_to include("You have changed in the Gemfile")
+ end
+
it "can have --frozen set to false via an environment variable" do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -187,6 +203,7 @@ RSpec.describe "install with --deployment or --frozen" do
G
ENV["BUNDLE_FROZEN"] = "false"
+ ENV["BUNDLE_DEPLOYMENT"] = "false"
bundle "install"
expect(out).not_to include("deployment mode")
expect(out).not_to include("You have added to the Gemfile")
@@ -277,7 +294,9 @@ RSpec.describe "install with --deployment or --frozen" do
end
it "remembers that the bundle is frozen at runtime" do
- bundle "install --deployment"
+ bundle! :lock
+
+ bundle! "config deployment true"
gemfile <<-G
source "file://#{gem_repo1}"