diff options
author | Matt Wrock <matt@mattwrock.com> | 2016-08-12 12:28:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-12 12:28:51 -0700 |
commit | 8cf5d695eb41936c463bfc39cad94e83d06c79f4 (patch) | |
tree | 64278ebf737a88a1839accb115e50c25c1ce90fa | |
parent | a9658a8da7c45d098116cc0888bfda33fbfbd2a3 (diff) | |
parent | 1b5944951dbc7adbb8eb8405523b52484b8392bb (diff) | |
download | ohai-8cf5d695eb41936c463bfc39cad94e83d06c79f4.tar.gz |
Merge pull request #864 from chef/tm/no_init_now
Move log configuration down to Mixlib::Log
-rw-r--r-- | lib/ohai/log.rb | 8 | ||||
-rw-r--r-- | spec/unit/system_spec.rb | 31 |
2 files changed, 22 insertions, 17 deletions
diff --git a/lib/ohai/log.rb b/lib/ohai/log.rb index 284d4fb0..c63f7abe 100644 --- a/lib/ohai/log.rb +++ b/lib/ohai/log.rb @@ -25,13 +25,5 @@ module Ohai init(STDERR) level = :info - def self.configured? - @configured - end - - def self.use_log_devices(other) - @configured = true - super - end end end diff --git a/spec/unit/system_spec.rb b/spec/unit/system_spec.rb index 8b2754ca..0144ff61 100644 --- a/spec/unit/system_spec.rb +++ b/spec/unit/system_spec.rb @@ -95,17 +95,30 @@ describe "Ohai::System" do end end - it "configures logging" do - log_level = :debug - Ohai.config[:log_level] = log_level - expect(Ohai::Log).to receive(:init).with(Ohai.config[:log_location]) - expect(Ohai::Log).to receive(:level=).with(log_level) - Ohai::System.new + context "first time configuration" do + before { allow(Ohai::Log).to receive(:configured?).and_return(false) } + + it "configures logging" do + log_level = :debug + Ohai.config[:log_level] = log_level + expect(Ohai::Log).to receive(:init).with(Ohai.config[:log_location]) + expect(Ohai::Log).to receive(:level=).with(log_level) + Ohai::System.new + end + + it "resolves log_level when set to :auto" do + expect(Ohai::Log).to receive(:level=).with(:info) + Ohai::System.new + end end - it "resolves log_level when set to :auto" do - expect(Ohai::Log).to receive(:level=).with(:info) - Ohai::System.new + context "after first time configuration" do + before { allow(Ohai::Log).to receive(:configured?).and_return(true) } + + it "configures logging" do + expect(Ohai::Log).not_to receive(:init).with(Ohai.config[:log_location]) + Ohai::System.new + end end end |