Sha256: 640b44cfc276dc7b9d39fed90bc00f7af6ca84e5746342b40704eba7e40870bb

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module FakeModule
  class FakeClass
    include Rails::LabeledLog::Logging
  end
end

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

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

  context 'class methods' do
    subject { FakeModule::FakeClass }

    Rails::LabeledLog::LEVELS.each do |level|
      describe "#log_#{level}" do
        it 'logs with class name' do
          subject.send("log_#{level}", "Message for #{level} in class methods")
          expect(@log_stream.string).to include("[FakeModule::FakeClass] Message for #{level} in class methods at ")
        end
      end
    end
  end

  context 'instance methods' do
    subject { FakeModule::FakeClass.new }

    Rails::LabeledLog::LEVELS.each do |level|
      describe "#log_#{level}" do
        it 'logs with class name' do
          subject.send("log_#{level}", "Message for #{level} in instance methods")
          expect(@log_stream.string).to include("[FakeModule::FakeClass] Message for #{level} in instance methods at ")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-labeled_log-0.0.2 spec/rails/labeled_log/logging_spec.rb