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 #4324 - RochesterinNYC:allow-bundler-ruby-version-neg-1…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
homu committed Feb 27, 2016
2 parents f819834 + 483bd8e commit a69ec8f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/bundler/ruby_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ def self.system
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
Expand Down
22 changes: 22 additions & 0 deletions spec/bundler/ruby_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,28 @@

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
Expand Down

0 comments on commit a69ec8f

Please sign in to comment.