1
0
mirror of https://github.com/meineerde/rackstash.git synced 2026-03-29 11:31:09 +00:00
rackstash/spec/rackstash/sink_spec.rb
Holger Just 3081b03db1 Add basic logger structure with early spikes
The Rackstash::Logger class will server as the public main entry point
for users. It will eventually implement the mostly complete interface of
Ruby's Logger.

The idea of Rackstash is the we will allow to buffer multiple log
messages allong with additional data until a combined log event is
eventually flushed to an underlying log target. This allows to keep
connected log messages and data as a single unit from the start without
having to painstakingly parse and connect these in later systems again.
2017-01-18 23:34:55 +01:00

38 lines
901 B
Ruby

# Copyright 2017 Holger Just
#
# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE.txt file for details.
require 'spec_helper'
require 'rackstash/sink'
describe Rackstash::Sink do
let(:targets) { [] }
let(:sink) { Rackstash::Sink.new(targets) }
describe '#initialize' do
it 'accepts an array with targets' do
expect(targets).to receive(:to_ary).once.and_call_original
expect(sink.targets).to equal targets
end
it 'wraps a single target into an array' do
target = Object.new
expect(Rackstash::Sink.new(target).targets).to eql [target]
end
end
describe '#flush' do
it 'flushes the buffer to all targets' do
buffer = double('buffer')
target = double('target')
targets << target
expect(target).to receive(:flush).with(buffer)
sink.flush(buffer)
end
end
end