2016-07-28 18:12:55 +00:00
|
|
|
require "./spec_helper"
|
|
|
|
|
|
|
|
describe "Kemal::CommonLogHandler" do
|
|
|
|
it "logs to the given IO" do
|
|
|
|
config = Kemal.config
|
2016-11-22 20:29:10 +00:00
|
|
|
io = IO::Memory.new
|
2016-07-28 18:12:55 +00:00
|
|
|
logger = Kemal::CommonLogHandler.new io
|
|
|
|
logger.write "Something"
|
|
|
|
io.to_s.should eq "Something"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates log message for each request" do
|
|
|
|
request = HTTP::Request.new("GET", "/")
|
2016-11-22 20:29:10 +00:00
|
|
|
io = IO::Memory.new
|
|
|
|
context_io = IO::Memory.new
|
2016-07-28 18:12:55 +00:00
|
|
|
response = HTTP::Server::Response.new(context_io)
|
|
|
|
context = HTTP::Server::Context.new(request, response)
|
|
|
|
logger = Kemal::CommonLogHandler.new io
|
|
|
|
logger.call(context)
|
|
|
|
io.to_s.should_not be nil
|
|
|
|
end
|
|
|
|
end
|