summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2016-06-06 23:25:09 -0700
committerAndre Arko <andre@arko.net>2016-06-06 23:26:08 -0700
commita85ac3726ed3011b0f4175f915f5a17f21de2b71 (patch)
treef939937b66776e53c23ce69369f60d5ba7eed4ea
parent26e871f8dd099d85a3e876374941c1417fcd9580 (diff)
downloadbundler-aa-implicit-ruby-versions.tar.gz
respect the current ruby when gems conflictaa-implicit-ruby-versions
-rw-r--r--lib/bundler/definition.rb2
-rw-r--r--spec/install/gems/resolving_spec.rb56
2 files changed, 53 insertions, 5 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 413eedc168..b7e77dd084 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -52,7 +52,7 @@ module Bundler
@optional_groups = optional_groups
@remote = false
@specs = nil
- @ruby_version = ruby_version
+ @ruby_version = ruby_version || Bundler::RubyVersion.system
@lockfile_contents = String.new
@locked_bundler_version = nil
diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb
index 68b838f831..cd98c27993 100644
--- a/spec/install/gems/resolving_spec.rb
+++ b/spec/install/gems/resolving_spec.rb
@@ -102,9 +102,9 @@ describe "bundle install with install-time dependencies" do
end
end
- describe "when a required ruby version" do
- context "allows only an older version" do
- it "installs the older version" do
+ describe "when an explicit ruby version" do
+ context "allows only an older gem version" do
+ it "installs the older gem version" do
update_repo gem_repo1 do
build_gem "rack", "9001.0.0" do |s|
s.required_ruby_version = "> 9000"
@@ -122,7 +122,7 @@ describe "bundle install with install-time dependencies" do
end
end
- context "allows no versions" do
+ context "allows no gem versions" do
it "raises an error during resolution" do
update_repo gem_repo1 do
build_gem "require_ruby" do |s|
@@ -152,6 +152,54 @@ describe "bundle install with install-time dependencies" do
end
end
+ describe "when the current ruby version" do
+ context "allows only an older gem version" do
+ it "installs the older gem version" do
+ update_repo gem_repo1 do
+ build_gem "rack", "9001.0.0" do |s|
+ s.required_ruby_version = "> 9000"
+ end
+ end
+
+ install_gemfile <<-G, :artifice => "compact_index"
+ source "file://#{gem_repo1}"
+ gem 'rack'
+ G
+
+ expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
+ should_be_installed("rack 1.0")
+ end
+ end
+
+ context "allows no gem versions" do
+ it "raises an error during resolution" do
+ update_repo gem_repo1 do
+ build_gem "require_ruby" do |s|
+ s.required_ruby_version = "> 9000"
+ end
+ end
+
+ install_gemfile <<-G, :artifice => "compact_index"
+ source "file://#{gem_repo1}"
+ gem 'require_ruby'
+ G
+
+ expect(out).to_not include("Gem::InstallError: require_ruby requires Ruby version > 9000")
+ nice_error = <<-E.strip.gsub(/^ {8}/, "")
+ Fetching source index from file:#{gem_repo1}/
+ Resolving dependencies...
+ Bundler could not find compatible versions for gem "require_ruby":
+ In Gemfile:
+ ruby (= #{RUBY_VERSION})
+
+ require_ruby was resolved to 1.0, which depends on
+ ruby (> 9000)
+ E
+ expect(out).to eq(nice_error)
+ end
+ end
+ end
+
describe "when a required rubygems version disallows a gem" do
it "does not try to install those gems" do
update_repo gem_repo1 do