test/clockwork_test.rb in clockwork-0.5.0 vs test/clockwork_test.rb in clockwork-0.5.1

- old
+ new

@@ -150,18 +150,22 @@ test "event-specific handler" do $set_me = 0 Clockwork.every(1.minute, 'myjob') { $set_me = 2 } Clockwork.tick(Time.now) + assert_equal 2, $set_me end test "exceptions are trapped and logged" do Clockwork.handler { raise 'boom' } event = Clockwork.every(1.minute, 'myjob') event.expects(:log_error) - assert_nothing_raised { Clockwork.tick(Time.now) } + + assert_nothing_raised do + Clockwork.tick(Time.now) + end end test "exceptions still set the last timestamp to avoid spastic error loops" do Clockwork.handler { raise 'boom' } event = Clockwork.every(1.minute, 'myjob') @@ -172,19 +176,22 @@ test "should be configurable" do Clockwork.configure do |config| config[:sleep_timeout] = 200 config[:logger] = "A Logger" + config[:max_threads] = 10 end assert_equal 200, Clockwork.config[:sleep_timeout] assert_equal "A Logger", Clockwork.config[:logger] + assert_equal 10, Clockwork.config[:max_threads] end test "configuration should have reasonable defaults" do assert_equal 1, Clockwork.config[:sleep_timeout] assert Clockwork.config[:logger].is_a?(Logger) + assert_equal 10, Clockwork.config[:max_threads] end test "should be able to specify a different timezone than local" do Clockwork.every(1.day, 'myjob', :at => '10:00', :tz => 'UTC') @@ -239,8 +246,19 @@ test ":if is not callable then raise ArgumentError" do assert_raise(ArgumentError) do Clockwork.every(1.second, 'myjob', :if => true) end + end + + test "should warn about missing jobs upon exhausting threads" do + Clockwork.configure do |config| + config[:max_threads] = 0 + end + + event = Clockwork.every(1.minute, 'myjob', :thread => true) + event.expects(:log_error).with("Threads exhausted; skipping #{event}") + + Clockwork.tick(Time.now) end end