test/scheduler_1_test.rb in rufus-scheduler-1.0.5 vs test/scheduler_1_test.rb in rufus-scheduler-1.0.6
- old
+ new
@@ -14,80 +14,75 @@
# testing otime and the scheduler
#
class Scheduler1Test < Test::Unit::TestCase
- #def setup
- #end
+ #def setup
+ #end
- #def teardown
- #end
+ #def teardown
+ #end
- def test_0
+ def test_0
- scheduler = OpenWFE::Scheduler.new
- scheduler.sstart
+ scheduler = OpenWFE::Scheduler.new
+ scheduler.sstart
- job_id = scheduler.schedule_every "500", :tags => "Avery" do
- # don't do a thing
- end
+ job_id = scheduler.schedule_every "500", :tags => "Avery" do
+ # don't do a thing
+ end
- sleep 0.300
+ sleep 0.300
- successful = true
+ count = nil
- 200000.times do
- #assert_not_nil scheduler.get_job(job_id)
- if scheduler.get_job(job_id) == nil
- successful = false
- break
- end
- end
-
- scheduler.sstop
-
- assert successful
+ 200_000.times do |i|
+ break if scheduler.get_job(job_id) == nil
+ count = i + 1
end
- def test_1
+ scheduler.sstop
- scheduler = OpenWFE::Scheduler.new
- scheduler.sstart
+ assert_equal 200_000, count
+ end
- job_id = scheduler.schedule_every "500", :tags => "Avery" do
- # don't do a thing
- end
+ def test_1
- sleep 0.300
+ scheduler = OpenWFE::Scheduler.new
+ scheduler.sstart
- successful = true
+ job_id = scheduler.schedule_every "500", :tags => "Avery" do
+ # don't do a thing
+ end
- 200000.times do
- #assert_equal 1, scheduler.find_jobs("Avery").size
- if scheduler.find_jobs("Avery").size != 1
- successful = false
- break
- end
- end
+ sleep 0.300
- scheduler.sstop
+ count = 1
- assert successful
+ 200_000.times do
+ #assert_equal 1, scheduler.find_jobs("Avery").size
+ count = scheduler.find_jobs("Avery").size
+ break if count != 1
end
- #
- # testing "deviation", if I may call it like that...
- #
- def _test_2
+ scheduler.sstop
- scheduler = OpenWFE::Scheduler.new
- scheduler.sstart
- last = nil
- job_id = scheduler.schedule_every "1s" do
- t = Time.now
- puts t.to_f
- end
- sleep 4 * 60
- scheduler.sstop
+ assert_equal 1, count
+ end
+
+ #
+ # testing "deviation", if I may call it like that...
+ #
+ def _test_2
+
+ scheduler = OpenWFE::Scheduler.new
+ scheduler.sstart
+ last = nil
+ job_id = scheduler.schedule_every "1s" do
+ t = Time.now
+ puts t.to_f
end
+ sleep 4 * 60
+ scheduler.sstop
+ end
end