mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Add class method API to Kemal::Base
This commit is contained in:
		
							parent
							
								
									2e42b3f48c
								
							
						
					
					
						commit
						53fa65f964
					
				
					 4 changed files with 62 additions and 9 deletions
				
			
		
							
								
								
									
										27
									
								
								spec/application_mode_spec.cr
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								spec/application_mode_spec.cr
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| require "./spec_helper" | ||||
| 
 | ||||
| private class MyApp < Kemal::Application | ||||
|   get "/route1" do |env| | ||||
|     "Route 1" | ||||
|   end | ||||
| 
 | ||||
|   get "/route2" do |env| | ||||
|     "Route 2" | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| describe MyApp do | ||||
|   it "matches the correct route" do | ||||
|     request = HTTP::Request.new("GET", "/route2") | ||||
|     client_response = call_request_on_app(MyApp.new, request) | ||||
|     client_response.body.should eq("Route 2") | ||||
|   end | ||||
| 
 | ||||
|   it "doesn't allow a route declaration start without /" do | ||||
|     expect_raises Kemal::Exceptions::InvalidPathStartException, "Route declaration get \"route\" needs to start with '/', should be get \"/route\"" do | ||||
|       MyApp.new.get "route" do |env| | ||||
|         "Route 1" | ||||
|       end | ||||
|     end | ||||
|   end | ||||
| end | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue