Sha256: 8c22b0e26316515394f8957a760b04c1d9d756645d186493873fe46b67485214

Contents?: true

Size: 935 Bytes

Versions: 1

Compression:

Stored size: 935 Bytes

Contents

describe Rails::LabeledLog::Logger do
  subject { described_class.new('Chefe', 'Pixel') }

  before(:all) do
    @log_stream = StringIO.new
    Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new(@log_stream))
  end

  after(:all) do
    Rails.logger = nil
  end

  Rails::LabeledLog::LEVELS.each do |level|
    describe "##{level}" do
      it 'logs with labels' do
        subject.send(level, "Message for #{level}")
        expect(@log_stream.string).to include("[Chefe] [Pixel] Message for #{level} at ")
      end
    end
  end

  context 'when supplies additional labels' do
    Rails::LabeledLog::LEVELS.each do |level|
      describe "##{level}" do
        it 'logs with labels and additional labels' do
          subject.send(level, "Message for #{level}", 'Nina', 'Doki')
          expect(@log_stream.string).to include("[Chefe] [Pixel] [Nina] [Doki] Message for #{level} at ")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-labeled_log-0.1.0 spec/rails/labeled_log/logger_spec.rb