summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-07-10 08:45:00 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-07-19 13:10:39 -0500
commitaec2780f59caf6070752fc7ceda1470cf1faf496 (patch)
tree0dd4b90e4073c4e42d3d60e11646c60216deaa41
parent6b9defe6a5c3a83f13d2f45e2166d7198ae28486 (diff)
downloadbundler-aec2780f59caf6070752fc7ceda1470cf1faf496.tar.gz
Set forgotten command line options via config in 2.0
-rw-r--r--lib/bundler.rb2
-rw-r--r--lib/bundler/cli/clean.rb3
-rw-r--r--lib/bundler/cli/install.rb4
-rw-r--r--lib/bundler/cli/package.rb2
-rw-r--r--lib/bundler/installer.rb5
-rw-r--r--lib/bundler/settings.rb9
-rw-r--r--lib/bundler/source/git/git_proxy.rb2
-rw-r--r--spec/cache/git_spec.rb8
-rw-r--r--spec/cache/path_spec.rb18
-rw-r--r--spec/commands/binstubs_spec.rb11
-rw-r--r--spec/commands/check_spec.rb28
-rw-r--r--spec/commands/clean_spec.rb58
-rw-r--r--spec/commands/config_spec.rb4
-rw-r--r--spec/commands/exec_spec.rb2
-rw-r--r--spec/commands/install_spec.rb16
-rw-r--r--spec/commands/outdated_spec.rb2
-rw-r--r--spec/commands/package_spec.rb10
-rw-r--r--spec/commands/update_spec.rb2
-rw-r--r--spec/install/deploy_spec.rb13
-rw-r--r--spec/install/gemfile/gemspec_spec.rb2
-rw-r--r--spec/install/gemfile/groups_spec.rb42
-rw-r--r--spec/install/gems/compact_index_spec.rb2
-rw-r--r--spec/install/gems/standalone_spec.rb28
-rw-r--r--spec/install/path_spec.rb16
-rw-r--r--spec/install/post_bundle_message_spec.rb16
-rw-r--r--spec/lock/lockfile_spec.rb2
-rw-r--r--spec/runtime/executable_spec.rb4
-rw-r--r--spec/runtime/setup_spec.rb10
-rw-r--r--spec/support/helpers.rb34
29 files changed, 204 insertions, 151 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 0a865f7218..d0ae913216 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -231,7 +231,7 @@ module Bundler
def app_cache(custom_path = nil)
path = custom_path || root
- path.join(settings.app_cache_path)
+ Pathname.new(path).join(settings.app_cache_path)
end
def tmp(name = Process.pid.to_s)
diff --git a/lib/bundler/cli/clean.rb b/lib/bundler/cli/clean.rb
index 0534532ee2..231127cf97 100644
--- a/lib/bundler/cli/clean.rb
+++ b/lib/bundler/cli/clean.rb
@@ -17,10 +17,9 @@ module Bundler
def require_path_or_force
if !Bundler.settings[:path] && !options[:force]
- Bundler.ui.error "Cleaning all the gems on your system is dangerous! " \
+ raise InvalidOption, "Cleaning all the gems on your system is dangerous! " \
"If you're sure you want to remove every system gem not in this " \
"bundle, run `bundle clean --force`."
- exit 1
end
end
end
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 9f81291941..8965192187 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -78,8 +78,8 @@ module Bundler
Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
Bundler::CLI::Common.output_without_groups_message
- if Bundler.settings[:path]
- absolute_path = File.expand_path(Bundler.settings[:path])
+ if path = Bundler.settings[:path]
+ absolute_path = File.expand_path(path)
relative_path = absolute_path.sub(File.expand_path(".") + File::SEPARATOR, "." + File::SEPARATOR)
Bundler.ui.confirm "Bundled gems are installed into #{relative_path}."
else
diff --git a/lib/bundler/cli/package.rb b/lib/bundler/cli/package.rb
index 9fb4e7f137..cda41ea623 100644
--- a/lib/bundler/cli/package.rb
+++ b/lib/bundler/cli/package.rb
@@ -18,7 +18,7 @@ module Bundler
install
# TODO: move cache contents here now that all bundles are locked
- custom_path = Pathname.new(options[:path]) if options[:path]
+ custom_path = Bundler.settings[:path] if options[:path]
Bundler.load.cache(custom_path)
end
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index db82660176..5996d185da 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -151,7 +151,10 @@ module Bundler
def generate_standalone_bundler_executable_stubs(spec)
# double-assignment to avoid warnings about variables that will be used by ERB
bin_path = Bundler.bin_path
- standalone_path = standalone_path = Bundler.root.join(Bundler.settings[:path]).relative_path_from(bin_path)
+ unless path = Bundler.settings[:path]
+ raise "Can't standalone without a path set"
+ end
+ standalone_path = standalone_path = Bundler.root.join(path).relative_path_from(bin_path)
template = File.read(File.expand_path("../templates/Executable.standalone", __FILE__))
ruby_command = ruby_command = Thor::Util.ruby_command
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 6692389c99..f4fdf96165 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -172,6 +172,7 @@ module Bundler
def locations(key)
key = key_for(key)
locations = {}
+ locations[:temporary] = @temporary[key] if @temporary.key?(key)
locations[:local] = @local_config[key] if @local_config.key?(key)
locations[:env] = ENV[key] if ENV[key]
locations[:global] = @global_config[key] if @global_config.key?(key)
@@ -183,6 +184,11 @@ module Bundler
key = key_for(exposed_key)
locations = []
+
+ if @temporary.key?(key)
+ locations << "Set for the current command: #{converted_value(@temporary[key], exposed_key).inspect}"
+ end
+
if @local_config.key?(key)
locations << "Set for your local app (#{local_config_file}): #{converted_value(@local_config[key], exposed_key).inspect}"
end
@@ -271,7 +277,8 @@ module Bundler
end
def array_to_s(array)
- array.empty? ? nil : array.join(":")
+ array = Array(array)
+ array.empty? ? nil : array.join(":").tr(" ", ":")
end
def set_key(key, value, hash, file)
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb
index 5b09b52a60..30ab5edf0d 100644
--- a/lib/bundler/source/git/git_proxy.rb
+++ b/lib/bundler/source/git/git_proxy.rb
@@ -153,7 +153,7 @@ module Bundler
end
def git_retry(command)
- Bundler::Retry.new("`git #{command}`", GitNotAllowedError).attempts do
+ Bundler::Retry.new("`git #{URICredentialsFilter.credential_filtered_string(command, uri)}`", GitNotAllowedError).attempts do
git(command)
end
end
diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb
index b780b19376..562fc881c0 100644
--- a/spec/cache/git_spec.rb
+++ b/spec/cache/git_spec.rb
@@ -100,7 +100,7 @@ end
gem "foo", :git => '#{lib_path("foo-1.0")}'
G
- bundle "#{cmd} --all"
+ bundle! cmd, forgotten_command_line_options([:all, :cache_all] => true)
update_git "foo" do |s|
s.write "lib/foo.rb", "puts :CACHE"
@@ -187,8 +187,8 @@ end
gem "foo", :git => '#{lib_path("foo-1.0")}'
G
- bundle "#{cmd} --all"
- bundle "#{cmd}"
+ bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
+ bundle cmd
expect(out).not_to include("Your Gemfile contains path and git dependencies.")
end
@@ -204,7 +204,7 @@ end
install_gemfile <<-G
gem "foo", :git => '#{lib_path("foo-1.0")}'
G
- bundle "#{cmd} --all"
+ bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
ref = git.ref_for("master", 11)
gemspec = bundled_app("vendor/cache/foo-1.0-#{ref}/foo.gemspec").read
diff --git a/spec/cache/path_spec.rb b/spec/cache/path_spec.rb
index 3bf67204ce..327d0abf60 100644
--- a/spec/cache/path_spec.rb
+++ b/spec/cache/path_spec.rb
@@ -9,7 +9,7 @@
gem "foo", :path => '#{bundled_app("lib/foo")}'
G
- bundle "#{cmd} --all"
+ bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
expect(the_bundle).to include_gems "foo 1.0"
end
@@ -21,7 +21,7 @@
gem "foo", :path => '#{lib_path("foo-1.0")}'
G
- bundle "#{cmd} --all"
+ bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
expect(bundled_app("vendor/cache/foo-1.0")).to exist
expect(bundled_app("vendor/cache/foo-1.0/.bundlecache")).to be_file
@@ -39,7 +39,7 @@
gem "#{libname}", :path => '#{libpath}'
G
- bundle "#{cmd} --all"
+ bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
expect(bundled_app("vendor/cache/#{libname}")).to exist
expect(bundled_app("vendor/cache/#{libname}/.bundlecache")).to be_file
@@ -54,13 +54,13 @@
gem "foo", :path => '#{lib_path("foo-1.0")}'
G
- bundle "#{cmd} --all"
+ bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
build_lib "foo" do |s|
s.write "lib/foo.rb", "puts :CACHE"
end
- bundle "#{cmd} --all"
+ bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
expect(bundled_app("vendor/cache/foo-1.0")).to exist
FileUtils.rm_rf lib_path("foo-1.0")
@@ -76,13 +76,13 @@
gem "foo", :path => '#{lib_path("foo-1.0")}'
G
- bundle "#{cmd} --all"
+ bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
install_gemfile <<-G
gem "bar", :path => '#{lib_path("bar-1.0")}'
G
- bundle "#{cmd} --all"
+ bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
expect(bundled_app("vendor/cache/bar-1.0")).not_to exist
end
@@ -105,7 +105,7 @@
gem "foo", :path => '#{lib_path("foo-1.0")}'
G
- bundle "#{cmd} --all"
+ bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
build_lib "bar"
install_gemfile <<-G
@@ -124,7 +124,7 @@
gem "foo", :path => '#{lib_path("foo-1.0")}'
G
- bundle "#{cmd} --all"
+ bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
build_lib "baz"
gemfile <<-G
diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb
index 430dbef314..d696ace093 100644
--- a/spec/commands/binstubs_spec.rb
+++ b/spec/commands/binstubs_spec.rb
@@ -150,8 +150,8 @@ RSpec.describe "bundle binstubs <gem>" do
gem "rails"
G
- bundle "binstubs rack --path exec"
- bundle :install
+ bundle! "binstubs rack", forgotten_command_line_options([:path, :bin] => "exec")
+ bundle! :install
expect(bundled_app("exec/rails")).to exist
end
@@ -159,15 +159,16 @@ RSpec.describe "bundle binstubs <gem>" do
context "after installing with --standalone" do
before do
- install_gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
G
- bundle "install --standalone"
+ forgotten_command_line_options(:path => "bundle")
+ bundle! "install", :standalone => true
end
it "includes the standalone path" do
- bundle "binstubs rack --standalone"
+ bundle! "binstubs rack", :standalone => true
standalone_line = File.read(bundled_app("bin/rackup")).each_line.find {|line| line.include? "$:.unshift" }.strip
expect(standalone_line).to eq %($:.unshift File.expand_path "../../bundle", path.realpath)
end
diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb
index b16d86e6b6..5957598f83 100644
--- a/spec/commands/check_spec.rb
+++ b/spec/commands/check_spec.rb
@@ -92,7 +92,7 @@ RSpec.describe "bundle check" do
expect(out).to include("Bundler can't satisfy your Gemfile's dependencies.")
end
- it "remembers --without option from install" do
+ it "remembers --without option from install", :bundler => "< 2" do
gemfile <<-G
source "file://#{gem_repo1}"
group :foo do
@@ -100,9 +100,21 @@ RSpec.describe "bundle check" do
end
G
- bundle "install --without foo"
- bundle "check"
- expect(exitstatus).to eq(0) if exitstatus
+ bundle! "install --without foo"
+ bundle! "check"
+ expect(out).to include("The Gemfile's dependencies are satisfied")
+ end
+
+ it "uses the without setting" do
+ bundle! "config without foo"
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+ group :foo do
+ gem "rack"
+ end
+ G
+
+ bundle! "check"
expect(out).to include("The Gemfile's dependencies are satisfied")
end
@@ -219,8 +231,7 @@ RSpec.describe "bundle check" do
gem "foo"
G
- bundle! "config deployment true"
- bundle! :install
+ bundle! "install", forgotten_command_line_options([:deployment, :frozen] => true)
FileUtils.rm(bundled_app("Gemfile.lock"))
bundle :check
@@ -244,10 +255,9 @@ RSpec.describe "bundle check" do
expect(out).to include("The Gemfile's dependencies are satisfied")
end
- it "should write to .bundle/config" do
+ it "should write to .bundle/config", :bundler => "< 2" do
bundle "check --path vendor/bundle"
- bundle "check"
- expect(exitstatus).to eq(0) if exitstatus
+ bundle! "check"
end
end
diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb
index 3f3dc8565d..dcdb4bfaa3 100644
--- a/spec/commands/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
@@ -25,16 +25,16 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
gem "thin"
G
- bundle "install"
+ bundle! "install"
- bundle :clean
+ bundle! :clean
expect(out).to include("Removing foo (1.0)")
@@ -52,7 +52,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -80,7 +80,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle! "install --path vendor/bundle --no-clean"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -111,8 +111,8 @@ RSpec.describe "bundle clean" do
end
G
- bundle "install --path vendor/bundle"
- bundle "install --without test_group"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
+ bundle "install", forgotten_command_line_options(:without => "test_group")
bundle :clean
expect(out).to include("Removing rack (1.0.0)")
@@ -137,7 +137,7 @@ RSpec.describe "bundle clean" do
end
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
bundle :clean
@@ -159,7 +159,7 @@ RSpec.describe "bundle clean" do
end
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
gemfile <<-G
source "file://#{gem_repo1}"
@@ -195,7 +195,7 @@ RSpec.describe "bundle clean" do
end
G
- bundle! "install --path vendor/bundle"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
update_git "foo", :path => lib_path("foo-bar")
revision2 = revision_for(lib_path("foo-bar"))
@@ -225,7 +225,7 @@ RSpec.describe "bundle clean" do
gem "activesupport", :git => "#{lib_path("rails")}", :ref => '#{revision}'
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
bundle :clean
expect(out).to include("")
@@ -247,7 +247,7 @@ RSpec.describe "bundle clean" do
end
end
G
- bundle "install --path vendor/bundle --without test"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :without => "test")
bundle :clean
@@ -268,7 +268,7 @@ RSpec.describe "bundle clean" do
end
G
- bundle "install --path vendor/bundle --without development"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :without => "development")
bundle :clean
expect(exitstatus).to eq(0) if exitstatus
@@ -283,7 +283,7 @@ RSpec.describe "bundle clean" do
bundle :clean
- expect(exitstatus).to eq(1) if exitstatus
+ expect(exitstatus).to eq(15) if exitstatus
expect(out).to include("--force")
end
@@ -296,7 +296,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
gemfile <<-G
source "file://#{gem_repo1}"
@@ -345,7 +345,7 @@ RSpec.describe "bundle clean" do
gem "thin"
gem "rack"
G
- bundle "install --path vendor/bundle --clean"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => true)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -366,7 +366,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle! "install --path vendor/bundle --clean"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => true)
update_repo2 do
build_gem "foo", "1.0.1"
@@ -385,7 +385,7 @@ RSpec.describe "bundle clean" do
gem "thin"
gem "rack"
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
gemfile <<-G
source "file://#{gem_repo1}"
@@ -405,7 +405,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle! "install --path vendor/bundle"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
update_repo2 do
build_gem "foo", "1.0.1"
@@ -501,7 +501,7 @@ RSpec.describe "bundle clean" do
gem "foo", :git => "#{lib_path("foo-1.0")}"
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
# mimic 7 length git revisions in Gemfile.lock
gemfile_lock = File.read(bundled_app("Gemfile.lock")).split("\n")
@@ -512,7 +512,7 @@ RSpec.describe "bundle clean" do
file.print gemfile_lock.join("\n")
end
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
bundle :clean
@@ -560,10 +560,8 @@ RSpec.describe "bundle clean" do
gem "bar", "1.0", :path => "#{relative_path}"
G
- bundle "install --path vendor/bundle"
- bundle :clean
-
- expect(exitstatus).to eq(0) if exitstatus
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
+ bundle! :clean
end
it "doesn't remove gems in dry-run mode with path set" do
@@ -574,7 +572,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -602,7 +600,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -632,7 +630,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
bundle "config dry_run false"
gemfile <<-G
@@ -662,7 +660,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -689,7 +687,7 @@ RSpec.describe "bundle clean" do
gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
G
- bundle! "install --path vendor/bundle"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
expect(vendored_gems("bundler/gems/extensions")).to exist
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb
index 4b9b27e0d5..9e49357465 100644
--- a/spec/commands/config_spec.rb
+++ b/spec/commands/config_spec.rb
@@ -45,7 +45,7 @@ RSpec.describe ".bundle/config" do
describe "BUNDLE_APP_CONFIG" do
it "can be moved with an environment variable" do
ENV["BUNDLE_APP_CONFIG"] = tmp("foo/bar").to_s
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
expect(bundled_app(".bundle")).not_to exist
expect(tmp("foo/bar/config")).to exist
@@ -57,7 +57,7 @@ RSpec.describe ".bundle/config" do
Dir.chdir bundled_app("omg")
ENV["BUNDLE_APP_CONFIG"] = "../foo"
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
expect(bundled_app(".bundle")).not_to exist
expect(bundled_app("../foo/config")).to exist
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index c2e3b88fdd..8acc00fc91 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -139,7 +139,7 @@ RSpec.describe "bundle exec" do
end
it "handles gems installed with --without" do
- install_gemfile <<-G, :without => :middleware
+ install_gemfile <<-G, forgotten_command_line_options(:without => "middleware")
source "file://#{gem_repo1}"
gem "rack" # rack 0.9.1 and 1.0 exist
diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb
index 3858a45b82..fd825a374f 100644
--- a/spec/commands/install_spec.rb
+++ b/spec/commands/install_spec.rb
@@ -261,21 +261,21 @@ RSpec.describe "bundle install with gem sources" do
end
it "works" do
- bundle "install --path vendor"
+ bundle "install", forgotten_command_line_options(:path => "vendor")
expect(the_bundle).to include_gems "rack 1.0"
end
- it "allows running bundle install --system without deleting foo" do
- bundle "install --path vendor"
- bundle "install --system"
+ it "allows running bundle install --system without deleting foo", :bundler => "< 2" do
+ bundle "install", forgotten_command_line_options(:path => "vendor")
+ bundle "install", forgotten_command_line_options(:system => true)
FileUtils.rm_rf(bundled_app("vendor"))
expect(the_bundle).to include_gems "rack 1.0"
end
- it "allows running bundle install --system after deleting foo" do
- bundle "install --path vendor"
+ it "allows running bundle install --system after deleting foo", :bundler => "< 2" do
+ bundle "install", forgotten_command_line_options(:path => "vendor")
FileUtils.rm_rf(bundled_app("vendor"))
- bundle "install --system"
+ bundle "install", forgotten_command_line_options(:system => true)
expect(the_bundle).to include_gems "rack 1.0"
end
end
@@ -486,7 +486,7 @@ RSpec.describe "bundle install with gem sources" do
it "should display a proper message to explain the problem" do
FileUtils.chmod(0o500, bundled_app("vendor"))
- bundle :install, :path => "vendor"
+ bundle :install, forgotten_command_line_options(:path => "vendor")
expect(out).to include(bundled_app("vendor").to_s)
expect(out).to include("grant write permissions")
end
diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb
index 7e2a71e067..50a16bd926 100644
--- a/spec/commands/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
@@ -407,7 +407,7 @@ RSpec.describe "bundle outdated" do
context "after bundle install --deployment", :bundler => "< 2" do
before do
- install_gemfile <<-G, :deployment => true
+ install_gemfile <<-G, forgotten_command_line_options([:deployment, :frozen] => true)
source "file://#{gem_repo2}"
gem "rack"
diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb
index d2854f122f..a143c225f3 100644
--- a/spec/commands/package_spec.rb
+++ b/spec/commands/package_spec.rb
@@ -148,7 +148,7 @@ RSpec.describe "bundle package" do
gem 'rack'
D
- bundle "package --path=#{bundled_app("test")}"
+ bundle! :package, forgotten_command_line_options(:path => bundled_app("test"))
expect(the_bundle).to include_gems "rack 1.0.0"
expect(bundled_app("test/vendor/cache/")).to exist
@@ -202,7 +202,7 @@ RSpec.describe "bundle package" do
bundle "install"
end
- subject { bundle "package --frozen" }
+ subject { bundle :package, forgotten_command_line_options(:frozen => true) }
it "tries to install with frozen" do
bundle! "config deployment true"
@@ -241,16 +241,16 @@ RSpec.describe "bundle install with gem sources" do
it "does not hit the remote at all" do
build_repo2
- install_gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "rack"
G
- bundle :pack
+ bundle! :pack
simulate_new_machine
FileUtils.rm_rf gem_repo2
- bundle "install --deployment"
+ bundle! :install, forgotten_command_line_options([:deployment, :frozen] => true, :path => "vendor/bundle")
expect(the_bundle).to include_gems "rack 1.0.0"
end
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index 49a2ceafd1..b7e0a17305 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -202,9 +202,9 @@ RSpec.describe "bundle update" do
bundle! "install --deployment"
bundle "update", :all => bundle_update_requires_all?
+ expect(last_command).to be_failure
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 install --no-deployment`./m)
- expect(exitstatus).not_to eq(0) if exitstatus
end
it "should suggest different command when frozen is set globally", :bundler => "< 2" do
diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb
index e5a71609ed..b93ee6d5f0 100644
--- a/spec/install/deploy_spec.rb
+++ b/spec/install/deploy_spec.rb
@@ -42,10 +42,13 @@ RSpec.describe "install with --deployment or --frozen" do
it "still works if you are not in the app directory and specify --gemfile" do
bundle "install"
- Dir.chdir tmp
- simulate_new_machine
- bundle "install --gemfile #{tmp}/bundled_app/Gemfile --deployment"
- Dir.chdir bundled_app
+ Dir.chdir tmp do
+ simulate_new_machine
+ bundle! :install,
+ forgotten_command_line_options(:gemfile => "#{tmp}/bundled_app/Gemfile",
+ [:deployment, :frozen] => true,
+ :path => "vendor/bundle")
+ end
expect(the_bundle).to include_gems "rack 1.0"
end
@@ -144,7 +147,7 @@ RSpec.describe "install with --deployment or --frozen" do
expect(the_bundle).to include_gems "path_gem 1.0"
FileUtils.rm_r lib_path("path_gem-1.0")
- bundle! :install, :path => ".bundle", :without => "development", :deployment => true, :env => { :DEBUG => "1" }
+ bundle! :install, forgotten_command_line_options(:path => ".bundle", :without => "development", [:deployment, :frozen] => true).merge(:env => { :DEBUG => "1" })
run! "puts :WIN"
expect(out).to eq("WIN")
end
diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb
index e04dafb2fa..f06229e0a4 100644
--- a/spec/install/gemfile/gemspec_spec.rb
+++ b/spec/install/gemfile/gemspec_spec.rb
@@ -651,7 +651,7 @@ RSpec.describe "bundle install from an existing gemspec" do
it "installs the ruby platform gemspec and skips dev deps with --without development" do
simulate_platform "ruby"
- install_gemfile! <<-G, :without => "development"
+ install_gemfile! <<-G, forgotten_command_line_options(:without => "development")
source "file://#{gem_repo1}"
gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
G
diff --git a/spec/install/gemfile/groups_spec.rb b/spec/install/gemfile/groups_spec.rb
index b49b64d1f0..4008ba9e0e 100644
--- a/spec/install/gemfile/groups_spec.rb
+++ b/spec/install/gemfile/groups_spec.rb
@@ -86,7 +86,7 @@ RSpec.describe "bundle install with groups" do
end
it "installs gems in the default group" do
- bundle :install, :without => "emo"
+ bundle! :install, forgotten_command_line_options(:without => "emo")
expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default]
end
@@ -96,20 +96,20 @@ RSpec.describe "bundle install with groups" do
end
it "does not install gems from the previously excluded group" do
- bundle :install, :without => "emo"
+ bundle :install, forgotten_command_line_options(:without => "emo")
expect(the_bundle).not_to include_gems "activesupport 2.3.5"
bundle :install
expect(the_bundle).not_to include_gems "activesupport 2.3.5"
end
it "does not say it installed gems from the excluded group" do
- bundle :install, :without => "emo"
+ bundle! :install, forgotten_command_line_options(:without => "emo")
expect(out).not_to include("activesupport")
end
it "allows Bundler.setup for specific groups" do
- bundle :install, :without => "emo"
- run("require 'rack'; puts RACK", :default)
+ bundle :install, forgotten_command_line_options(:without => "emo")
+ run!("require 'rack'; puts RACK", :default)
expect(out).to eq("1.0.0")
end
@@ -122,15 +122,15 @@ RSpec.describe "bundle install with groups" do
end
G
- bundle :install, :without => "emo"
+ bundle :install, forgotten_command_line_options(:without => "emo")
expect(the_bundle).to include_gems "activesupport 2.3.2", :groups => [:default]
end
it "still works on a different machine and excludes gems" do
- bundle :install, :without => "emo"
+ bundle :install, forgotten_command_line_options(:without => "emo")
simulate_new_machine
- bundle :install, :without => "emo"
+ bundle :install, forgotten_command_line_options(:without => "emo")
expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default]
expect(the_bundle).not_to include_gems "activesupport 2.3.5", :groups => [:default]
@@ -149,14 +149,14 @@ RSpec.describe "bundle install with groups" do
end
it "clears without when passed an empty list" do
- bundle :install, :without => "emo"
+ bundle :install, forgotten_command_line_options(:without => "emo")
- bundle 'install --without ""'
+ bundle :install, forgotten_command_line_options(:without => "")
expect(the_bundle).to include_gems "activesupport 2.3.5"
end
it "doesn't clear without when nothing is passed" do
- bundle :install, :without => "emo"
+ bundle :install, forgotten_command_line_options(:without => "emo")
bundle :install
expect(the_bundle).not_to include_gems "activesupport 2.3.5"
@@ -168,12 +168,12 @@ RSpec.describe "bundle install with groups" do
end
it "does install gems from the optional group when requested" do
- bundle :install, :with => "debugging"
+ bundle :install, forgotten_command_line_options(:with => "debugging")
expect(the_bundle).to include_gems "thin 1.0"
end
it "does install gems from the previously requested group" do
- bundle :install, :with => "debugging"
+ bundle :install, forgotten_command_line_options(:with => "debugging")
expect(the_bundle).to include_gems "thin 1.0"
bundle :install
expect(the_bundle).to include_gems "thin 1.0"
@@ -187,8 +187,8 @@ RSpec.describe "bundle install with groups" do
end
it "clears with when passed an empty list" do
- bundle :install, :with => "debugging"
- bundle 'install --with ""'
+ bundle :install, forgotten_command_line_options(:with => "debugging")
+ bundle :install, forgotten_command_line_options(:with => "")
expect(the_bundle).not_to include_gems "thin 1.0"
end
@@ -210,7 +210,7 @@ RSpec.describe "bundle install with groups" do
end
it "can add and remove a group at the same time" do
- bundle :install, :with => "debugging", :without => "emo"
+ bundle :install, forgotten_command_line_options(:with => "debugging", :without => "emo")
expect(the_bundle).to include_gems "thin 1.0"
expect(the_bundle).not_to include_gems "activesupport 2.3.5"
end
@@ -238,12 +238,12 @@ RSpec.describe "bundle install with groups" do
end
it "installs gems in the default group" do
- bundle :install, :without => "emo lolercoaster"
+ bundle! :install, forgotten_command_line_options(:without => "emo lolercoaster")
expect(the_bundle).to include_gems "rack 1.0.0"
end
it "installs the gem if any of its groups are installed" do
- bundle "install --without emo"
+ bundle! :install, forgotten_command_line_options(:without => "emo")
expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
end
@@ -299,12 +299,12 @@ RSpec.describe "bundle install with groups" do
end
it "installs gems in the default group" do
- bundle :install, :without => "emo lolercoaster"
+ bundle! :install, forgotten_command_line_options(:without => "emo lolercoaster")
expect(the_bundle).to include_gems "rack 1.0.0"
end
it "installs the gem if any of its groups are installed" do
- bundle "install --without emo"
+ bundle! :install, forgotten_command_line_options(:without => "emo")
expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
end
end
@@ -339,7 +339,7 @@ RSpec.describe "bundle install with groups" do
before(:each) do
build_repo2
system_gems "rack-0.9.1" do
- install_gemfile <<-G, :without => :rack
+ install_gemfile <<-G, forgotten_command_line_options(:without => "rack")
source "file://#{gem_repo2}"
gem "rack"
diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb
index 0f1a210433..85a17f35a8 100644
--- a/spec/install/gems/compact_index_spec.rb
+++ b/spec/install/gems/compact_index_spec.rb
@@ -174,7 +174,7 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "falls back when the user's home directory does not exist or is not writable" do
- ENV["HOME"] = nil
+ ENV["HOME"] = tmp("missing_home").to_s
gemfile <<-G
source "#{source_uri}"
diff --git a/spec/install/gems/standalone_spec.rb b/spec/install/gems/standalone_spec.rb
index 8899272393..5c5a2a01d4 100644
--- a/spec/install/gems/standalone_spec.rb
+++ b/spec/install/gems/standalone_spec.rb
@@ -50,10 +50,11 @@ RSpec.shared_examples "bundle install --standalone" do
describe "with simple gems" do
before do
- install_gemfile <<-G, :standalone => true
+ gemfile <<-G
source "file://#{gem_repo1}"
gem "rails"
G
+ bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true)
end
let(:expected_gems) do
@@ -68,7 +69,7 @@ RSpec.shared_examples "bundle install --standalone" do
describe "with gems with native extension" do
before do
- install_gemfile <<-G, :standalone => true
+ install_gemfile <<-G, forgotten_command_line_options(:path => "bundle").merge(:standalone => true)
source "file://#{gem_repo1}"
gem "very_simple_binary"
G
@@ -100,7 +101,7 @@ RSpec.shared_examples "bundle install --standalone" do
end
G
end
- install_gemfile <<-G, :standalone => true
+ install_gemfile <<-G, forgotten_command_line_options(:path => "bundle").merge(:standalone => true)
gem "bar", :git => "#{lib_path("bar-1.0")}"
G
end
@@ -115,11 +116,12 @@ RSpec.shared_examples "bundle install --standalone" do
before do
build_git "devise", "1.0"
- install_gemfile <<-G, :standalone => true
+ gemfile <<-G
source "file://#{gem_repo1}"
gem "rails"
gem "devise", :git => "#{lib_path("devise-1.0")}"
G
+ bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true)
end
let(:expected_gems) do
@@ -137,7 +139,7 @@ RSpec.shared_examples "bundle install --standalone" do
before do
build_git "devise", "1.0"
- install_gemfile <<-G, :standalone => true
+ gemfile <<-G
source "file://#{gem_repo1}"
gem "rails"
@@ -146,6 +148,7 @@ RSpec.shared_examples "bundle install --standalone" do
gem "rack-test"
end
G
+ bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true)
end
let(:expected_gems) do
@@ -158,7 +161,7 @@ RSpec.shared_examples "bundle install --standalone" do
include_examples "common functionality"
it "allows creating a standalone file with limited groups" do
- bundle "install --standalone default"
+ bundle! "install", forgotten_command_line_options(:path => "bundle").merge(:standalone => "default")
Dir.chdir(bundled_app) do
load_error_ruby <<-RUBY, "spec", :no_lib => true
@@ -176,7 +179,7 @@ RSpec.shared_examples "bundle install --standalone" do
end
it "allows --without to limit the groups used in a standalone" do
- bundle "install --standalone --without test"
+ bundle! :install, forgotten_command_line_options(:path => "bundle", :without => "test").merge(:standalone => true)
Dir.chdir(bundled_app) do
load_error_ruby <<-RUBY, "spec", :no_lib => true
@@ -194,7 +197,7 @@ RSpec.shared_examples "bundle install --standalone" do
end
it "allows --path to change the location of the standalone bundle" do
- bundle "install --standalone --path path/to/bundle"
+ bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true)
Dir.chdir(bundled_app) do
ruby <<-RUBY, :no_lib => true
@@ -210,8 +213,8 @@ RSpec.shared_examples "bundle install --standalone" do
end
it "allows remembered --without to limit the groups used in a standalone" do
- bundle "install --without test"
- bundle "install --standalone"
+ bundle! :install, forgotten_command_line_options(:without => "test")
+ bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true)
Dir.chdir(bundled_app) do
load_error_ruby <<-RUBY, "spec", :no_lib => true
@@ -238,7 +241,7 @@ RSpec.shared_examples "bundle install --standalone" do
source "#{source_uri}"
gem "rails"
G
- bundle "install --standalone", :artifice => "endpoint"
+ bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true, :artifice => "endpoint")
end
let(:expected_gems) do
@@ -254,10 +257,11 @@ RSpec.shared_examples "bundle install --standalone" do
describe "with --binstubs" do
before do
- install_gemfile <<-G, :standalone => true, :binstubs => true
+ gemfile <<-G
source "file://#{gem_repo1}"
gem "rails"
G
+ bundle! :install, forgotten_command_line_options(:path => "bundle").merge(:standalone => true, :binstubs => true)
end
let(:expected_gems) do
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index 206b59c26e..4b723933d5 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -13,8 +13,8 @@ RSpec.describe "bundle install" do
G
end
- it "does not use available system gems with bundle --path vendor/bundle" do
- bundle "install --path vendor/bundle"
+ it "does not use available system gems with bundle --path vendor/bundle", :bundler => "< 2" do
+ bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -41,7 +41,7 @@ RSpec.describe "bundle install" do
expect(exitstatus).to eq(15) if exitstatus
end
- it "remembers to disable system gems after the first time with bundle --path vendor/bundle" do
+ it "remembers to disable system gems after the first time with bundle --path vendor/bundle", :bundler => "< 2" do
bundle "install --path vendor/bundle"
FileUtils.rm_rf bundled_app("vendor")
bundle "install"
@@ -74,7 +74,7 @@ RSpec.describe "bundle install" do
[:env, :global].each do |type|
it "installs gems to a path if one is specified" do
set_bundle_path(type, bundled_app("vendor2").to_s)
- bundle "install --path vendor/bundle"
+ bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
expect(bundled_app("vendor2")).not_to be_directory
@@ -113,7 +113,7 @@ RSpec.describe "bundle install" do
end
it "sets BUNDLE_PATH as the first argument to bundle install" do
- bundle "install --path ./vendor/bundle"
+ bundle! :install, forgotten_command_line_options(:path => "./vendor/bundle")
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
expect(the_bundle).to include_gems "rack 1.0.0"
@@ -122,7 +122,7 @@ RSpec.describe "bundle install" do
it "disables system gems when passing a path to install" do
# This is so that vendored gems can be distributed to others
build_gem "rack", "1.1.0", :to_system => true
- bundle "install --path ./vendor/bundle"
+ bundle! :install, forgotten_command_line_options(:path => "./vendor/bundle")
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
expect(the_bundle).to include_gems "rack 1.0.0"
@@ -138,7 +138,7 @@ RSpec.describe "bundle install" do
gem "very_simple_binary"
G
- bundle "install --path ./vendor/bundle"
+ bundle! :install, forgotten_command_line_options(:path => "./vendor/bundle")
expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory
expect(vendored_gems("extensions")).to be_directory
@@ -149,7 +149,7 @@ RSpec.describe "bundle install" do
run "require 'very_simple_binary_c'"
expect(err).to include("Bundler::GemNotFound")
- bundle "install --path ./vendor/bundle"
+ bundle :install, forgotten_command_line_options(:path => "./vendor/bundle")
expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory
expect(vendored_gems("extensions")).to be_directory
diff --git a/spec/install/post_bundle_message_spec.rb b/spec/install/post_bundle_message_spec.rb
index bc700b5c4b..df3faa9457 100644
--- a/spec/install/post_bundle_message_spec.rb
+++ b/spec/install/post_bundle_message_spec.rb
@@ -146,8 +146,8 @@ The source does not contain any versions of 'not-a-gem'
end
it "with --without one group" do
- bundle "install --without emo"
- bundle :install
+ bundle! :install, forgotten_command_line_options(:without => "emo")
+ bundle! :install
expect(out).to include(bundle_show_message)
expect(out).to include("Gems in the group emo were not installed")
expect(out).to include(bundle_complete_message)
@@ -155,15 +155,15 @@ The source does not contain any versions of 'not-a-gem'
end
it "with --without two groups" do
- bundle "install --without emo test"
- bundle :install
+ bundle! :install, forgotten_command_line_options(:without => "emo test")
+ bundle! :install
expect(out).to include(bundle_show_message)
expect(out).to include("Gems in the groups emo and test were not installed")
expect(out).to include(bundle_complete_message)
end
it "with --without more groups" do
- bundle "install --without emo obama test"
+ bundle! :install, forgotten_command_line_options(:without => "emo obama test")
bundle :install
expect(out).to include(bundle_show_message)
expect(out).to include("Gems in the groups emo, obama and test were not installed")
@@ -179,21 +179,21 @@ The source does not contain any versions of 'not-a-gem'
end
it "with --without one group" do
- bundle! :install, :without => :emo
+ bundle! :install, forgotten_command_line_options(:without => "emo")
bundle! :update, :all => bundle_update_requires_all?
expect(out).to include("Gems in the group emo were not installed")
expect(out).to include(bundle_updated_message)
end
it "with --without two groups" do
- bundle! "install --without emo test"
+ bundle! :install, forgotten_command_line_options(:without => "emo test")
bundle! :update, :all => bundle_update_requires_all?
expect(out).to include("Gems in the groups emo and test were not installed")
expect(out).to include(bundle_updated_message)
end
it "with --without more groups" do
- bundle! "install --without emo obama test"
+ bundle! :install, forgotten_command_line_options(:without => "emo obama test")
bundle! :update, :all => bundle_update_requires_all?
expect(out).to include("Gems in the groups emo, obama and test were not installed")
expect(out).to include(bundle_updated_message)
diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb
index d1b415395a..14cf94bdb7 100644
--- a/spec/lock/lockfile_spec.rb
+++ b/spec/lock/lockfile_spec.rb
@@ -1239,7 +1239,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do
gem "omg", :git => "#{lib_path("omg")}", :branch => 'master'
G
- bundle "install --path vendor"
+ bundle! :install, forgotten_command_line_options(:path => "vendor")
expect(the_bundle).to include_gems "omg 1.0"
# Create a Gemfile.lock that has duplicate GIT sections
diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb
index ae3b429b9d..04c166174a 100644
--- a/spec/runtime/executable_spec.rb
+++ b/spec/runtime/executable_spec.rb
@@ -116,7 +116,7 @@ RSpec.describe "Running bin/* commands" do
gem "activesupport"
G
- bundle "install --binstubs"
+ bundle! :install, forgotten_command_line_options([:binstubs, :bin] => "bin")
gemfile <<-G
source "file://#{gem_repo1}"
@@ -135,7 +135,7 @@ RSpec.describe "Running bin/* commands" do
gem "rack"
G
- bundle "install --binstubs bin/"
+ bundle! :install, forgotten_command_line_options([:binstubs, :bin] => "bin")
File.open(bundled_app("bin/rackup"), "wb") do |file|
file.print "OMG"
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index c6b2d1ff3f..3f95399c2b 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -495,13 +495,13 @@ RSpec.describe "Bundler.setup" do
end
it "works even when the cache directory has been deleted" do
- bundle "install --path vendor/bundle"
+ bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
FileUtils.rm_rf vendored_gems("cache")
expect(the_bundle).to include_gems "rack 1.0.0"
end
it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do
- bundle "install --path vendor/bundle"
+ bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
with_read_only("**/*") do
expect(the_bundle).to include_gems "rack 1.0.0"
@@ -603,7 +603,7 @@ RSpec.describe "Bundler.setup" do
describe "when excluding groups" do
it "doesn't change the resolve if --without is used" do
- install_gemfile <<-G, :without => :rails
+ install_gemfile <<-G, forgotten_command_line_options(:without => :rails)
source "file://#{gem_repo1}"
gem "activesupport"
@@ -618,7 +618,7 @@ RSpec.describe "Bundler.setup" do
end
it "remembers --without and does not bail on bare Bundler.setup" do
- install_gemfile <<-G, :without => :rails
+ install_gemfile <<-G, forgotten_command_line_options(:without => :rails)
source "file://#{gem_repo1}"
gem "activesupport"
@@ -633,7 +633,7 @@ RSpec.describe "Bundler.setup" do
end
it "remembers --without and does not include groups passed to Bundler.setup" do
- install_gemfile <<-G, :without => :rails
+ install_gemfile <<-G, forgotten_command_line_options(:without => :rails)
source "file://#{gem_repo1}"
gem "activesupport"
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 8a81053da7..312e47d546 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -51,7 +51,7 @@ module Spec
end
def bundle_update_requires_all?
- !Bundler::VERSION.start_with?("1.")
+ Bundler::VERSION.start_with?("1.") ? nil : true
end
def in_app_root(&blk)
@@ -99,7 +99,8 @@ module Spec
with_sudo = options.delete(:sudo)
sudo = with_sudo == :preserve_env ? "sudo -E" : "sudo" if with_sudo
- options["no-color"] = true unless options.key?("no-color") || cmd.to_s =~ /\A(e|ex|exe|exec|conf|confi|config)(\s|\z)/
+ no_color = options.delete("no-color") { cmd.to_s !~ /\A(e|ex|exe|exec|conf|confi|config)(\s|\z)/ }
+ options["no-color"] = true if no_color
bundle_bin = options.delete("bundle_bin") || File.expand_path("../../../exe/bundle", __FILE__)
@@ -134,7 +135,16 @@ module Spec
env = env.map {|k, v| "#{k}='#{v}'" }.join(" ")
args = options.map do |k, v|
- v == true ? " --#{k}" : " --#{k} #{v}" if v
+ case v
+ when nil
+ next
+ when true
+ " --#{k}"
+ when false
+ " --no-#{k}"
+ else
+ " --#{k} #{v}"
+ end
end.join
cmd = "#{env} #{sudo} #{Gem.ruby} #{load_path_str} #{requires_str} #{bundle_bin} #{cmd}#{args}"
@@ -142,6 +152,24 @@ module Spec
end
bang :bundle
+ def forgotten_command_line_options(options)
+ remembered = Bundler::VERSION.split(".", 2).first == "1"
+ options = options.map do |k, v|
+ k = Array(k)[remembered ? 0 : -1]
+ v = '""' if v && v.to_s.empty?
+ [k, v]
+ end
+ return Hash[options] if remembered
+ options.each do |k, v|
+ if v.nil?
+ bundle! "config --delete #{k}"
+ else
+ bundle! "config --local #{k} #{v}"
+ end
+ end
+ {}
+ end
+
def bundler(cmd, options = {})
options["bundle_bin"] = File.expand_path("../../../exe/bundler", __FILE__)
bundle(cmd, options)