2015-11-14 21:45:20 +00:00
|
|
|
require "./spec_helper"
|
|
|
|
|
|
|
|
describe "Config" do
|
|
|
|
it "sets default port to 3000" do
|
2018-06-18 12:07:54 +00:00
|
|
|
Kemal::Config.new.port.should eq 3000
|
2015-11-14 21:45:20 +00:00
|
|
|
end
|
|
|
|
|
2015-11-18 20:45:49 +00:00
|
|
|
it "sets default environment to development" do
|
2018-06-18 12:07:54 +00:00
|
|
|
Kemal::Config.new.env.should eq "development"
|
2015-11-18 20:45:49 +00:00
|
|
|
end
|
|
|
|
|
2016-01-03 14:04:11 +00:00
|
|
|
it "sets environment to production" do
|
2015-11-18 20:45:49 +00:00
|
|
|
config = Kemal.config
|
|
|
|
config.env = "production"
|
|
|
|
config.env.should eq "production"
|
|
|
|
end
|
|
|
|
|
2018-05-09 07:19:59 +00:00
|
|
|
it "sets default powered_by_header to true" do
|
2018-06-18 12:07:54 +00:00
|
|
|
Kemal::Config.new.powered_by_header.should be_true
|
2018-05-09 07:19:59 +00:00
|
|
|
end
|
|
|
|
|
2016-01-03 14:04:11 +00:00
|
|
|
it "sets host binding" do
|
|
|
|
config = Kemal.config
|
|
|
|
config.host_binding = "127.0.0.1"
|
|
|
|
config.host_binding.should eq "127.0.0.1"
|
|
|
|
end
|
|
|
|
|
2018-07-15 22:36:06 +00:00
|
|
|
it "adds a custom handler" do
|
2015-11-14 21:45:20 +00:00
|
|
|
config = Kemal.config
|
|
|
|
config.add_handler CustomTestHandler.new
|
2017-07-11 08:22:35 +00:00
|
|
|
Kemal.config.setup
|
2017-09-10 11:41:07 +00:00
|
|
|
config.handlers.size.should eq(7)
|
2015-11-14 21:45:20 +00:00
|
|
|
end
|
2016-03-22 21:13:49 +00:00
|
|
|
|
2017-01-18 12:55:33 +00:00
|
|
|
it "toggles the shutdown message" do
|
|
|
|
config = Kemal.config
|
|
|
|
config.shutdown_message = false
|
|
|
|
config.shutdown_message.should eq false
|
|
|
|
config.shutdown_message = true
|
|
|
|
config.shutdown_message.should eq true
|
|
|
|
end
|
|
|
|
|
2016-03-22 21:13:49 +00:00
|
|
|
it "adds custom options" do
|
|
|
|
config = Kemal.config
|
|
|
|
ARGV.push("--test")
|
|
|
|
ARGV.push("FOOBAR")
|
2016-07-04 17:23:16 +00:00
|
|
|
test_option = nil
|
2016-03-22 21:13:49 +00:00
|
|
|
|
2016-07-04 17:23:16 +00:00
|
|
|
config.extra_options do |parser|
|
2016-03-22 21:13:49 +00:00
|
|
|
parser.on("--test TEST_OPTION", "Test an option") do |opt|
|
2016-07-04 17:23:16 +00:00
|
|
|
test_option = opt
|
2016-03-22 21:13:49 +00:00
|
|
|
end
|
2016-07-04 17:23:16 +00:00
|
|
|
end
|
2016-03-22 21:13:49 +00:00
|
|
|
Kemal::CLI.new
|
2016-07-04 17:23:16 +00:00
|
|
|
test_option.should eq("FOOBAR")
|
2016-03-22 21:13:49 +00:00
|
|
|
end
|
2018-07-15 22:22:50 +00:00
|
|
|
|
|
|
|
it "returns a string" do
|
|
|
|
Kemal::VERSION.should be_a(String)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "gets the version from shards.yml" do
|
|
|
|
Kemal::VERSION.should eq("0.23.0")
|
|
|
|
end
|
2015-11-14 21:45:20 +00:00
|
|
|
end
|