aboutsummaryrefslogtreecommitdiffstats
path: root/spec/install/gems/sources_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/install/gems/sources_spec.rb')
-rw-r--r--spec/install/gems/sources_spec.rb61
1 files changed, 47 insertions, 14 deletions
diff --git a/spec/install/gems/sources_spec.rb b/spec/install/gems/sources_spec.rb
index 946eb9d2..632a7ac3 100644
--- a/spec/install/gems/sources_spec.rb
+++ b/spec/install/gems/sources_spec.rb
@@ -4,24 +4,57 @@ describe "bundle install with gems on multiple sources" do
# repo1 is built automatically before all of the specs run
# it contains rack-obama 1.0.0 and rack 0.9.1 & 1.0.0 amongst other gems
- it "searches gem sources from last to first" do
- # Oh no! Someone evil is trying to hijack rack :(
- # need this to be broken to check for correct source ordering
- build_repo gem_repo3 do
- build_gem "rack", "1.0.0" do |s|
- s.write "lib/rack.rb", "RACK = 'FAIL'"
+ context "without source affinity" do
+ before do
+ # Oh no! Someone evil is trying to hijack rack :(
+ # need this to be broken to check for correct source ordering
+ build_repo gem_repo3 do
+ build_gem "rack", repo3_rack_version do |s|
+ s.write "lib/rack.rb", "RACK = 'FAIL'"
+ end
end
end
- gemfile <<-G
- source "file://#{gem_repo3}"
- source "file://#{gem_repo1}"
- gem "rack-obama"
- gem "rack"
- G
+ context "when the same version of the same gem is in multiple sources" do
+ let(:repo3_rack_version) { "1.0.0" }
- bundle :install
+ before do
+ gemfile <<-G
+ source "file://#{gem_repo3}"
+ source "file://#{gem_repo1}"
+ gem "rack-obama"
+ gem "rack"
+ G
+ end
+
+ it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first" do
+ bundle :install
+
+ expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
+ expect(out).to include("Installed from: file:#{gem_repo1}")
+ should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
+ end
+ end
+
+ context "when different versions of the same gem are in multiple sources" do
+ let(:repo3_rack_version) { "1.2" }
- should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
+ before do
+ gemfile <<-G
+ source "file://#{gem_repo3}"
+ source "file://#{gem_repo1}"
+ gem "rack-obama"
+ gem "rack", "1.0.0" # force it to install the working version in repo1
+ G
+ end
+
+ it "warns about ambiguous gems, but installs anyway" do
+ bundle :install
+
+ expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
+ expect(out).to include("Installed from: file:#{gem_repo1}")
+ should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
+ end
+ end
end
end