Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 74 additions & 1 deletion spec/install/gems/sources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
end
end

context "with an indirect dependency" do
context "when a pinned gem has an indirect dependency" do
before do
build_repo gem_repo3 do
build_gem "depends_on_rack", "1.0.1" do |s|
Expand Down Expand Up @@ -266,6 +266,79 @@
end
end

context "when a top-level gem has an indirect dependency" do
before do
build_repo gem_repo2 do
build_gem "depends_on_rack", "1.0.1" do |s|
s.add_dependency "rack"
end
end

build_repo gem_repo3 do
build_gem "unrelated_gem", "1.0.0"
end

gemfile <<-G
source "file://#{gem_repo2}"

gem "depends_on_rack"

source "file://#{gem_repo3}" do
gem "unrelated_gem"
end
G
end

context "and the dependency is only in the top-level source" do
before do
update_repo gem_repo2 do
build_gem "rack", "1.0.0"
end
end

it "installs all gems without warning" do
bundle :install
expect(out).not_to include("Warning")
should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0")
end
end

context "and the dependency is only in a pinned source" do
before do
update_repo gem_repo3 do
build_gem "rack", "1.0.0" do |s|
s.write "lib/rack.rb", "RACK = 'FAIL'"
end
end
end

it "does not find the dependency" do
bundle :install
expect(out).to include("Could not find gem 'rack (>= 0) ruby'")
end
end

context "and the dependency is in both the top-level and a pinned source" do
before do
update_repo gem_repo2 do
build_gem "rack", "1.0.0"
end

update_repo gem_repo3 do
build_gem "rack", "1.0.0" do |s|
s.write "lib/rack.rb", "RACK = 'FAIL'"
end
end
end

it "installs the dependency from the top-level source without warning" do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TimMoore shouldn't it install from the pinned source here rather than the top-level source?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this case, I think, because the thing that depends on it comes from the top-level source.

but then I don't know what should happen when you have multiple gems from multiple different sources that depend on a third gem

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, ended up getting it working :D

bundle :install
expect(out).not_to include("Warning")
should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0")
end
end
end

context "with a gem that is only found in the wrong source" do
before do
build_repo gem_repo3 do
Expand Down