summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2015-06-23 21:32:46 -0700
committerAndre Arko <andre@arko.net>2015-06-23 21:32:46 -0700
commit13c445680f65293ee50f11718e8a86bfa87abd2e (patch)
tree477907992cf044fd631629298edfe8219c3f75df
parente5d936e7c6265f8f8dcdd7fcc4b93aeb013acbd1 (diff)
parent08be389291ea70ca07605aa7dad0b10b98963aab (diff)
downloadbundler-13c445680f65293ee50f11718e8a86bfa87abd2e.tar.gz
Merge pull request #3743
from karlo57/3715-install-force-should-delete-existing-gems-before-install Includes tests for --force and a fix for trying to reinstall Bundler
-rw-r--r--lib/bundler/source/rubygems.rb6
-rw-r--r--spec/install/force_spec.rb28
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 7b40860db9..bb06830f3e 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -98,7 +98,7 @@ module Bundler
end
end
- if installed_specs[spec].any? && !force
+ if (installed_specs[spec].any? && !force) || bundler?(spec)
Bundler.ui.info "Using #{version_message(spec)}"
return nil # no post-install message
end
@@ -413,6 +413,10 @@ module Bundler
spec.loaded_from && spec.loaded_from.include?("specifications/default/")
end
+ def bundler?(spec)
+ spec.name.eql?('bundler')
+ end
+
end
end
end
diff --git a/spec/install/force_spec.rb b/spec/install/force_spec.rb
index 269390994a..fd695bdc0b 100644
--- a/spec/install/force_spec.rb
+++ b/spec/install/force_spec.rb
@@ -7,14 +7,40 @@ describe "bundle install" do
source "file://#{gem_repo1}"
gem "rack"
G
+ end
+ it "re-installs installed gems" do
bundle "install"
+ bundle "install --force"
+
+ expect(out).to include "Installing rack 1.0.0"
+ should_be_installed "rack 1.0.0"
+ expect(exitstatus).to eq(0) if exitstatus
end
- it "re-installs installed gems" do
+ it "overwrites old gem code" do
+ bundle "install"
+ default_bundle_path("gems/rack-1.0.0/lib/rack.rb").open('w'){|f| f.write("blah blah blah") }
bundle "install --force"
+
+ expect(default_bundle_path("gems/rack-1.0.0/lib/rack.rb").open{|f| f.read }).to eq("RACK = '1.0.0'\n")
+ end
+
+ it "doesn't reinstall bundler" do
+ bundle "install"
+ bundle "install --force"
+ expect(out).to_not include "Installing bundler 1.10.4"
+ expect(out).to include "Using bundler 1.10.4"
+ end
+
+ it "works on first bundle install" do
+ bundle "install --force"
+
expect(out).to include "Installing rack 1.0.0"
should_be_installed "rack 1.0.0"
+ expect(exitstatus).to eq(0) if exitstatus
end
+
+
end
end