summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2010-04-21 17:39:59 -0700
committerAndre Arko <andre@arko.net>2010-04-21 17:39:59 -0700
commitf1a19680452e3003a78b89ecc011a375c68ab258 (patch)
tree1e693dc47b5e93ba429117c305293c361508d544
parent4117623e391baf187c0146805f004a75a2c6cc50 (diff)
downloadbundler-f1a19680452e3003a78b89ecc011a375c68ab258.tar.gz
When Bundler is being bundled, bundle the current version of bundler
-rw-r--r--lib/bundler/resolver.rb11
-rw-r--r--spec/install/gems/simple_case_spec.rb43
-rw-r--r--spec/support/matchers.rb4
3 files changed, 54 insertions, 4 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index a1371bd94b..fddae44470 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -98,8 +98,15 @@ module Bundler
debug { "Requirements:\n" + reqs.map { |r| " #{r.name} (#{r.requirement})"}.join("\n") }
activated = activated.dup
- # Pull off the first requirement so that we can resolve it
- current = reqs.shift
+
+ if reqs.first.name == "bundler" && !activated["bundler"]
+ # activate the current version of bundler before other versions
+ bundler_version = ENV["BUNDLER_VERSION"] || Bundler::VERSION
+ current = Gem::Dependency.new("bundler", bundler_version, reqs.first.type)
+ else
+ # Pull off the first requirement so that we can resolve it
+ current = reqs.shift
+ end
debug { "Attempting:\n #{current.name} (#{current.requirement})"}
diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb
index ed7b94b198..39a12da69e 100644
--- a/spec/install/gems/simple_case_spec.rb
+++ b/spec/install/gems/simple_case_spec.rb
@@ -423,4 +423,47 @@ describe "bundle install with gem sources" do
should_be_installed "rcov 1.0.0"
end
end
+
+ describe "bundler dependencies" do
+ before(:each) do
+ build_repo2 do
+ build_gem "rails", "3.0" do |s|
+ s.add_dependency "bundler", "~>0.9.0"
+ end
+ build_gem "bundler", "0.9.1"
+ build_gem "bundler", Bundler::VERSION
+ end
+ ENV["BUNDLER_VERSION"] = "0.9.1"
+ end
+
+ after(:each) do
+ ENV["BUNDLER_VERSION"] = nil
+ end
+
+ it "are forced to the current bundler version" do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "rails", "3.0"
+ G
+ should_be_installed "bundler 0.9.1"
+ end
+
+ it "are not added if not already present" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+ should_not_be_installed "bundler 0.9.1"
+ end
+
+ it "cause a conflict if explicitly requesting a different version" do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "rails", "3.0"
+ gem "bundler", "0.9.2"
+ G
+ out.should =~ /conflict on: "bundler"/i
+ end
+ end
+
end
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index f3649bbc91..d96190cb9d 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -20,7 +20,7 @@ module Spec
groups = opts[:groups] || []
names.each do |name|
name, version = name.split(/\s+/)
- run "require '#{name}'; puts #{Spec::Builders.constantize(name)}", *groups
+ run "load '#{name}.rb'; puts #{Spec::Builders.constantize(name)}", *groups
Gem::Version.new(out).should == Gem::Version.new(version)
end
end
@@ -36,7 +36,7 @@ module Spec
begin
require '#{name}'
puts #{Spec::Builders.constantize(name)}
- rescue LoadError
+ rescue LoadError, NameError
puts "WIN"
end
R