Use expect_raises for websocket handler spec
This commit is contained in:
parent
fe9d193418
commit
5f834f8873
|
@ -3,7 +3,7 @@ require "./spec_helper"
|
||||||
describe "Kemal::WebSocketHandler" do
|
describe "Kemal::WebSocketHandler" do
|
||||||
it "doesn't match on wrong route" do
|
it "doesn't match on wrong route" do
|
||||||
handler = Kemal::WebSocketHandler::INSTANCE
|
handler = Kemal::WebSocketHandler::INSTANCE
|
||||||
handler.next = Kemal::CommonExceptionHandler::INSTANCE
|
handler.next = Kemal::RouteHandler::INSTANCE
|
||||||
ws "/" { }
|
ws "/" { }
|
||||||
headers = HTTP::Headers{
|
headers = HTTP::Headers{
|
||||||
"Upgrade" => "websocket",
|
"Upgrade" => "websocket",
|
||||||
|
@ -14,15 +14,10 @@ describe "Kemal::WebSocketHandler" do
|
||||||
io = IO::Memory.new
|
io = IO::Memory.new
|
||||||
response = HTTP::Server::Response.new(io)
|
response = HTTP::Server::Response.new(io)
|
||||||
context = HTTP::Server::Context.new(request, response)
|
context = HTTP::Server::Context.new(request, response)
|
||||||
begin
|
|
||||||
|
expect_raises(Kemal::Exceptions::RouteNotFound) do
|
||||||
handler.call context
|
handler.call context
|
||||||
rescue IO::Error
|
|
||||||
# Raises because the IO::Memory is empty
|
|
||||||
end
|
end
|
||||||
response.close
|
|
||||||
io.rewind
|
|
||||||
client_response = HTTP::Client::Response.from_io(io, decompress: false)
|
|
||||||
client_response.status_code.should eq(404)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "matches on given route" do
|
it "matches on given route" do
|
||||||
|
|
Loading…
Reference in New Issue