diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-07-21 14:21:56 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-07-23 12:51:36 -0500 |
commit | dcd9963876f1405a19671a6bd34d42a6add9e16a (patch) | |
tree | 1cfee962063fdf074972211b6f0fe99ae329bf7b | |
parent | 07fedc3f9ee972d5da43f8a77a162bf2c9ca4b1b (diff) | |
download | bundler-dcd9963876f1405a19671a6bd34d42a6add9e16a.tar.gz |
Update the specs for the default bundle path being ./.bundle
-rw-r--r-- | lib/bundler/cli/clean.rb | 9 | ||||
-rw-r--r-- | lib/bundler/cli/install.rb | 2 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source/git.rb | 4 | ||||
-rw-r--r-- | spec/cache/gems_spec.rb | 27 | ||||
-rw-r--r-- | spec/commands/check_spec.rb | 8 | ||||
-rw-r--r-- | spec/commands/clean_spec.rb | 25 | ||||
-rw-r--r-- | spec/install/bundler_spec.rb | 20 | ||||
-rw-r--r-- | spec/install/post_bundle_message_spec.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers.rb | 11 |
10 files changed, 75 insertions, 35 deletions
diff --git a/lib/bundler/cli/clean.rb b/lib/bundler/cli/clean.rb index 71b2969192..4a407fbae7 100644 --- a/lib/bundler/cli/clean.rb +++ b/lib/bundler/cli/clean.rb @@ -16,11 +16,10 @@ module Bundler protected def require_path_or_force - if Bundler.use_system_gems? && !options[:force] - 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`." - end + return unless Bundler.use_system_gems? && !options[:force] + 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`." end end end diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 53db0026f8..771ff6f5dc 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -196,6 +196,8 @@ module Bundler Bundler.settings.set_command_option :without, options[:without] - options[:with] Bundler.settings.set_command_option :with, options[:with] end + + options[:force] = options[:redownload] end def warn_ambiguous_gems diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 78dcf89160..ffdac1f979 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -236,7 +236,7 @@ module Bundler def base_path path = explicit_path - path ||= ".bundle" if default_install_uses_path + path ||= ".bundle" unless use_system_gems? path ||= Bundler.rubygems.gem_dir path end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 020cf74766..eb605771f4 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -172,13 +172,11 @@ module Bundler print_using_message "Using #{version_message(spec)} from #{self}" - if requires_checkout? && !@copied && !force + if (requires_checkout? && !@copied) || force Bundler.ui.debug " * Checking out revision: #{ref}" git_proxy.copy_to(install_path, submodules) serialize_gemspecs_in(install_path) @copied = true - elsif force - git_proxy.copy_to(install_path, submodules) end generate_bin_options = { :disable_extensions => !Bundler.rubygems.spec_missing_extensions?(spec), :build_args => options[:build_args] } diff --git a/spec/cache/gems_spec.rb b/spec/cache/gems_spec.rb index aef4c5f05a..4a0b953830 100644 --- a/spec/cache/gems_spec.rb +++ b/spec/cache/gems_spec.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true RSpec.describe "bundle cache" do - describe "when there are only gemsources" do + shared_examples_for "when there are only gemsources" do before :each do gemfile <<-G gem 'rack' G - system_gems "rack-1.0.0" - bundle :cache + system_gems "rack-1.0.0", :path => :bundle_path + bundle! :cache end it "copies the .gem file to vendor/cache" do @@ -27,7 +27,7 @@ RSpec.describe "bundle cache" do end it "uses the cache as a source when installing gems with --local" do - system_gems [] + system_gems [], :path => :bundle_path bundle "install --local" expect(the_bundle).to include_gems("rack 1.0.0") @@ -46,7 +46,7 @@ RSpec.describe "bundle cache" do end it "does not reinstall gems from the cache if they exist in the bundle" do - system_gems "rack-1.0.0" + system_gems "rack-1.0.0", :path => :bundle_path gemfile <<-G gem "rack" @@ -56,7 +56,7 @@ RSpec.describe "bundle cache" do s.write "lib/rack.rb", "RACK = 'FAIL'" end - bundle "install --local" + bundle! :install, :local => true expect(the_bundle).to include_gems("rack 1.0.0") end @@ -73,6 +73,16 @@ RSpec.describe "bundle cache" do end end + context "using system gems" do + before { bundle! "config path.system true" } + it_behaves_like "when there are only gemsources" + end + + context "installing into a local path" do + before { bundle! "config path ./.bundle" } + it_behaves_like "when there are only gemsources" + end + describe "when there is a built-in gem", :ruby => "2.0" do before :each do build_repo2 do @@ -86,7 +96,8 @@ RSpec.describe "bundle cache" do FileUtils.rm("#{system_gem_path}/cache/builtin_gem-1.0.2.gem") end - it "uses builtin gems" do + it "uses builtin gems when installing to system gems" do + bundle! "config path.system true" install_gemfile %(gem 'builtin_gem', '1.0.2') expect(the_bundle).to include_gems("builtin_gem 1.0.2") end @@ -118,6 +129,8 @@ RSpec.describe "bundle cache" do end it "errors if the builtin gem isn't available to cache" do + bundle! "config path.system true" + install_gemfile <<-G gem 'builtin_gem', '1.0.2' G diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb index 3c25a8e8c8..f2af446fbf 100644 --- a/spec/commands/check_spec.rb +++ b/spec/commands/check_spec.rb @@ -137,8 +137,6 @@ RSpec.describe "bundle check" do end it "ignores missing gems restricted to other platforms" do - system_gems "rack-1.0.0" - gemfile <<-G source "file://#{gem_repo1}" gem "rack" @@ -147,6 +145,8 @@ RSpec.describe "bundle check" do end G + system_gems "rack-1.0.0", :path => :bundle_path + lockfile <<-G GEM remote: file:#{gem_repo1}/ @@ -168,8 +168,6 @@ RSpec.describe "bundle check" do end it "works with env conditionals" do - system_gems "rack-1.0.0" - gemfile <<-G source "file://#{gem_repo1}" gem "rack" @@ -178,6 +176,8 @@ RSpec.describe "bundle check" do end G + system_gems "rack-1.0.0", :path => :bundle_path + lockfile <<-G GEM remote: file:#{gem_repo1}/ diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index e1febcbd4e..387098cdc7 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -275,6 +275,7 @@ RSpec.describe "bundle clean" do end it "displays an error when used without --path" do + bundle! "config path.system true" install_gemfile <<-G source "file://#{gem_repo1}" @@ -318,24 +319,27 @@ RSpec.describe "bundle clean" do end it "does not call clean automatically when using system gems" do - gemfile <<-G + bundle! "config path.system true" + + bundle! :config + + install_gemfile! <<-G source "file://#{gem_repo1}" gem "thin" gem "rack" G - bundle :install - gemfile <<-G + bundle! "info thin" + + install_gemfile! <<-G source "file://#{gem_repo1}" gem "rack" G - bundle :install - sys_exec "gem list" - expect(out).to include("rack (1.0.0)") - expect(out).to include("thin (1.0)") + sys_exec! "gem list" + expect(out).to include("rack (1.0.0)").and include("thin (1.0)") end it "--clean should override the bundle setting on install", :bundler => "< 2" do @@ -416,6 +420,8 @@ RSpec.describe "bundle clean" do end it "does not clean on bundle update when using --system" do + bundle! "config path.system true" + build_repo2 gemfile <<-G @@ -435,6 +441,8 @@ RSpec.describe "bundle clean" do end it "cleans system gems when --force is used" do + bundle! "config path.system true" + gemfile <<-G source "file://#{gem_repo1}" @@ -458,6 +466,7 @@ RSpec.describe "bundle clean" do end describe "when missing permissions" do + before { ENV["BUNDLE_PATH__SYSTEM"] = "true" } after do FileUtils.chmod(0o755, default_bundle_path("cache")) end @@ -522,6 +531,8 @@ RSpec.describe "bundle clean" do end it "when using --force on system gems, it doesn't remove binaries" do + bundle! "config path.system true" + build_repo2 update_repo2 do build_gem "bindir" do |s| diff --git a/spec/install/bundler_spec.rb b/spec/install/bundler_spec.rb index b59096e1ea..fd7d44d664 100644 --- a/spec/install/bundler_spec.rb +++ b/spec/install/bundler_spec.rb @@ -125,15 +125,29 @@ RSpec.describe "bundle install" do expect(last_command.bundler_err).to include(nice_error) end - it "can install dependencies with newer bundler version" do - install_gemfile <<-G + it "can install dependencies with newer bundler version with system gems" do + bundle! "config path.system true" + install_gemfile! <<-G + source "file://#{gem_repo2}" + gem "rails", "3.0" + G + + simulate_bundler_version "99999999.99.1" + + bundle! "check" + expect(out).to include("The Gemfile's dependencies are satisfied") + end + + it "can install dependencies with newer bundler version with a local path" do + bundle! "config path .bundle" + install_gemfile! <<-G source "file://#{gem_repo2}" gem "rails", "3.0" G simulate_bundler_version "99999999.99.1" - bundle "check" + bundle! "check" expect(out).to include("The Gemfile's dependencies are satisfied") end diff --git a/spec/install/post_bundle_message_spec.rb b/spec/install/post_bundle_message_spec.rb index 36d578cb95..08b70f9512 100644 --- a/spec/install/post_bundle_message_spec.rb +++ b/spec/install/post_bundle_message_spec.rb @@ -14,7 +14,7 @@ RSpec.describe "post bundle message" do end let(:bundle_show_message) { "Use `bundle info [gemname]` to see where a bundled gem is installed." } - let(:bundle_deployment_message) { "Bundled gems are installed into ./vendor" } + let(:bundle_deployment_message) { "Bundled gems are installed into `./vendor`" } let(:bundle_complete_message) { "Bundle complete!" } let(:bundle_updated_message) { "Bundle updated!" } let(:installed_gems_stats) { "4 Gemfile dependencies, 5 gems now installed." } diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 312e47d546..be187d5332 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -360,16 +360,19 @@ module Spec end def system_gems(*gems) + opts = gems.last.is_a?(Hash) ? gems.last : {} + path = opts.fetch(:path, system_gem_path) + path = ruby!("require 'bundler'; puts Bundler.bundle_path") if path == :bundle_path gems = gems.flatten - FileUtils.rm_rf(system_gem_path) - FileUtils.mkdir_p(system_gem_path) + FileUtils.rm_rf(path) + FileUtils.mkdir_p(path) Gem.clear_paths env_backup = ENV.to_hash - ENV["GEM_HOME"] = system_gem_path.to_s - ENV["GEM_PATH"] = system_gem_path.to_s + ENV["GEM_HOME"] = path.to_s + ENV["GEM_PATH"] = path.to_s ENV["BUNDLER_ORIG_GEM_PATH"] = nil install_gems(*gems) |