summaryrefslogtreecommitdiff
path: root/spec/mixlib
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-07-21 23:06:21 -0700
committerGitHub <noreply@github.com>2019-07-21 23:06:21 -0700
commit87213334119a6dc3b5c4fd469f4850a74343b984 (patch)
tree8b730eecbc1c4b6b124e6c319a377b9baba55832 /spec/mixlib
parent7e9373f5dd41a9ac258102df01f45bed8467f2f9 (diff)
parent616f57e849331ee349ad5fda431ec86b4e3e4b65 (diff)
downloadmixlib-log-87213334119a6dc3b5c4fd469f4850a74343b984.tar.gz
Merge pull request #54 from zenspider/zenspider/remove_all_warnings
Resolve all warnings emitted during testing
Diffstat (limited to 'spec/mixlib')
-rw-r--r--spec/mixlib/log_spec.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/spec/mixlib/log_spec.rb b/spec/mixlib/log_spec.rb
index 5e0f270..b58c4e2 100644
--- a/spec/mixlib/log_spec.rb
+++ b/spec/mixlib/log_spec.rb
@@ -134,17 +134,22 @@ RSpec.describe Mixlib::Log do
end
it "should raise an ArgumentError if you try and set the level to something strange using the binding form" do
- expect(lambda { Logit.level = :the_roots }).to raise_error(ArgumentError)
+ expect { Logit.level = :the_roots }.to raise_error(ArgumentError)
end
it "should raise an ArgumentError if you try and set the level to something strange using the method form" do
- expect(lambda { Logit.level(:the_roots) }).to raise_error(ArgumentError)
+ expect { Logit.level(:the_roots) }.to raise_error(ArgumentError)
end
it "should pass other method calls directly to logger" do
- Logit.level = :debug
- expect(Logit).to be_debug
- expect(lambda { Logit.debug("Gimme some sugar!") }).to_not raise_error
+ expect do
+ # this needs to be inside of the block because the level setting
+ # is causing the init, which grabs $stderr before rspec replaces
+ # it for output testing.
+ Logit.level = :debug
+ expect(Logit).to be_debug
+ Logit.debug("Gimme some sugar!")
+ end.to output(/DEBUG: Gimme some sugar!/).to_stdout
end
it "should pass add method calls directly to logger" do
@@ -152,12 +157,13 @@ RSpec.describe Mixlib::Log do
Logit.init(logdev)
Logit.level = :debug
expect(Logit).to be_debug
- expect(lambda { Logit.add(Logger::DEBUG, "Gimme some sugar!") }).to_not raise_error
+ expect { Logit.add(Logger::DEBUG, "Gimme some sugar!") }.to_not raise_error
expect(logdev.string).to match(/Gimme some sugar/)
end
it "should default to STDOUT if init is called with no arguments" do
logger_mock = Struct.new(:formatter, :level).new
+ # intentionally STDOUT to avoid unfailable test
expect(Logger).to receive(:new).with(STDOUT).and_return(logger_mock)
Logit.init
end
@@ -203,6 +209,7 @@ RSpec.describe Mixlib::Log do
end
it "should return nil from its logging methods" do
+ # intentionally STDOUT to avoid unfailable test
expect(Logger).to receive(:new).with(STDOUT) { double("a-quiet-logger").as_null_object }
Logit.init