summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-02-08 15:43:35 +0000
committerThe Bundler Bot <bot@bundler.io>2017-02-08 15:43:35 +0000
commit427f07f77f414f43d693c87c104546af3d9fe984 (patch)
tree85e015253a40a5293084f57b7e37b10c7c1524ee
parentc0de8f625f0ae2ed5cc2b26673c875e2900a9829 (diff)
parentd4384e39565b348b394677e2e357f46c601c54fb (diff)
downloadbundler-427f07f77f414f43d693c87c104546af3d9fe984.tar.gz
Auto merge of #5391 - bundler:seg-ruby-version-requirement-valid, r=indirect
[RubyVersion] Ensure passed-in versions are valid during init Closes #5380
-rw-r--r--lib/bundler/ruby_version.rb6
-rw-r--r--spec/install/gemfile/ruby_spec.rb20
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb
index ebdefe63fc..f0a001d296 100644
--- a/lib/bundler/ruby_version.rb
+++ b/lib/bundler/ruby_version.rb
@@ -21,7 +21,11 @@ module Bundler
# must not be specified, or the engine version
# specified must match the version.
- @versions = Array(versions)
+ @versions = Array(versions).map do |v|
+ op, v = Gem::Requirement.parse(v)
+ op == "=" ? v.to_s : "#{op} #{v}"
+ end
+
@gem_version = Gem::Requirement.create(@versions.first).requirements.first.last
@input_engine = engine && engine.to_s
@engine = engine && engine.to_s || "ruby"
diff --git a/spec/install/gemfile/ruby_spec.rb b/spec/install/gemfile/ruby_spec.rb
index 3f8957916b..b9d9683758 100644
--- a/spec/install/gemfile/ruby_spec.rb
+++ b/spec/install/gemfile/ruby_spec.rb
@@ -86,4 +86,24 @@ RSpec.describe "ruby requirement" do
expect(the_bundle).to include_gems "rack 1.0.0"
expect(locked_ruby_version.versions).to eq(["5100"])
end
+
+ it "allows requirements with trailing whitespace" do
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+ ruby "#{RUBY_VERSION}\\n \t\\n"
+ gem "rack"
+ G
+
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+
+ it "fails gracefully with malformed requirements" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ ruby ">= 0", "-.\\0"
+ gem "rack"
+ G
+
+ expect(out).to include("There was an error parsing") # i.e. DSL error, not error template
+ end
end