Sha256: 1976b295c150738dfad3505ca2c8cba251b98a39edfba62148760219b8112291

Contents?: true

Size: 1.17 KB

Versions: 85

Compression:

Stored size: 1.17 KB

Contents

#frozen_string_literal: true

require 'timecop'
package_require('ree_logger/formatters/default_formatter')

RSpec.describe ReeLogger::DefaultFormatter do
  link :parse, from: :ree_datetime

  let(:formatter) { described_class.new }

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

  let(:error_log_event) {
    ReeLogger::LogEvent.new(
      :error,
      "Some error message",
      StandardError.new('Help me, I am error'),
      { some_error: "params" }
    )
  }

  before { Timecop.travel(parse('1605-11-05 00:00:00')) }
  after { Timecop.return }

  it { expect(formatter).to respond_to(:format) }

  it {
    expected = "[05/11/05 00:00:00] INFO: Some message"
    expect(formatter.format(info_log_event, nil)).to eq(expected)
  }

  it {
    expected = "[SomeCoolApp] [05/11/05 00:00:00] INFO: Some message"
    expect(formatter.format(info_log_event, "SomeCoolApp")).to eq(expected)
  }

  it {
    expected = "[05/11/05 00:00:00] ERROR: Some error message\nPARAMETERS: {:some_error=>\"params\"}\nEXCEPTION: StandardError (Help me, I am error)\n"
    expect(formatter.format(error_log_event, nil)).to eq(expected)
  }
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/formatters/default_formatter_spec.rb
ree_lib-1.0.123 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.122 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.121 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.120 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.119 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.118 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.117 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.116 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.115 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.114 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.113 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.112 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.111 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.110 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.109 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.108 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.107 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.106 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb
ree_lib-1.0.105 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/default_formatter_spec.rb