Sha256: 60429b3a9048d46bfbac368bbeb8fde829ef5dc3677939b9c32ce071f709eaba

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require "spec_helper"

describe Timber::LogDevices::IO::HybridHiddenFormatter do
  describe ".format" do
    let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) }
    let(:formatter) { described_class.new }
    let(:message) { "a message" }
    let(:log_line) { Timber::LogLine.new(message) }
    subject { formatter.format(log_line) }

    before(:each) do
      server_context = Timber::CurrentContext.get(Timber::Contexts::Server)
      allow(server_context).to receive(:_dt).and_return(time)
    end

    it { should eq("\e7\e[1;30m@timber.io \e8\e[Kserver.hostname=comp\e8\e[Kuter-name.domain.com\e8\e[K server._dt=2016-09-\e8\e[K01T12:00:00.000000Z \e8\e[Kserver._version=1 se\e8\e[Krver._index=0 _versi\e8\e[Kon=1 _hierarchy=[ser\e8\e[Kver] @original \e8\e[K\e[0ma message") }

    context "with a slash" do
      let(:message) { "this is a long message that exceeds the step size".insert(described_class::CLEAR_STEP_SIZE - 1, "\\") }

      before(:each) do
        allow(formatter).to receive(:encoded_context).and_return(message)
      end

      it { should eq("\e7\e[1;30m@timber.io \e8\e[Kthis is a long mess\\a\e8\e[Kge that exceeds the \e8\e[Kstep size @original \e8\e[K\e[0mthis is a long mess\\a\e8\e[Kge that exceeds the \e8\e[Kstep size") }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timberio-1.0.0.beta1 spec/timber/log_devices/io/hybrid_hidden_formatter_spec.rb