spec/standalone/ucblit/logging/formatters_spec.rb in berkeley_library-logging-0.2.2 vs spec/standalone/ucblit/logging/formatters_spec.rb in berkeley_library-logging-0.2.3

- old
+ new

@@ -63,9 +63,18 @@ expect(data['the_string']).to eq(expected_string) additional_data = data['additional_data'] expect(additional_data['another_string']).to eq(expected_string) expect(additional_data['more_strings']).to eq([expected_string, expected_string]) end + + 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 end describe :ensure_hash do it 'returns an empty hash for nil' do expect(Formatters.ensure_hash(nil)).to eq({})