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

Commit

Permalink
Auto merge of #5008 - bundler:seg-lazy-specification-materialize-plat…
Browse files Browse the repository at this point in the history
…form, r=indirect

[LazySpecification] Select the best platform match when materializing

Closes #5006

This was not fun to track down >.<
  • Loading branch information
homu authored and segiddins committed Sep 30, 2016
1 parent 1fa8e94 commit 2f22a84
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/bundler/lazy_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def to_lock
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)
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

0 comments on commit 2f22a84

Please sign in to comment.