mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Start implementing error block
This commit is contained in:
parent
35239dfaa0
commit
e6d9311895
7 changed files with 71 additions and 25 deletions
|
@ -2,10 +2,27 @@ require "./spec_helper"
|
|||
|
||||
describe "Kemal::CommonExceptionHandler" do
|
||||
it "renders 404 on route not found" do
|
||||
common_exception_handler = Kemal::CommonExceptionHandler::INSTANCE
|
||||
request = HTTP::Request.new("GET", "/?message=world")
|
||||
io_with_context = create_request_and_return_io(common_exception_handler, request)
|
||||
client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false)
|
||||
get "/" do |env|
|
||||
"Hello"
|
||||
end
|
||||
|
||||
request = HTTP::Request.new("GET", "/asd")
|
||||
client_response = call_request_on_app(request)
|
||||
client_response.status_code.should eq 404
|
||||
end
|
||||
|
||||
it "renders custom error" do
|
||||
error 403 do
|
||||
"403 error"
|
||||
end
|
||||
|
||||
get "/" do |env|
|
||||
env.response.status_code = 403
|
||||
end
|
||||
|
||||
request = HTTP::Request.new("GET", "/")
|
||||
client_response = call_request_on_app(request)
|
||||
client_response.status_code.should eq 403
|
||||
client_response.body.should eq "403 error"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue