diff options
author | Homu <homu@barosl.com> | 2016-09-19 18:54:09 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-09-19 18:54:09 +0900 |
commit | c36e18098e3efc9f4bf63e4a05c98494b8c7b502 (patch) | |
tree | 9eb58cf9786a7f5b3074f828ba268e3bbce02b8e | |
parent | ffacdb3737af3b3b1b26a22b635c843aa4065a77 (diff) | |
parent | 9628e2242faa80738e021c2474b5f9d888e130ff (diff) | |
download | bundler-c36e18098e3efc9f4bf63e4a05c98494b8c7b502.tar.gz |
Auto merge of #4971 - bundler:seg-pare-metadata-error, r=indirect
[EndpointSpecification] Raise a helpful error when parsing metadata fails
Would make diagnosing a recent issue around this easier
\c @indirect would love to get this into 1.13.1
-rw-r--r-- | lib/bundler/endpoint_specification.rb | 2 | ||||
-rw-r--r-- | spec/bundler/endpoint_specification_spec.rb | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb index 69d05167e8..4f5377d3cc 100644 --- a/lib/bundler/endpoint_specification.rb +++ b/lib/bundler/endpoint_specification.rb @@ -113,6 +113,8 @@ module Bundler @required_ruby_version = Gem::Requirement.new(v) end end + rescue => e + raise GemspecError, "There was an error parsing the metadata for the gem #{name} (#{version}): #{e.class}\n#{e}\nThe metadata was #{data.inspect}" end def build_dependency(name, requirements) diff --git a/spec/bundler/endpoint_specification_spec.rb b/spec/bundler/endpoint_specification_spec.rb index 6718b24971..b1e71df39a 100644 --- a/spec/bundler/endpoint_specification_spec.rb +++ b/spec/bundler/endpoint_specification_spec.rb @@ -50,4 +50,17 @@ describe Bundler::EndpointSpecification do end end end + + describe "#parse_metadata" do + context "when the metadata has malformed requirements" do + let(:metadata) { { "rubygems" => ">\n" } } + it "raises a helpful error message" do + expect { subject }.to raise_error( + Bundler::GemspecError, + a_string_including("There was an error parsing the metadata for the gem foo (1.0.0)"). + and(a_string_including('The metadata was {"rubygems"=>">\n"}')) + ) + end + end + end end |