Refactor dsl_helper_spec

This commit is contained in:
Johannes Müller 2017-07-20 15:24:09 +02:00 committed by sdogruyol
parent 5d65bcb3b9
commit 34022273b2
2 changed files with 47 additions and 12 deletions

47
spec/dsl_helpers_spec.cr Normal file
View file

@ -0,0 +1,47 @@
require "./dsl_helper"
describe "Macros" do
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 "#logging" do
it "sets logging status" do
logging false
Kemal.config.logging?.should be_false
end
it "sets a custom logger" do
logger CustomLogHandler.new
Kemal.application.logger.should be_a(CustomLogHandler)
end
end
describe "#gzip" do
it "adds HTTP::CompressHandler to handlers" do
gzip true
Kemal.application.setup
Kemal.application.handlers[4].should be_a(HTTP::CompressHandler)
end
end
describe "#serve_static" do
it "should disable static file hosting" do
serve_static false
Kemal.config.serve_static.should be_false
end
it "should disble enable gzip and dir_listing" do
serve_static({"gzip" => true, "dir_listing" => true})
conf = Kemal.config.serve_static
conf.is_a?(Hash).should be_true
if conf.is_a?(Hash)
conf["gzip"].should be_true
conf["dir_listing"].should be_true
end
end
end
end

View file

@ -17,18 +17,6 @@ describe "Macros" do
end
end
describe "#logging" do
it "sets logging status" do
logging false
Kemal.config.logging?.should be_false
end
it "sets a custom logger" do
logger CustomLogHandler.new
Kemal.application.logger.should be_a(CustomLogHandler)
end
end
describe "#halt" do
it "can break block with halt macro" do
app = Kemal::Base.new