Sha256: afb2a55546b80717c1fa51d5a701c2b7e4846be7c197310f6a9121654d0d47ee
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
require File.join(File.dirname(__FILE__), "test_helper.rb") require "syslog" class RescueTest < Scope::TestCase context "with termite" do setup do Ecology.reset @logger = Termite::Logger.new("/tmp/termite_test.log") end should "continue even if all loggers raise errors" do # First, UDP will raise an error @logger.socket.expects(:send).raises(StandardError, "You suck!") # Termite should fall back to trying Ruby Syslog... syslog_mock = mock("Syslog connection") Syslog.expects(:open).yields(syslog_mock) syslog_mock.expects(:error).with("UDP syslog failed! Falling back to libc syslog!") syslog_mock.expects(:crit).raises(StandardError, "You suck even more than that!") # And it should still try to write to a file logger @logger.file_logger.expects(:fatal).raises(StandardError, "You suck lots!") extra_logger = mock("Additional logger") @logger.add_logger(extra_logger) # And it should try to write to any extra loggers extra_logger.expects(:fatal).raises(StandardError, "You suck constantly!") # And yet, nothing should be raised to the outside world begin @logger.fatal("Woe is me!") assert true, "Nothing was raised! Yay!" rescue Exception flunk "Logging an event raised an assertion outside the logger!" end end should "continue even if internal logic gives an error" do #Time.expects(:now).raises(Exception.new "You suck!") Ecology.expects(:thread_id).raises(Exception.new "Ecology thread_id dies!") begin @logger.fatal("Woe is me!") assert true, "Nothing was raised! Yay!" rescue Exception flunk "Logging an event raised an assertion outside the logger!" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
termite-0.0.10 | test/rescue_test.rb |