mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Refactor global namespace DSL into OOP Kemal::Base
This commit is contained in:
parent
a5d8df7382
commit
aaa2109837
25 changed files with 420 additions and 387 deletions
|
@ -2,15 +2,17 @@ require "./spec_helper"
|
|||
|
||||
describe "Config" do
|
||||
it "sets default port to 3000" do
|
||||
Kemal::Config.new.port.should eq 3000
|
||||
config = Kemal::Config.new
|
||||
config.port.should eq 3000
|
||||
end
|
||||
|
||||
it "sets default environment to development" do
|
||||
Kemal::Config.new.env.should eq "development"
|
||||
config = Kemal::Config.new
|
||||
config.env.should eq "development"
|
||||
end
|
||||
|
||||
it "sets environment to production" do
|
||||
config = Kemal.config
|
||||
config = Kemal::Config.new
|
||||
config.env = "production"
|
||||
config.env.should eq "production"
|
||||
end
|
||||
|
@ -20,28 +22,28 @@ describe "Config" do
|
|||
end
|
||||
|
||||
it "sets host binding" do
|
||||
config = Kemal.config
|
||||
config = Kemal::Config.new
|
||||
config.host_binding = "127.0.0.1"
|
||||
config.host_binding.should eq "127.0.0.1"
|
||||
end
|
||||
|
||||
it "adds a custom handler" do
|
||||
config = Kemal.config
|
||||
config.add_handler CustomTestHandler.new
|
||||
Kemal.config.setup
|
||||
config.handlers.size.should eq(7)
|
||||
application = Kemal::Base.new
|
||||
application.add_handler CustomTestHandler.new
|
||||
application.setup
|
||||
application.handlers.size.should eq(8)
|
||||
end
|
||||
|
||||
it "toggles the shutdown message" do
|
||||
config = Kemal.config
|
||||
config = Kemal::Config.new
|
||||
config.shutdown_message = false
|
||||
config.shutdown_message.should eq false
|
||||
config.shutdown_message?.should be_false
|
||||
config.shutdown_message = true
|
||||
config.shutdown_message.should eq true
|
||||
config.shutdown_message?.should be_true
|
||||
end
|
||||
|
||||
it "adds custom options" do
|
||||
config = Kemal.config
|
||||
config = Kemal::Config.new
|
||||
ARGV.push("--test")
|
||||
ARGV.push("FOOBAR")
|
||||
test_option = nil
|
||||
|
@ -51,7 +53,8 @@ describe "Config" do
|
|||
test_option = opt
|
||||
end
|
||||
end
|
||||
Kemal::CLI.new ARGV
|
||||
|
||||
Kemal::CLI.new(ARGV, config)
|
||||
test_option.should eq("FOOBAR")
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue