Updated logger to be more robust

This commit is contained in:
Sdogruyol 2015-11-18 22:45:49 +02:00
parent 639d4a7a48
commit 28d4d5167b
6 changed files with 39 additions and 16 deletions

View file

@ -12,6 +12,17 @@ describe "Config" do
config.port.should eq 3000
end
it "sets default environment to development" do
config = Kemal.config
config.env.should eq "development"
end
it "set environment to production" do
config = Kemal.config
config.env = "production"
config.env.should eq "production"
end
it "adds a custom handler" do
config = Kemal.config
config.add_handler CustomTestHandler.new

View file

@ -1,11 +1,16 @@
require "./spec_helper"
describe "Logger" do
it "logs stuff" do
# IO.pipe do |r, w|
# logger = Kemal::Logger.new(w)
# logger.info "Info from logger"
# r.gets.should match(/Info from logger/)
# end
it "creates a STDOUT handler by default" do
config = Kemal.config
logger = Kemal::Logger.new
logger.handler.should be_a IO
end
it "creates a file handler in production" do
config = Kemal.config
config.env = "production"
logger = Kemal::Logger.new
logger.handler.should be_a File
end
end