mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Rebased to master and update to Crystal 0.27.0
This commit is contained in:
		
							parent
							
								
									4fefd9cb5c
								
							
						
					
					
						commit
						678adaa375
					
				
					 12 changed files with 71 additions and 136 deletions
				
			
		|  | @ -1,4 +1,4 @@ | |||
| require "../spec_helper" | ||||
| require "../dsl_helper" | ||||
| 
 | ||||
| describe "Kemal::FilterHandler" do | ||||
|   it "executes code before home request" do | ||||
|  | @ -13,8 +13,8 @@ describe "Kemal::FilterHandler" do | |||
| 
 | ||||
|     test_filter.modified.should eq("false") | ||||
|     request = HTTP::Request.new("GET", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("true") | ||||
|   end | ||||
|  | @ -33,14 +33,14 @@ describe "Kemal::FilterHandler" do | |||
|     test_filter.modified.should eq("false") | ||||
| 
 | ||||
|     request = HTTP::Request.new("GET", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("true") | ||||
| 
 | ||||
|     request = HTTP::Request.new("POST", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("true") | ||||
|   end | ||||
|  | @ -61,14 +61,14 @@ describe "Kemal::FilterHandler" do | |||
|     test_filter.modified.should eq("false") | ||||
| 
 | ||||
|     request = HTTP::Request.new("GET", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("false") | ||||
| 
 | ||||
|     request = HTTP::Request.new("POST", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("false") | ||||
|   end | ||||
|  | @ -85,14 +85,14 @@ describe "Kemal::FilterHandler" do | |||
| 
 | ||||
|     test_filter.modified.should eq("false") | ||||
|     request = HTTP::Request.new("GET", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("true") | ||||
|   end | ||||
| 
 | ||||
|   it "executes code after GET home request but not POST home request" do | ||||
|     test_filter = FilterTest.new | ||||
|         test_filter = FilterTest.new | ||||
|     test_filter.modified = "false" | ||||
| 
 | ||||
|     filter_middleware = Kemal::FilterHandler.new(Kemal.application) | ||||
|  | @ -105,20 +105,20 @@ describe "Kemal::FilterHandler" do | |||
|     test_filter.modified.should eq("false") | ||||
| 
 | ||||
|     request = HTTP::Request.new("GET", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("true") | ||||
| 
 | ||||
|     request = HTTP::Request.new("POST", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("true") | ||||
|   end | ||||
| 
 | ||||
|   it "executes code after all GET/POST home request" do | ||||
|     test_filter = FilterTest.new | ||||
|         test_filter = FilterTest.new | ||||
|     test_filter.modified = "false" | ||||
| 
 | ||||
|     filter_middleware = Kemal::FilterHandler.new(Kemal.application) | ||||
|  | @ -132,14 +132,14 @@ describe "Kemal::FilterHandler" do | |||
| 
 | ||||
|     test_filter.modified.should eq("false") | ||||
|     request = HTTP::Request.new("GET", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("false") | ||||
| 
 | ||||
|     request = HTTP::Request.new("POST", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("false") | ||||
|   end | ||||
|  | @ -166,20 +166,20 @@ describe "Kemal::FilterHandler" do | |||
|     test_filter_second.modified.should eq("false") | ||||
|     test_filter_third.modified.should eq("false") | ||||
|     request = HTTP::Request.new("GET", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("true") | ||||
| 
 | ||||
|     request = HTTP::Request.new("POST", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("false") | ||||
| 
 | ||||
|     request = HTTP::Request.new("PUT", "/greetings") | ||||
|     create_request_and_return_io_and_context(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io_and_context(kemal, request)[0] | ||||
|     create_request_and_return_io(filter_middleware, request) | ||||
|     io_with_context = create_request_and_return_io(kemal, request) | ||||
|     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||
|     client_response.body.should eq("true") | ||||
|   end | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue