diff options
author | Carl Lerche <me@carllerche.com> | 2012-02-08 09:12:40 -0800 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2012-02-08 09:12:40 -0800 |
commit | 2231309e0e6289ead11d2c2815bb4ee232a5e2e9 (patch) | |
tree | 03bd19b1d05a2e8084dad2bf5e1f21bae5ef8366 | |
parent | 5b16789e6707133af0390a2dd878930f82022a34 (diff) | |
download | bundler-2231309e0e6289ead11d2c2815bb4ee232a5e2e9.tar.gz |
Apply Gem::Dependency#type mismatches fix
-rw-r--r-- | lib/bundler/definition.rb | 17 | ||||
-rw-r--r-- | spec/install/gemspec_spec.rb | 21 |
2 files changed, 38 insertions, 0 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 82e1aa3e27..2bc7dd7eb0 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -70,6 +70,23 @@ module Bundler converge_sources converge_dependencies + + fixup_dependency_types! + end + + def fixup_dependency_types! + # XXX This is a temporary workaround for a bug when using rubygems 1.8.15 + # where Gem::Dependency#== matches Gem::Dependency#type. As the lockfile + # doesn't carry a notion of the dependency type, if you use + # add_development_dependency in a gemspec that's loaded with the gemspec + # directive, the lockfile dependencies and resolved dependencies end up + # with a mismatch on #type. + # Test coverage to catch a regression on this is in gemspec_spec.rb + @dependencies.each do |d| + if ld = @locked_deps.find { |l| l.name == d.name } + ld.instance_variable_set(:@type, d.type) + end + end end def resolve_with_cache! diff --git a/spec/install/gemspec_spec.rb b/spec/install/gemspec_spec.rb index dce8b16c69..15c22b2d29 100644 --- a/spec/install/gemspec_spec.rb +++ b/spec/install/gemspec_spec.rb @@ -110,6 +110,27 @@ describe "bundle install from an existing gemspec" do should_be_installed "bar-dev 1.0.0", :groups => :dev end + it "should match a lockfile even if the gemspec defines development dependencies" do + build_lib("foo", :path => tmp.join("foo")) do |s| + s.write("Gemfile", "source 'file://#{gem_repo1}'\ngemspec") + s.add_dependency "actionpack", "=2.3.2" + s.add_development_dependency "rake", '=0.8.7' + end + + Dir.chdir(tmp.join("foo")) do + bundle "install" + # This should really be able to rely on $stderr, but, it's not written + # right, so we can't. In fact, this is a bug negation test, and so it'll + # ghost pass in future, and will only catch a regression if the message + # doesn't change. Exit codes should be used correctly (they can be more + # than just 0 and 1). + output = bundle("install --deployment") + output.should_not match(/You have added to the Gemfile/) + output.should_not match(/You have deleted from the Gemfile/) + output.should_not match(/install in deployment mode after changing/) + end + end + it "should evaluate the gemspec in its directory" do build_lib("foo", :path => tmp.join("foo")) File.open(tmp.join("foo/foo.gemspec"), "w") do |s| |