Replace global macros with methods. Thanks @asterite

This commit is contained in:
Sdogruyol 2016-02-14 18:52:49 +02:00
parent 092f5a2e49
commit 8c87a3fa67
2 changed files with 13 additions and 14 deletions

37
spec/helpers_spec.cr Normal file
View file

@ -0,0 +1,37 @@
require "./spec_helper"
describe "Macros" do
describe "#basic_auth" do
it "adds HTTPBasicAuthHandler" do
basic_auth "serdar", "123"
Kemal.config.handlers.size.should eq 1
end
end
describe "#public_folder" do
it "sets public folder" do
public_folder "/some/path/to/folder"
Kemal.config.public_folder.should eq("/some/path/to/folder")
end
end
describe "#add_handler" do
it "adds a custom handler" do
add_handler CustomTestHandler.new
Kemal.config.handlers.size.should eq 1
end
end
describe "#logging" do
it "sets logging status" do
logging false
Kemal.config.logging.should eq false
end
it "sets a custom logger" do
config = Kemal::Config::INSTANCE
logger CustomLogHandler.new("production")
config.handlers.first.should be_a(CustomLogHandler)
config.logger.should be_a(CustomLogHandler)
end
end
end