class StdOutErrLoggerTest

def setup

Redirect STDOUT and STDERR to capture them for assertions
def setup
  @original_stdout = $stdout
  @original_stderr = $stderr
  $stdout = StringIO.new
  $stderr = StringIO.new
end

def teardown

def teardown
  $stdout = @original_stdout
  $stderr = @original_stderr
end

def test_initialize_with_file

def test_initialize_with_file
  Tempfile.open do |file|
    logger = StdOutErrLogger.new(file.path)
    assert_equal file.path, logger.file
  end
end

def test_initialize_without_file

def test_initialize_without_file
  logger = StdOutErrLogger.new
  assert_nil logger.file
  assert_equal Logger::DEBUG, logger.level
end

def test_logging_error

def test_logging_error
  logger = StdOutErrLogger.new
  logger.error("Error message")
  assert_empty $stdout.string
  assert_equal "Error message\n", $stderr.string
end

def test_logging_info

def test_logging_info
  logger = StdOutErrLogger.new
  logger.info("Info message")
  assert_equal "Info message\n", $stdout.string
  assert_empty $stderr.string
end

def test_logging_unknown_severity

def test_logging_unknown_severity
  logger = StdOutErrLogger.new
  logger.add(Logger::UNKNOWN, "Unknown severity message")
  assert_empty $stdout.string
  assert_equal "Unknown severity message\n", $stderr.string
end

def test_logging_warning

def test_logging_warning
  logger = StdOutErrLogger.new
  logger.warn("Warning message")
  assert_empty $stdout.string
  assert_equal "Warning message\n", $stderr.string
end

def test_logging_with_array

def test_logging_with_array
  logger = StdOutErrLogger.new
  logger.info(["Message line 1", "Message line 2"])
  assert_equal "Message line 1\nMessage line 2\n", $stdout.string
end

def test_logging_with_block

def test_logging_with_block
  logger = StdOutErrLogger.new
  logger.info { "Block message" }
  assert_equal "Block message\n", $stdout.string
end