1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/sinatra-contrib/spec/custom_logger_spec.rb

44 lines
901 B
Ruby
Raw Normal View History

2014-05-09 02:39:16 -04:00
require 'spec_helper'
2014-04-03 22:35:44 -04:00
require 'sinatra/custom_logger'
RSpec.describe Sinatra::CustomLogger do
before do
rack_logger = @rack_logger = double
mock_app do
helpers Sinatra::CustomLogger
before do
env['rack.logger'] = rack_logger
end
get '/' do
logger.info 'Logged message'
'Response'
end
end
end
describe '#logger' do
it 'falls back to request.logger' do
expect(@rack_logger).to receive(:info).with('Logged message')
get '/'
end
context 'logger setting is set' do
before do
custom_logger = @custom_logger = double
@app.class_eval do
configure do
set :logger, custom_logger
end
end
end
it 'calls custom logger' do
expect(@custom_logger).to receive(:info).with('Logged message')
get '/'
end
end
end
end