Sha256: e37d85f8187b3fa1f5e4423f4f7f67c6f0541cc597344cdeca6de6d8d084a6d0

Contents?: true

Size: 946 Bytes

Versions: 85

Compression:

Stored size: 946 Bytes

Contents

#frozen_string_literal: true

package_require('ree_logger/appenders/stdout_appender')

RSpec.describe ReeLogger::StdoutAppender do
  let(:stdout_appender) { described_class }

  let(:log_event) {
    ReeLogger::LogEvent.new(
      :info,
      "Some message",
      nil,
      {}
    )
  }

  let(:custom_formatter) {
    Class.new(ReeLogger::Formatter) do
      def format(event, progname = nil)
        event.message.upcase
      end
    end
  }

  it "with default formatter" do
    appender = stdout_appender.new(
      :info,
      nil
    )

    expect(appender).to respond_to(:append)
    expect { appender.append(log_event) }.to output(/#{log_event.message}/).to_stdout
  end

  it "with custom formatter" do
    appender = stdout_appender.new(
      :info,
      custom_formatter.new
    )

    expect(appender).to respond_to(:append)
    expect { appender.append(log_event) }.to output(/#{log_event.message.upcase}/).to_stdout
  end
end

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
ree_lib-1.0.124 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.123 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.122 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.121 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.120 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.119 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.118 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.117 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.116 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.115 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.114 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.113 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.112 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.111 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.110 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.109 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.108 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.107 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.106 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.105 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb