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"
|
||||
|
||||
private class CustomTestHandler < Kemal::Handler
|
||||
def call(env)
|
||||
env.response << "Kemal"
|
||||
call_next env
|
||||
end
|
||||
end
|
||||
|
||||
describe "Config" do
|
||||
it "sets default port to 3000" do
|
||||
config = Kemal::Config.new
|
||||
|
|
|
@ -12,23 +12,6 @@ class CustomLogHandler < Kemal::BaseLogHandler
|
|||
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)
|
||||
io = IO::Memory.new
|
||||
response = HTTP::Server::Response.new(io)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
require "./spec_helper"
|
||||
|
||||
class CustomTestHandler < Kemal::Handler
|
||||
private class CustomTestHandler < Kemal::Handler
|
||||
def call(env)
|
||||
env.response << "Kemal"
|
||||
call_next env
|
||||
end
|
||||
end
|
||||
|
||||
class OnlyHandler < Kemal::Handler
|
||||
private class OnlyHandler < Kemal::Handler
|
||||
only ["/only"]
|
||||
|
||||
def call(env)
|
||||
|
@ -17,7 +17,7 @@ class OnlyHandler < Kemal::Handler
|
|||
end
|
||||
end
|
||||
|
||||
class ExcludeHandler < Kemal::Handler
|
||||
private class ExcludeHandler < Kemal::Handler
|
||||
exclude ["/exclude"]
|
||||
|
||||
def call(env)
|
||||
|
@ -27,7 +27,7 @@ class ExcludeHandler < Kemal::Handler
|
|||
end
|
||||
end
|
||||
|
||||
class PostOnlyHandler < Kemal::Handler
|
||||
private class PostOnlyHandler < Kemal::Handler
|
||||
only ["/only", "/route1", "/route2"], "POST"
|
||||
|
||||
def call(env)
|
||||
|
@ -37,7 +37,7 @@ class PostOnlyHandler < Kemal::Handler
|
|||
end
|
||||
end
|
||||
|
||||
class PostExcludeHandler < Kemal::Handler
|
||||
private class PostExcludeHandler < Kemal::Handler
|
||||
exclude ["/exclude"], "POST"
|
||||
|
||||
def call(env)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
require "./spec_helper"
|
||||
|
||||
describe "Macros" do
|
||||
describe "#public_folder" do
|
||||
it "sets public folder" do
|
||||
public_folder "/some/path/to/folder"
|
||||
Kemal.config.public_folder.should eq("/some/path/to/folder")
|
||||
end
|
||||
private class CustomTestHandler < Kemal::Handler
|
||||
def call(env)
|
||||
env.response << "Kemal"
|
||||
call_next env
|
||||
end
|
||||
end
|
||||
|
||||
describe "Macros" do
|
||||
describe "#add_handler" do
|
||||
it "adds a custom handler" do
|
||||
app = Kemal::Application.new
|
||||
|
|
|
@ -1,6 +1,23 @@
|
|||
require "spec"
|
||||
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)
|
||||
io = IO::Memory.new
|
||||
response = HTTP::Server::Response.new(io)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue