mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Use expect_raises for websocket handler spec
This commit is contained in:
		
							parent
							
								
									fe9d193418
								
							
						
					
					
						commit
						5f834f8873
					
				
					 1 changed files with 3 additions and 8 deletions
				
			
		|  | @ -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…
	
	Add table
		Add a link
		
	
		Reference in a new issue