diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-02 00:25:01 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-02 00:26:10 -0700 |
commit | d7381d2d96deeb95aac484780b38202b1a7d8115 (patch) | |
tree | 5679cae34e44bcdcb7d5b14bf678ba3fe241fa25 | |
parent | 62206b128f71f64a684a5e14103178dc6a516125 (diff) | |
download | unicorn-d7381d2d96deeb95aac484780b38202b1a7d8115.tar.gz |
:delay may be a Float to represent fractional seconds.
-rw-r--r-- | lib/unicorn/configurator.rb | 4 | ||||
-rw-r--r-- | test/unit/test_configurator.rb | 30 |
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index bff8f7e..77a55ad 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -277,9 +277,9 @@ module Unicorn TrueClass === value || FalseClass === value or raise ArgumentError, "not boolean: #{key}=#{value.inspect}" end - unless (value = opt[:tries]).nil? + unless (value = opt[:delay]).nil? Numeric === value or - raise ArgumentError, "not numeric: #{key}=#{value.inspect}" + raise ArgumentError, "not numeric: delay=#{value.inspect}" end set[:listener_opts][address].merge!(opt) end 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| |