summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2015-03-11 10:18:42 -0400
committerArthur Neves <arthurnn@gmail.com>2015-03-11 13:41:32 -0400
commit2066de222384ad74ad96f6b863510541ac66cc51 (patch)
tree3bff5dd8119bdf4f49aa64003f64d4f77feceacb
parent7ba9673a3ee0fd020d7868e92c8be08c8387a8f3 (diff)
downloadbundler-2066de222384ad74ad96f6b863510541ac66cc51.tar.gz
Catch and report RuntimeError on Gemfile eval
-rw-r--r--lib/bundler/dsl.rb2
-rw-r--r--spec/bundler/dsl_spec.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 9736525a4f..e6c4b975ef 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -33,7 +33,7 @@ module Bundler
rescue SyntaxError => e
syntax_msg = e.message.gsub("#{gemfile}:", 'on line ')
raise GemfileError, "Gemfile syntax error #{syntax_msg}"
- rescue ScriptError, RegexpError, NameError, ArgumentError => e
+ rescue ScriptError, RegexpError, NameError, ArgumentError, RuntimeError => e
e.backtrace[0] = "#{e.backtrace[0]}: #{e.message} (#{e.class})"
Bundler.ui.warn e.backtrace.join("\n ")
raise GemfileError, "There was an error in your Gemfile," \
diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb
index e3ff2306e9..81313c38a8 100644
--- a/spec/bundler/dsl_spec.rb
+++ b/spec/bundler/dsl_spec.rb
@@ -180,4 +180,12 @@ describe Bundler::Dsl do
to raise_error(Bundler::GemfileError, /Gemfile syntax error/)
end
end
+
+ describe "Runtime errors", :unless => Bundler.current_ruby.on_18? do
+ it "will raise a Bundler::GemfileError" do
+ gemfile "s = 'foo'.freeze; s.strip!"
+ expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
+ to raise_error(Bundler::GemfileError, /There was an error in your Gemfile/)
+ end
+ end
end