Add 500 exception spec

This commit is contained in:
Sdogruyol 2015-12-01 21:52:44 +02:00
parent 7f198cab3b
commit 171459eee9
2 changed files with 11 additions and 1 deletions

View file

@ -109,4 +109,15 @@ describe "Kemal::Handler" do
response = kemal.call(request)
response.status_code.should eq 404
end
it "renders 500 on exception" do
kemal = Kemal::Handler.new
kemal.add_route "GET", "/" do
raise "Exception"
end
request = HTTP::Request.new("GET", "/?message=world")
response = kemal.call(request)
response.status_code.should eq 500
response.body.includes?("Exception").should eq true
end
end

View file

@ -33,7 +33,6 @@ class Kemal::Handler < HTTP::Handler
end
# Render 404 unless a route matches
return render_404
nil
end
def render_404