Skip to content

Commit

Permalink
Explicitly close logger to make all the logfile tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
billdueber committed Jul 24, 2023
1 parent b994efc commit d9aed5c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions spec/cictl/logger_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ def testlogger(verbose: false, log_file: test_log, quiet: false)
end

it "sends #error to $stderr" do
skip "RSpec and captured stderr in the logger don't play well together"
expect { testlogger.error "error shwoozle" }.to output(/shwoozle/).to_stderr_from_any_process
expect {
testlogger.error "error error-via-error"
testlogger.close
}.to output(/error-via-error/).to_stderr_from_any_process
end

it "sends #fatal to $stderr" do
# skip "RSpec and captured stderr in the logger don't play well together"
expect {
testlogger.fatal "fatal shwoozle"
testlogger.close
Expand All @@ -33,14 +34,18 @@ def testlogger(verbose: false, log_file: test_log, quiet: false)
end

it "does not send anything less than #error to STDERR" do
skip "RSpec and captured stderr in the logger don't play well together"
%i[debug info warn].each do |level|
expect { testlogger.send(level, "#{level} shwoozle") }.not_to output(/shwoozle/).to_stderr_from_any_process
expect {
testlogger.send(level, "#{level} shwoozle")
testlogger.close
}.not_to output(/shwoozle/).to_stderr_from_any_process
end
end

it "doesn't send output to stderr in quiet mode" do
skip "RSpec and captured stderr in the logger don't play well together"
expect { testlogger(quiet: true).error("Error") }.not_to output(/Error/).to_stderr_from_any_process
expect {
testlogger(quiet: true).error("Error")
testlogger.close
}.not_to output(/Error/).to_stderr_from_any_process
end
end

0 comments on commit d9aed5c

Please sign in to comment.