test/cron_test.rb in rufus-scheduler-1.0.6 vs test/cron_test.rb in rufus-scheduler-1.0.7

- old
+ new

@@ -1,8 +1,8 @@ # -# Testing OpenWFE +# Testing Rufus # # John Mettraux at openwfe.org # # Sun Oct 29 16:18:25 JST 2006 # @@ -25,11 +25,11 @@ def test_0 $var = 0 - scheduler = OpenWFE::Scheduler.new + scheduler = Rufus::Scheduler.new scheduler.start sid = scheduler.schedule( '* * * * *', :schedulable => CounterSchedulable.new) @@ -44,11 +44,11 @@ assert_equal 2, $var end def test_1 - scheduler = OpenWFE::Scheduler.new + scheduler = Rufus::Scheduler.new scheduler.start sec = nil has_gone_wrong = false counter = 0 @@ -74,11 +74,11 @@ assert (not has_gone_wrong) end def test_2 - scheduler = OpenWFE::Scheduler.new + scheduler = Rufus::Scheduler.new scheduler.start counter = 0 scheduler.schedule "7 * * * * *" do @@ -95,11 +95,11 @@ # # testing cron unschedule # def test_3 - scheduler = OpenWFE::Scheduler.new + scheduler = Rufus::Scheduler.new scheduler.start counter = 0 job_id = scheduler.schedule "* * * * *" do @@ -109,23 +109,41 @@ sleep 0.300 #puts "job_id : #{job_id}" assert_equal 1, scheduler.cron_job_count + assert_equal 0, scheduler.find_schedulables("nada").size scheduler.unschedule job_id sleep 0.300 assert_equal 0, scheduler.cron_job_count scheduler.stop end + def test_4 + + scheduler = Rufus::Scheduler.start_new + + val = nil + + job_id = scheduler.schedule "* * * * * *" do |job_id, cron_line, params| + val = params.inspect + end + + sleep 2 + + assert_equal '{}', val + + scheduler.stop + end + protected class CounterSchedulable - include OpenWFE::Schedulable + include Rufus::Schedulable def trigger (params) $var = $var + 1 end end