From d7381d2d96deeb95aac484780b38202b1a7d8115 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 2 Oct 2009 00:25:01 -0700 Subject: configurator: listen :delay must be Numeric :delay may be a Float to represent fractional seconds. --- test/unit/test_configurator.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/unit/test_configurator.rb') diff --git a/test/unit/test_configurator.rb b/test/unit/test_configurator.rb index 9e18728..caa985e 100644 --- a/test/unit/test_configurator.rb +++ b/test/unit/test_configurator.rb @@ -99,6 +99,36 @@ class TestConfigurator < Test::Unit::TestCase end end + def test_listen_option_bad_delay + tmp = Tempfile.new('unicorn_config') + expect = { :delay => "five" } + listener = "127.0.0.1:12345" + tmp.syswrite("listen '#{listener}', #{expect.inspect}\n") + assert_raises(ArgumentError) do + Unicorn::Configurator.new(:config_file => tmp.path) + end + end + + def test_listen_option_float_delay + tmp = Tempfile.new('unicorn_config') + expect = { :delay => 0.5 } + listener = "127.0.0.1:12345" + tmp.syswrite("listen '#{listener}', #{expect.inspect}\n") + assert_nothing_raised do + Unicorn::Configurator.new(:config_file => tmp.path) + end + end + + def test_listen_option_int_delay + tmp = Tempfile.new('unicorn_config') + expect = { :delay => 5 } + listener = "127.0.0.1:12345" + tmp.syswrite("listen '#{listener}', #{expect.inspect}\n") + assert_nothing_raised do + Unicorn::Configurator.new(:config_file => tmp.path) + end + end + def test_after_fork_proc test_struct = TestStruct.new [ proc { |a,b| }, Proc.new { |a,b| }, lambda { |a,b| } ].each do |my_proc| -- cgit v1.2.3-24-ge0c7