Sha256: f820ed99467ccfbd78581e5fe0a3936992e599d38de6fea40df0075a76a49603

Contents?: true

Size: 770 Bytes

Versions: 2

Compression:

Stored size: 770 Bytes

Contents

require 'abstract_unit'
require 'stringio'
require 'active_support/logger'

class CleanLoggerTest < ActiveSupport::TestCase
  def setup
    @out = StringIO.new
    @logger = ActiveSupport::Logger.new(@out)
  end

  def test_format_message
    @logger.error 'error'
    assert_equal "error\n", @out.string
  end

  def test_datetime_format
    @logger.formatter = Logger::Formatter.new
    @logger.formatter.datetime_format = "%Y-%m-%d"
    @logger.debug 'debug'
    assert_equal "%Y-%m-%d", @logger.formatter.datetime_format
    assert_match(/D, \[\d\d\d\d-\d\d-\d\d#\d+\] DEBUG -- : debug/, @out.string)
  end

  def test_nonstring_formatting
    an_object = [1, 2, 3, 4, 5]
    @logger.debug an_object
    assert_equal("#{an_object.inspect}\n", @out.string)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activejob-lock-0.0.2 rails/activesupport/test/clean_logger_test.rb
activejob-lock-0.0.1 rails/activesupport/test/clean_logger_test.rb