mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Added context specs
This commit is contained in:
parent
ad6baba12b
commit
5376eb8bb2
5 changed files with 36 additions and 27 deletions
23
spec/context_spec.cr
Normal file
23
spec/context_spec.cr
Normal file
|
@ -0,0 +1,23 @@
|
|||
require "./spec_helper"
|
||||
|
||||
describe "Context" do
|
||||
it "has a default content type" do
|
||||
kemal = Kemal::Handler.new
|
||||
kemal.add_route "GET", "/" do |env|
|
||||
"Hello"
|
||||
end
|
||||
request = HTTP::Request.new("GET", "/")
|
||||
response = kemal.call(request)
|
||||
response.headers["Content-Type"].should eq("text/plain")
|
||||
end
|
||||
|
||||
it "sets content type" do
|
||||
kemal = Kemal::Handler.new
|
||||
kemal.add_route "GET", "/" do |env|
|
||||
env.set_content_type "application/json"
|
||||
end
|
||||
request = HTTP::Request.new("GET", "/")
|
||||
response = kemal.call(request)
|
||||
response.headers["Content-Type"].should eq("application/json")
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue