summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-02-28 06:48:35 +0900
committerHomu <homu@barosl.com>2016-02-28 06:48:35 +0900
commita69ec8fd00947cd5428873055c30e25e662cf7d9 (patch)
tree48f3cda5c72a986e83b48a90f7ea028529cbb5c4
parentf819834287274aa78d0fd03ac5685cf543cd68e4 (diff)
parent483bd8ee8da279fbf93a3b02a4d5dfc6f6acaf2a (diff)
downloadbundler-a69ec8fd00947cd5428873055c30e25e662cf7d9.tar.gz
Auto merge of #4324 - RochesterinNYC:allow-bundler-ruby-version-neg-1-patchlevel-handling, r=indirect
Allow `Bundler::RubyVersion` to handle -1 for RUBY_PATCHLEVEL Fixes how the `matches?` method in `Bundler::RubyVersion` handles a `RUBY_PATCHLEVEL` of `-1`, which seems to be the case with ruby-head. Closes #4317
-rw-r--r--lib/bundler/ruby_version.rb3
-rw-r--r--spec/bundler/ruby_version_spec.rb22
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb
index 800a4433f2..92f9d4c396 100644
--- a/lib/bundler/ruby_version.rb
+++ b/lib/bundler/ruby_version.rb
@@ -103,6 +103,9 @@ module Bundler
private
def matches?(requirements, version)
+ # Handles RUBY_PATCHLEVEL of -1 for instances like ruby-head
+ return requirements == version if requirements.to_s == "-1" || version.to_s == "-1"
+
Array(requirements).all? do |requirement|
Gem::Requirement.create(requirement).satisfied_by?(Gem::Version.create(version))
end
diff --git a/spec/bundler/ruby_version_spec.rb b/spec/bundler/ruby_version_spec.rb
index ce68463029..08a7e0e8e4 100644
--- a/spec/bundler/ruby_version_spec.rb
+++ b/spec/bundler/ruby_version_spec.rb
@@ -328,6 +328,28 @@ describe "Bundler::RubyVersion and its subclasses" do
it_behaves_like "there is a difference in the engine versions"
end
+
+ context "with a patchlevel of -1" do
+ let(:version) { ">= 2.0.0" }
+ let(:patchlevel) { "-1" }
+ let(:engine) { "ruby" }
+ let(:engine_version) { "~> 2.0.1" }
+ let(:other_version) { version }
+ let(:other_engine) { engine }
+ let(:other_engine_version) { engine_version }
+
+ context "and comparing with another patchlevel of -1" do
+ let(:other_patchlevel) { patchlevel }
+
+ it_behaves_like "there are no differences"
+ end
+
+ context "and comparing with a patchlevel that is not -1" do
+ let(:other_patchlevel) { "642" }
+
+ it_behaves_like "there is a difference in the patchlevels"
+ end
+ end
end
describe "#system" do