Sha256: e29aa6421225648e8bd17b70ca33119f57792d2ff63e98be8e75e9b8b2a03c3b
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
require 'rails_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/rails/ucblit/logging/formatters_spec.rb |
berkeley_library-logging-0.2.0 | spec/rails/ucblit/logging/formatters_spec.rb |