Sha256: 0edc8e8815b2b12ff7a7c5e493995d2e57a1c1cac6999039bac61ae57a24c9ac
Contents?: true
Size: 1.94 KB
Versions: 4
Compression:
Stored size: 1.94 KB
Contents
# # Specifying rufus-scheduler # # Sun Mar 22 19:59:12 JST 2009 # require File.dirname(__FILE__) + '/spec_base' describe "#{SCHEDULER_CLASS}#cron" do before do @s = start_scheduler end after do stop_scheduler(@s) end it 'should have job ids with the class name in it' do j0 = @s.cron('7 10-12 * * * *') {} j0.job_id.should.match(/Rufus::Scheduler::CronJob/) end it 'should cron every second' do seconds = [] job = @s.cron '* * * * * *' do |job| seconds << job.last.sec end sleep 4.990 job.unschedule seconds.uniq.size.should.equal(seconds.size) end it 'should unschedule' do second = nil job = @s.cron '* * * * * *' do |job| second = job.last.sec end second.should.be.nil sleep 2 second.should.not.be.nil job.unschedule after = second sleep 2 second.should.equal(after) end it 'should keep track of cron jobs' do j0 = @s.cron '7 10-12 * * * *' do end j1 = @s.cron '7 10-12 * * * *' do end @s.cron_jobs.keys.sort.should.equal([ j0.job_id, j1.job_id ].sort) end it 'should accept tags for jobs' do job = @s.cron '* * * * * *', :tags => 'spec' do end wait_next_tick @s.find_by_tag('spec').size.should.equal(1) @s.find_by_tag('spec').first.job_id.should.equal(job.job_id) end it 'should accept job.unschedule within the job' do stack = [] @s.cron '* * * * * *' do |job| if stack.size > 2 stack << 'done' job.unschedule else stack << 'ok' end end sleep 4 @s.jobs.size.should.equal(0) stack.should.equal(%w[ ok ok ok done ]) end end describe Rufus::Scheduler::CronJob do before do @s = start_scheduler end after do stop_scheduler(@s) end it 'should respond to #next_time' do job = @s.cron '* * * * *' do end (job.next_time.to_i - Time.now.to_i).should.satisfy { |v| v < 60 } end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
tanzeeb-rufus-scheduler-2.0.7.2 | spec/cron_spec.rb |
rufus-scheduler-2.0.6 | spec/cron_spec.rb |
rufus-scheduler-2.0.5 | spec/cron_spec.rb |
rufus-scheduler-2.0.4 | spec/cron_spec.rb |