Sha256: b0b2e461ace5505e885f1d78ca215b13c2e156fd6baff3658be6f7cc99332447
Contents?: true
Size: 653 Bytes
Versions: 2
Compression:
Stored size: 653 Bytes
Contents
# frozen_string_literal: true RSpec.describe TTY::Logger::Handlers::Null, "custom handler" do let(:output) { StringIO.new } it "logs messages with a custom handler" do stub_const("MyHandler", Class.new do def initialize(output: nil, config: nil, label: nil) @label = label @output = output end def call(event) @output.puts "(#{@label}) #{event.message.join}" end end) logger = TTY::Logger.new(output: output) do |config| config.handlers = [[MyHandler, {label: "myhandler"}]] end logger.info("Logging") expect(output.string).to eq("(myhandler) Logging\n") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tty-logger-0.2.0 | spec/unit/handlers/custom_spec.rb |
tty-logger-0.1.0 | spec/unit/handlers/custom_spec.rb |