spec/standalone/ucblit/logging/loggers_spec.rb in berkeley_library-logging-0.2.1 vs spec/standalone/ucblit/logging/loggers_spec.rb in berkeley_library-logging-0.2.2

- old
+ new

@@ -1,7 +1,8 @@ require 'standalone_helper' require 'json' +require 'colorize' module BerkeleyLibrary module Logging describe Loggers do attr_reader :out @@ -19,9 +20,21 @@ end # rubocop:enable Lint/ConstantDefinitionInBlock after(:each) do Object.send(:remove_const, :TestError) + end + + describe :new_readable_logger do + it 'logs ANSI colors' do + logger = Loggers.new_readable_logger(out) + colors = %i[red green yellow blue magenta cyan] + colorized_string = colors.map { |c| c.to_s.colorize(c) }.join(' ') + expect(colorized_string).to include("\u001b") # just to be sure + + logger.info(colorized_string) + expect(out.string).to include(colorized_string) + end end describe :new_json_logger do # TODO: rewrite this as a matcher