2009-12-26 21:00:18 +01:00
|
|
|
require 'stringio'
|
2010-06-14 06:09:24 +02:00
|
|
|
require 'rack/logger'
|
2009-12-26 21:00:18 +01:00
|
|
|
|
2010-06-14 06:09:24 +02:00
|
|
|
describe Rack::Logger do
|
|
|
|
should "log to rack.errors" do
|
2009-12-26 21:00:18 +01:00
|
|
|
app = lambda { |env|
|
|
|
|
log = env['rack.logger']
|
|
|
|
log.debug("Created logger")
|
|
|
|
log.info("Program started")
|
|
|
|
log.warn("Nothing to do!")
|
|
|
|
|
|
|
|
[200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]]
|
|
|
|
}
|
|
|
|
|
|
|
|
errors = StringIO.new
|
2010-06-14 06:09:24 +02:00
|
|
|
Rack::Logger.new(app).call('rack.errors' => errors)
|
|
|
|
errors.string.should.match(/INFO -- : Program started/)
|
|
|
|
errors.string.should.match(/WARN -- : Nothing to do/)
|
2009-12-26 21:00:18 +01:00
|
|
|
end
|
|
|
|
end
|