Add macro specs
This commit is contained in:
parent
806b129b1c
commit
c21567fe17
5 changed files with 20 additions and 6 deletions
|
@ -28,9 +28,4 @@ describe "Config" do
|
|||
config.add_handler CustomTestHandler.new
|
||||
config.handlers.size.should eq(1)
|
||||
end
|
||||
|
||||
it "sets public folder" do
|
||||
public_folder "/some/path/to/folder"
|
||||
Kemal.config.public_folder.should eq("/some/path/to/folder")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,7 @@ describe "Logger" do
|
|||
logger = Kemal::Logger.new
|
||||
logger.handler.should be_a File
|
||||
end
|
||||
|
||||
it "writes to a file in production" do
|
||||
config = Kemal.config
|
||||
config.env = "production"
|
||||
|
|
17
spec/macros_spec.cr
Normal file
17
spec/macros_spec.cr
Normal file
|
@ -0,0 +1,17 @@
|
|||
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
|
||||
end
|
|
@ -6,4 +6,5 @@ include Kemal
|
|||
|
||||
Spec.before_each do
|
||||
Kemal.config.env = "development"
|
||||
Kemal.config.handlers.clear
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ end
|
|||
|
||||
# Uses Kemal::Middleware::HTTPBasicAuth to easily add HTTP Basic Auth support.
|
||||
macro basic_auth(username, password)
|
||||
auth_handler = Kemal::Middleware::HTTPBasicAuth.new(username, password)
|
||||
auth_handler = Kemal::Middleware::HTTPBasicAuth.new({{username}}, {{password}})
|
||||
Kemal.config.add_handler auth_handler
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue