Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

[LazySpecification] Select the best platform match when materializing #5008

Merged
merged 4 commits into from
Sep 27, 2016
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion lib/bundler/lazy_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ def to_lock

def __materialize__
search_object = Bundler.settings[:specific_platform] ? self : Dependency.new(name, version)
@specification = source.specs.search(search_object).last
@specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
source.gemspec.tap {|s| s.source = source }
else
source.specs.search(search_object).last
end
end

def respond_to?(*args)
Expand Down
33 changes: 33 additions & 0 deletions spec/install/gemfile/gemspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,37 @@
end
end
end

context "with multiple platforms" do
before do
build_lib("foo", :path => tmp.join("foo")) do |s|
s.version = "1.0.0"
s.add_development_dependency "rack"
s.write "foo-universal-java.gemspec", build_spec("foo", "1.0.0", "universal-java") {|sj| sj.runtime "rack", "1.0.0" }.first.to_ruby
end
end

it "installs the ruby platform gemspec" do
simulate_platform "ruby"

install_gemfile! <<-G
source "file://#{gem_repo1}"
gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
G

expect(the_bundle).to include_gems "foo 1.0.0", "rack 1.0.0"
end

it "installs the ruby platform gemspec and skips dev deps with --without development" do
simulate_platform "ruby"

install_gemfile! <<-G, :without => "development"
source "file://#{gem_repo1}"
gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
G

expect(the_bundle).to include_gem "foo 1.0.0"
expect(the_bundle).not_to include_gem "rack"
end
end
end