mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Refactor spec helper classes locations and visibility
This commit is contained in:
		
							parent
							
								
									ad91a22789
								
							
						
					
					
						commit
						5d65bcb3b9
					
				
					 5 changed files with 35 additions and 28 deletions
				
			
		|  | @ -1,5 +1,12 @@ | ||||||
| require "./spec_helper" | require "./spec_helper" | ||||||
| 
 | 
 | ||||||
|  | private class CustomTestHandler < Kemal::Handler | ||||||
|  |   def call(env) | ||||||
|  |     env.response << "Kemal" | ||||||
|  |     call_next env | ||||||
|  |   end | ||||||
|  | end | ||||||
|  | 
 | ||||||
| describe "Config" do | describe "Config" do | ||||||
|   it "sets default port to 3000" do |   it "sets default port to 3000" do | ||||||
|     config = Kemal::Config.new |     config = Kemal::Config.new | ||||||
|  |  | ||||||
|  | @ -12,23 +12,6 @@ class CustomLogHandler < Kemal::BaseLogHandler | ||||||
|   end |   end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| class TestContextStorageType |  | ||||||
|   property id |  | ||||||
|   @id = 1 |  | ||||||
| 
 |  | ||||||
|   def to_s |  | ||||||
|     @id |  | ||||||
|   end |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| class AnotherContextStorageType |  | ||||||
|   property name |  | ||||||
|   @name = "kemal-context" |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| add_context_storage_type(TestContextStorageType) |  | ||||||
| add_context_storage_type(AnotherContextStorageType) |  | ||||||
| 
 |  | ||||||
| def create_request_and_return_io(handler, request) | def create_request_and_return_io(handler, request) | ||||||
|   io = IO::Memory.new |   io = IO::Memory.new | ||||||
|   response = HTTP::Server::Response.new(io) |   response = HTTP::Server::Response.new(io) | ||||||
|  |  | ||||||
|  | @ -1,13 +1,13 @@ | ||||||
| require "./spec_helper" | require "./spec_helper" | ||||||
| 
 | 
 | ||||||
| class CustomTestHandler < Kemal::Handler | private class CustomTestHandler < Kemal::Handler | ||||||
|   def call(env) |   def call(env) | ||||||
|     env.response << "Kemal" |     env.response << "Kemal" | ||||||
|     call_next env |     call_next env | ||||||
|   end |   end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| class OnlyHandler < Kemal::Handler | private class OnlyHandler < Kemal::Handler | ||||||
|   only ["/only"] |   only ["/only"] | ||||||
| 
 | 
 | ||||||
|   def call(env) |   def call(env) | ||||||
|  | @ -17,7 +17,7 @@ class OnlyHandler < Kemal::Handler | ||||||
|   end |   end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| class ExcludeHandler < Kemal::Handler | private class ExcludeHandler < Kemal::Handler | ||||||
|   exclude ["/exclude"] |   exclude ["/exclude"] | ||||||
| 
 | 
 | ||||||
|   def call(env) |   def call(env) | ||||||
|  | @ -27,7 +27,7 @@ class ExcludeHandler < Kemal::Handler | ||||||
|   end |   end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| class PostOnlyHandler < Kemal::Handler | private class PostOnlyHandler < Kemal::Handler | ||||||
|   only ["/only", "/route1", "/route2"], "POST" |   only ["/only", "/route1", "/route2"], "POST" | ||||||
| 
 | 
 | ||||||
|   def call(env) |   def call(env) | ||||||
|  | @ -37,7 +37,7 @@ class PostOnlyHandler < Kemal::Handler | ||||||
|   end |   end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| class PostExcludeHandler < Kemal::Handler | private class PostExcludeHandler < Kemal::Handler | ||||||
|   exclude ["/exclude"], "POST" |   exclude ["/exclude"], "POST" | ||||||
| 
 | 
 | ||||||
|   def call(env) |   def call(env) | ||||||
|  |  | ||||||
|  | @ -1,13 +1,13 @@ | ||||||
| require "./spec_helper" | require "./spec_helper" | ||||||
| 
 | 
 | ||||||
| describe "Macros" do | private class CustomTestHandler < Kemal::Handler | ||||||
|   describe "#public_folder" do |   def call(env) | ||||||
|     it "sets public folder" do |     env.response << "Kemal" | ||||||
|       public_folder "/some/path/to/folder" |     call_next env | ||||||
|       Kemal.config.public_folder.should eq("/some/path/to/folder") |  | ||||||
|     end |  | ||||||
|   end |   end | ||||||
|  | end | ||||||
| 
 | 
 | ||||||
|  | describe "Macros" do | ||||||
|   describe "#add_handler" do |   describe "#add_handler" do | ||||||
|     it "adds a custom handler" do |     it "adds a custom handler" do | ||||||
|       app = Kemal::Application.new |       app = Kemal::Application.new | ||||||
|  |  | ||||||
|  | @ -1,6 +1,23 @@ | ||||||
| require "spec" | require "spec" | ||||||
| require "../src/kemal" | require "../src/kemal" | ||||||
| 
 | 
 | ||||||
|  | class TestContextStorageType | ||||||
|  |   property id | ||||||
|  |   @id = 1 | ||||||
|  | 
 | ||||||
|  |   def to_s | ||||||
|  |     @id | ||||||
|  |   end | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | class AnotherContextStorageType | ||||||
|  |   property name | ||||||
|  |   @name = "kemal-context" | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | Kemal::Macros.add_context_storage_type(TestContextStorageType) | ||||||
|  | Kemal::Macros.add_context_storage_type(AnotherContextStorageType) | ||||||
|  | 
 | ||||||
| def call_request_on_app(app, request) | def call_request_on_app(app, request) | ||||||
|   io = IO::Memory.new |   io = IO::Memory.new | ||||||
|   response = HTTP::Server::Response.new(io) |   response = HTTP::Server::Response.new(io) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue