summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-09-24 22:04:01 +0900
committerSamuel Giddins <segiddins@segiddins.me>2016-09-30 12:27:06 -0500
commit36e84727bb16816cd60d98b6d416c866eaccbd5f (patch)
tree5e590cb7015181eeefa88cab6bb98239da2fa05d
parent713e7711dc506751966a3abd86340e284ebc6a95 (diff)
downloadbundler-36e84727bb16816cd60d98b6d416c866eaccbd5f.tar.gz
Auto merge of #5015 - m1k3:fix-settings-no-config, r=segiddins
fixing NoMethodError on settings When the Settings object is initialized with no root directory it cannot read the local_config. This used to not be a problem due to the fact that the `#load_config` method did not try to exit early. Since now it does it returns nil when the config is not present setting the @local_config instance variable to nil. The fix is to return an empty hash the same way the `#load_config` method would return if it encountered a problem later on. The attached test proves that there is a problem and the fix makes the problem go away.
-rw-r--r--lib/bundler/settings.rb2
-rw-r--r--spec/bundler/settings_spec.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 3abe009d13..01594066c3 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -279,7 +279,7 @@ module Bundler
}xo
def load_config(config_file)
- return unless config_file
+ return {} unless config_file
SharedHelpers.filesystem_access(config_file, :read) do |file|
valid_file = file.exist? && !file.size.zero?
return {} if ignore_config? || !valid_file
diff --git a/spec/bundler/settings_spec.rb b/spec/bundler/settings_spec.rb
index 0f7d2a0138..66189eae72 100644
--- a/spec/bundler/settings_spec.rb
+++ b/spec/bundler/settings_spec.rb
@@ -54,6 +54,16 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow
end
describe "#[]" do
+ context "when the local config file is not found" do
+ subject(:settings) { described_class.new }
+
+ it "does not raise" do
+ expect do
+ subject["foo"]
+ end.not_to raise_error
+ end
+ end
+
context "when not set" do
context "when default value present" do
it "retrieves value" do