kemal/spec/config_spec.cr

47 lines
1 KiB
Crystal
Raw Normal View History

2015-11-14 21:45:20 +00:00
require "./spec_helper"
describe "Config" do
it "sets default port to 3000" do
config = Kemal.config
config.port.should eq 3000
end
2015-11-18 20:45:49 +00:00
it "sets default environment to development" do
config = Kemal.config
config.env.should eq "development"
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
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
2015-11-14 21:45:20 +00:00
it "adds a custom handler" do
config = Kemal.config
config.add_handler CustomTestHandler.new
2016-03-21 16:29:48 +00:00
config.handlers.size.should eq(5)
2015-11-14 21:45:20 +00:00
end
it "adds custom options" do
config = Kemal.config
ARGV.push("--test")
ARGV.push("FOOBAR")
$test_option = nil
2016-05-08 00:18:42 +00:00
config.extra_options = ->(parser : OptionParser) {
parser.on("--test TEST_OPTION", "Test an option") do |opt|
$test_option = opt
end
}
Kemal::CLI.new
$test_option.should eq("FOOBAR")
end
2015-11-14 21:45:20 +00:00
end