2016-07-17 15:11:26 +00:00
|
|
|
require "./spec_helper"
|
|
|
|
|
|
|
|
describe "Kemal::InitHandler" do
|
|
|
|
it "initializes context with Content-Type: text/html" do
|
|
|
|
request = HTTP::Request.new("GET", "/")
|
2016-11-22 20:29:10 +00:00
|
|
|
io = IO::Memory.new
|
2016-07-17 15:11:26 +00:00
|
|
|
response = HTTP::Server::Response.new(io)
|
|
|
|
context = HTTP::Server::Context.new(request, response)
|
2016-07-17 17:42:00 +00:00
|
|
|
Kemal::InitHandler::INSTANCE.next = ->(context : HTTP::Server::Context) {}
|
2016-07-17 15:11:26 +00:00
|
|
|
Kemal::InitHandler::INSTANCE.call(context)
|
|
|
|
context.response.headers["Content-Type"].should eq "text/html"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "initializes context with X-Powered-By: Kemal" do
|
|
|
|
request = HTTP::Request.new("GET", "/")
|
2016-11-22 20:29:10 +00:00
|
|
|
io = IO::Memory.new
|
2016-07-17 15:11:26 +00:00
|
|
|
response = HTTP::Server::Response.new(io)
|
|
|
|
context = HTTP::Server::Context.new(request, response)
|
|
|
|
Kemal::InitHandler::INSTANCE.call(context)
|
|
|
|
context.response.headers["X-Powered-By"].should eq "Kemal"
|
|
|
|
end
|
|
|
|
end
|