Sha256: 57a0d35c97b2eb41333b89cab5110d44461c71a6264318472435ad85e5119d63

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
require 'logger'
require 'low/scoped_logger'
require 'low/rack/request_logger'

describe Low::Rack::RequestLogger do

  it 'should set rack.logger to an instance of `Low::ScopedLogger` with scope set to \'request_id\'
      and level set to \'low.log_level\'' do
    app = lambda do |env|
      [200, {'Content-Type' => 'text/plain'}, env['rack.logger']]
    end
    rack = Low::Rack::RequestLogger.new app
    response = rack.call({'request_id' => 'abc123', 'low.log_level' => Logger::FATAL})
    logger = response[2]
    logger.should be_a(Low::ScopedLogger)
    logger.scope.should == 'abc123'
    logger.level.should == Logger::FATAL
  end

  it 'should set the specified logger key' do
    app = lambda do |env|
      [200, {'Content-Type' => 'text/plain'}, env['another.logger']]
    end
    rack = Low::Rack::RequestLogger.new app, key: 'another.logger'
    response = rack.call({})
    response[2].should be_a(Low::ScopedLogger)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
low-0.0.14 spec/low/rack/request_logger_spec.rb