summaryrefslogtreecommitdiff
path: root/lib/bundler/cli/init.rb
diff options
context:
space:
mode:
authorColby Swandale <colby@taplaboratories.com>2017-05-31 23:35:38 +1000
committerColby Swandale <colby@taplaboratories.com>2017-06-01 01:01:43 +1000
commitfab4838fa2680d32f3591e00ac97677d8382a517 (patch)
tree7daae22dc7598af9fabd2be8ea9f623d6139da92 /lib/bundler/cli/init.rb
parentbf26b5515926c51008f2fe9e9d0054260d482e74 (diff)
downloadbundler-fab4838fa2680d32f3591e00ac97677d8382a517.tar.gz
handle invalid gemspec and add specs for untested behaviour in bundle init --gemspec
Diffstat (limited to 'lib/bundler/cli/init.rb')
-rw-r--r--lib/bundler/cli/init.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/bundler/cli/init.rb b/lib/bundler/cli/init.rb
index 4bbdee1f48..774736f708 100644
--- a/lib/bundler/cli/init.rb
+++ b/lib/bundler/cli/init.rb
@@ -18,7 +18,13 @@ module Bundler
Bundler.ui.error "Gem specification #{gemspec} doesn't exist"
exit 1
end
+
spec = Gem::Specification.load(gemspec)
+ unless spec
+ Bundler.ui.error "Gem specification #{gemspec} is invalid"
+ exit 1
+ end
+
puts "Writing new Gemfile to #{SharedHelpers.pwd}/Gemfile"
File.open("Gemfile", "wb") do |file|
file << "# Generated from #{gemspec}\n"