Refactor global namespace DSL into OOP Kemal::Base

This commit is contained in:
Johannes Müller 2017-07-16 19:16:12 +02:00 committed by sdogruyol
parent a5d8df7382
commit aaa2109837
25 changed files with 420 additions and 387 deletions

View file

@ -6,8 +6,9 @@ describe "Kemal::InitHandler" do
io = IO::Memory.new
response = HTTP::Server::Response.new(io)
context = HTTP::Server::Context.new(request, response)
Kemal::InitHandler::INSTANCE.next = ->(_context : HTTP::Server::Context) {}
Kemal::InitHandler::INSTANCE.call(context)
init_handler = Kemal::InitHandler.new(Kemal::Base.new)
init_handler.next = ->(context : HTTP::Server::Context) {}
init_handler.call(context)
context.response.headers["Content-Type"].should eq "text/html"
end
@ -16,7 +17,8 @@ describe "Kemal::InitHandler" do
io = IO::Memory.new
response = HTTP::Server::Response.new(io)
context = HTTP::Server::Context.new(request, response)
Kemal::InitHandler::INSTANCE.call(context)
init_handler = Kemal::InitHandler.new(Kemal::Base.new)
init_handler.call(context)
context.response.headers["X-Powered-By"].should eq "Kemal"
end