summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Wrock <matt@mattwrock.com>2016-08-12 12:24:55 -0700
committerMatt Wrock <matt@mattwrock.com>2016-08-12 12:24:55 -0700
commit1b5944951dbc7adbb8eb8405523b52484b8392bb (patch)
tree64278ebf737a88a1839accb115e50c25c1ce90fa
parent80f4a57c1cad9f7869be56bdf8fbdcbd5fa4491a (diff)
downloadohai-1b5944951dbc7adbb8eb8405523b52484b8392bb.tar.gz
retrofit tests to cover preconfigured state
-rw-r--r--spec/unit/system_spec.rb31
1 files changed, 22 insertions, 9 deletions
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