summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-09-28 05:54:38 +0900
committerHomu <homu@barosl.com>2016-09-28 05:54:38 +0900
commitc3b69668529ff9bbdd923f89fd0758418998dc37 (patch)
tree028572787f1b356ffef3fae2e731d790459ddb2b
parent30a161ebf93ecc268166515df52d62d00ff32c32 (diff)
parentea86a1902ea34ddb10f4bc8cc96f58e8a0a7e946 (diff)
downloadbundler-c3b69668529ff9bbdd923f89fd0758418998dc37.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.rb6
-rw-r--r--spec/install/gemfile/gemspec_spec.rb33
2 files changed, 38 insertions, 1 deletions
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index 0b667f7dbe..13e7f5fc3c 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -70,7 +70,11 @@ module Bundler
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)
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