Sha256: 4dd60af224f73a0ad0e66c209c5acdeace1a5d373411559b1e8fe333266e5053

Contents?: true

Size: 973 Bytes

Versions: 2

Compression:

Stored size: 973 Bytes

Contents

# frozen_string_literal: true

RSpec.describe TTY::Logger, "outputs" do
  let(:styles) { TTY::Logger::Handlers::Console::STYLES }

  it "outputs to multiple streams of the same handler" do
    stream = StringIO.new

    logger = TTY::Logger.new do |config|
      config.handlers = [[:stream, formatter: :text]]
      config.output = [stream, stream]
    end

    logger.info("logging")

    expect(stream.string).to eq([
      "level=info message=logging\n",
      "level=info message=logging\n"
    ].join)
  end

  it "outputs each handler to a different stream" do
    stream = StringIO.new

    logger = TTY::Logger.new do |config|
      config.handlers = [
        [:console, output: stream],
        [:stream, output: stream]
      ]
    end

    logger.info("logging")

    expect(stream.string).to eq([
      "\e[32m#{styles[:info][:symbol]}\e[0m \e[32minfo\e[0m    ",
      "logging                  \n",
      "level=info message=logging\n"
    ].join)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tty-logger-0.2.0 spec/unit/output_spec.rb
tty-logger-0.1.0 spec/unit/output_spec.rb