From 5f834f8873e8cfd1b838406c5273a1fae7f4f10f Mon Sep 17 00:00:00 2001 From: Serdar Dogruyol Date: Sun, 10 Sep 2017 15:04:51 +0300 Subject: [PATCH] Use expect_raises for websocket handler spec --- spec/websocket_handler_spec.cr | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/spec/websocket_handler_spec.cr b/spec/websocket_handler_spec.cr index a3573a5..1e454ad 100644 --- a/spec/websocket_handler_spec.cr +++ b/spec/websocket_handler_spec.cr @@ -3,7 +3,7 @@ require "./spec_helper" describe "Kemal::WebSocketHandler" do it "doesn't match on wrong route" do handler = Kemal::WebSocketHandler::INSTANCE - handler.next = Kemal::CommonExceptionHandler::INSTANCE + handler.next = Kemal::RouteHandler::INSTANCE ws "/" { } headers = HTTP::Headers{ "Upgrade" => "websocket", @@ -14,15 +14,10 @@ describe "Kemal::WebSocketHandler" do io = IO::Memory.new response = HTTP::Server::Response.new(io) context = HTTP::Server::Context.new(request, response) - begin + + expect_raises(Kemal::Exceptions::RouteNotFound) do handler.call context - rescue IO::Error - # Raises because the IO::Memory is empty end - response.close - io.rewind - client_response = HTTP::Client::Response.from_io(io, decompress: false) - client_response.status_code.should eq(404) end it "matches on given route" do