Sha256: a220a9626f966582a186ffc93020743a58e97aada382665ddd4bf90567bf549c
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require_relative 'test_helper' class FormattersTest < Minitest::Test describe SemanticLogger::Formatters do describe '.factory' do let :log do SemanticLogger::Log.new('Test', :info) end let :appender do SemanticLogger::Appender::File.new(io: STDOUT) end it 'from a symbol' do assert formatter = SemanticLogger::Formatters.factory(:raw) assert formatter.is_a?(SemanticLogger::Formatters::Raw) assert_equal 'Test', formatter.call(log, appender)[:name] end it 'from a Hash (Symbol with options)' do assert formatter = SemanticLogger::Formatters.factory(raw: {time_format: "%Y%m%d"}) assert formatter.is_a?(SemanticLogger::Formatters::Raw) assert result = formatter.call(log, appender) assert_equal 'Test', result[:name] assert_equal Time.now.strftime("%Y%m%d"), result[:time] end it 'from block' do my_formatter = -> log, appender { log.name } assert formatter = SemanticLogger::Formatters.factory(my_formatter) assert formatter.is_a?(Proc) assert_equal 'Test', formatter.call(log, appender) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
semantic_logger-4.2.0 | test/formatters_test.rb |