From 7858fd6334328cec6a214305200cdc7dd7c17089 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Wed, 3 Apr 2024 17:46:03 +0200 Subject: [PATCH] Add specs --- spec/init_handler_spec.cr | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/init_handler_spec.cr b/spec/init_handler_spec.cr index 601bbc1d..ee1c8624 100644 --- a/spec/init_handler_spec.cr +++ b/spec/init_handler_spec.cr @@ -11,6 +11,17 @@ describe "Kemal::InitHandler" do context.response.headers["Content-Type"].should eq "text/html" end + it "initializes context with Date header" do + request = HTTP::Request.new("GET", "/") + 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) + date = context.response.headers["Date"]?.should_not be_nil + Time.parse_rfc2822(date).should be_close(Time.utc, 1.second) + end + it "initializes context with X-Powered-By: Kemal" do request = HTTP::Request.new("GET", "/") io = IO::Memory.new