summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Luis Leal Cardoso Junior <andrehjr@gmail.com>2019-10-25 16:23:12 -0300
committerAndré Luis Leal Cardoso Junior <andrehjr@gmail.com>2019-11-04 15:10:40 -0300
commit293ad80da8939f766fe886c7653903f09b6133d8 (patch)
treea2dcff7e730eb7f29271d2cf0960b156167f3021
parent27a01a5480c97990123a05e8122f8c5b7910e427 (diff)
downloadbundler-293ad80da8939f766fe886c7653903f09b6133d8.tar.gz
Make bundle add caches newly added gems when needed.
-rw-r--r--lib/bundler/cli/add.rb1
-rw-r--r--spec/commands/add_spec.rb9
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/bundler/cli/add.rb b/lib/bundler/cli/add.rb
index 7c6235f17c..07b951f1ef 100644
--- a/lib/bundler/cli/add.rb
+++ b/lib/bundler/cli/add.rb
@@ -21,6 +21,7 @@ module Bundler
def perform_bundle_install
Installer.install(Bundler.root, Bundler.definition)
+ Bundler.load.cache if Bundler.app_cache.exist?
end
def inject_dependencies
diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb
index fdfca5d8f2..35fd43d3d2 100644
--- a/spec/commands/add_spec.rb
+++ b/spec/commands/add_spec.rb
@@ -239,4 +239,13 @@ RSpec.describe "bundle add" do
expect(err).not_to include("You may also need to change the version requirement specified in the Gemfile if it's too restrictive")
end
end
+
+ describe "when a gem is added and cache exists" do
+ it "caches all new dependencies added for the specified gem" do
+ bundle! :cache
+
+ bundle "add 'rack' --version=1.0.0"
+ expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
+ end
+ end
end