diff --git a/spec/dsl_helpers_spec.cr b/spec/dsl_helpers_spec.cr new file mode 100644 index 0000000..338e154 --- /dev/null +++ b/spec/dsl_helpers_spec.cr @@ -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 diff --git a/spec/helpers_spec.cr b/spec/helpers_spec.cr index b03cbc9..d5139cd 100644 --- a/spec/helpers_spec.cr +++ b/spec/helpers_spec.cr @@ -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