spec/rails/ucblit/logging/formatters_spec.rb in berkeley_library-logging-0.2.5 vs spec/rails/ucblit/logging/formatters_spec.rb in berkeley_library-logging-0.2.6
- old
+ new
@@ -7,11 +7,11 @@
module Logging
describe Formatters do
describe :new_json_formatter do
attr_reader :out, :logger
- before(:each) do
+ before do
@out = StringIO.new
@logger = Logger.new(out)
logger.formatter = Formatters.new_json_formatter
end
@@ -66,17 +66,19 @@
expect(additional_data['not_a_string']).to eq(12)
expect(additional_data['another_string']).to eq(expected_string)
expect(additional_data['more_strings']).to eq([expected_string, expected_string])
end
+ # rubocop:disable Layout/LineLength
it 'removes ANSI formatting from ActiveRecord logs' do
original = " \e[1m\e[36mLendingItem Load (2.0ms)\e[0m \e[1m\e[34mSELECT \"lending_items\".* FROM \"lending_items\" WHERE \"lending_items\".\"directory\" = $1 LIMIT $2\e[0m [[\"directory\", \"b135297126_C068087930\"], [\"LIMIT\", 1]]"
expected = ' LendingItem Load (2.0ms) SELECT "lending_items".* FROM "lending_items" WHERE "lending_items"."directory" = $1 LIMIT $2 [["directory", "b135297126_C068087930"], ["LIMIT", 1]]'
logger.info(original)
logged_json = JSON.parse(out.string)
msg = logged_json['msg']
expect(msg).to eq(expected)
end
+ # rubocop:enable Layout/LineLength
end
describe :ensure_hash do
it 'returns an empty hash for nil' do
expect(Formatters.ensure_hash(nil)).to eq({})