Sha256: eff83e02fffffab85cf72dc5542486d366b0e7b8571c0e9dd312a70cc3610e89

Contents?: true

Size: 947 Bytes

Versions: 39

Compression:

Stored size: 947 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

39 entries across 39 versions & 1 rubygems

Version Path
ree_lib-1.0.39 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.38 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.37 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.36 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.35 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.34 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.33 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.32 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.31 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.30 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.29 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.28 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.27 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.26 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.24 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.23 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.22 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.21 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.20 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb
ree_lib-1.0.19 lib/ree_lib/packages/ree_logger/spec/ree_logger/appenders/stdout_appender_spec.rb