summaryrefslogtreecommitdiff
path: root/spec/unit/config_spec.rb
diff options
context:
space:
mode:
authorNikhil Benesch <nikhil.benesch@gmail.com>2014-01-13 00:00:31 -0500
committerdanielsdeleo <dan@opscode.com>2014-01-20 16:58:41 -0800
commit6a4b9a7849f4c60fdd2b016b288e01f2a6fd03f2 (patch)
tree3bab09fd5bd64cfc24f0f3573dbe54fef2f41bc5 /spec/unit/config_spec.rb
parente15f04b1ed124767a04ef4f5de4f8678fcbe33df (diff)
downloadchef-6a4b9a7849f4c60fdd2b016b288e01f2a6fd03f2.tar.gz
CHEF-4725: Validate 'log_location' setting on log initialization
Previously, a Mixlib::Config setter method verified that 'log_location' was set to a writeable file or a valid IO stream. Due to the way Mixlib::Config handles `default` and `merge!`, this setter method would not fire if the 'log_location' was left unconfigured or if it was set on the command line, resulting in inconsistent error handling. This commit moves the validation logic out of the configuration layer and into the log initializion layer. This ensures that error handling is consistent, regardless of where the 'log_location' setting is configured. Validation logic is also simplified, relying on the MonoLogger class to open and configure any necessary IO streams.
Diffstat (limited to 'spec/unit/config_spec.rb')
-rw-r--r--spec/unit/config_spec.rb30
1 files changed, 0 insertions, 30 deletions
diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb
index 77870e84d8..2bf003bbdb 100644
--- a/spec/unit/config_spec.rb
+++ b/spec/unit/config_spec.rb
@@ -121,29 +121,6 @@ describe Chef::Config do
end
- describe "config attribute writer: log_method=" do
- describe "when given an object that responds to sync= e.g. IO" do
- it "should configure itself to use the IO as log_location" do
- Chef::Config.log_location = STDOUT
- Chef::Config.log_location.should == STDOUT
- end
- end
-
- describe "when given an object that is stringable (to_str)" do
- before do
- @mockfile = mock("File", :path => "/var/log/chef/client.log", :sync= => true)
- File.should_receive(:new).
- with("/var/log/chef/client.log", "a").
- and_return(@mockfile)
- end
-
- it "should configure itself to use a File object based upon the String" do
- Chef::Config.log_location = "/var/log/chef/client.log"
- Chef::Config.log_location.path.should == "/var/log/chef/client.log"
- end
- end
- end
-
describe "class method: plaform_specific_path" do
it "should return given path on non-windows systems" do
platform_mock :unix do
@@ -354,13 +331,6 @@ describe Chef::Config do
end
end
- describe "Chef::Config[:log_location]" do
- it "raises ConfigurationError when log_location directory is missing" do
- missing_path = "/tmp/non-existing-dir/file"
- expect{Chef::Config.log_location = missing_path}.to raise_error Chef::Exceptions::ConfigurationError
- end
- end
-
describe "Chef::Config[:event_handlers]" do
it "sets a event_handlers to an empty array by default" do
Chef::Config[:event_handlers].should eq([])