diff options
author | Homu <homu@barosl.com> | 2016-09-28 05:54:38 +0900 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-09-30 12:27:06 -0500 |
commit | 2f22a8405c9ce290ed5464312cb100eeef3ad3b9 (patch) | |
tree | 192c2cb30f244f77b7340860b2ff3df97004151c | |
parent | 1fa8e94a32d4e71b9dcfa22171c2a7282e03322e (diff) | |
download | bundler-2f22a8405c9ce290ed5464312cb100eeef3ad3b9.tar.gz |
Auto merge of #5008 - bundler:seg-lazy-specification-materialize-platform, r=indirect
[LazySpecification] Select the best platform match when materializing
Closes #5006
This was not fun to track down >.<
-rw-r--r-- | lib/bundler/lazy_specification.rb | 6 | ||||
-rw-r--r-- | spec/install/gemfile/gemspec_spec.rb | 33 |
2 files changed, 38 insertions, 1 deletions
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 36ff5c59ed..83ab9ef967 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -55,7 +55,11 @@ module Bundler end def __materialize__ - @specification = source.specs.search(Gem::Dependency.new(name, version)).last + @specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name + source.gemspec.tap {|s| s.source = source } + else + source.specs.search(Gem::Dependency.new(name, version)).last + end end def respond_to?(*args) diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb index 9a6bd5f1e8..698756525c 100644 --- a/spec/install/gemfile/gemspec_spec.rb +++ b/spec/install/gemfile/gemspec_spec.rb @@ -409,4 +409,37 @@ describe "bundle install from an existing gemspec" do 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 |