Sha256: bed912ef0bc6b271b70c489fd890555fb2d67468f2eac65589d20765014c23a4

Contents?: true

Size: 1.23 KB

Versions: 39

Compression:

Stored size: 1.23 KB

Contents

#frozen_string_literal = true

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

RSpec.describe ReeLogger::ColorizedFormatter 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] \e[36minfo:\e[0m Some message"
    expect(formatter.format(info_log_event, nil)).to eq(expected)
  }

  it {
    expected = "[SomeCoolApp] [05/11/05 00:00:00] \e[36minfo:\e[0m Some message"
    expect(formatter.format(info_log_event, "SomeCoolApp")).to eq(expected)
  }

  it {
    expected = "[05/11/05 00:00:00] \e[31merror:\e[0m Some error message\n\e[34mPARAMETERS:\e[0m {:some_error=>\"params\"}\n\e[31mEXCEPTION:\e[0m StandardError (Help me, I am error)\n"
    expect(formatter.format(error_log_event, nil)).to eq(expected)
  }
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/formatters/colorized_formatter_spec.rb
ree_lib-1.0.38 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.37 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.36 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.35 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.34 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.33 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.32 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.31 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.30 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.29 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.28 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.27 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.26 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.24 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.23 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.22 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.21 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.20 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb
ree_lib-1.0.19 lib/ree_lib/packages/ree_logger/spec/ree_logger/formatters/colorized_formatter_spec.rb