Sha256: b72dc4325907f48083513ffc5d98eb62275c82ee9e0e42919540f17020e81bae
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
require 'standalone_helper' require 'json' require 'berkeley_library/logging' module BerkeleyLibrary module Logging describe Formatters do describe :new_json_formatter do it 'supports tagged logging' do out = StringIO.new logger = Logger.new(out) logger.formatter = Formatters.new_json_formatter logger = ActiveSupport::TaggedLogging.new(logger) expected_tag = 'hello' expected_msg = 'this is a test' logger.tagged(expected_tag) { logger.info(expected_msg) } logged_json = JSON.parse(out.string) expect(logged_json['msg']).to eq(expected_msg) expect(logged_json['tags']).to eq([expected_tag]) end end describe :ensure_hash do it 'returns an empty hash for nil' do expect(Formatters.ensure_hash(nil)).to eq({}) end it 'returns the original hash for a hash' do original_hash = { a: 1, b: 2 } expect(Formatters.ensure_hash(original_hash)).to equal(original_hash) end it 'wraps anything else in a hash' do message = 'this is a message' expect(Formatters.ensure_hash(message)).to eq({ msg: message }) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
berkeley_library-logging-0.2.1 | spec/standalone/ucblit/logging/formatters_spec.rb |
berkeley_library-logging-0.2.0 | spec/standalone/ucblit/logging/formatters_spec.rb |