spec/job_spec.rb in rufus-scheduler-3.0.4 vs spec/job_spec.rb in rufus-scheduler-3.0.5

- old
+ new

@@ -176,9 +176,73 @@ job.running?.should == true job.scheduled?.should == true end end + describe '#call' do + + it 'calls the job (like it were a proc)' do + + counter = 0 + + job = + @scheduler.schedule_in('0.5s') do + counter = counter + 1 + end + job.call + + sleep 0.8 + + counter.should == 2 + end + end + + describe '#call(true)' do + + it 'calls the job and let the scheduler handle errors' do + + $err = nil + + def @scheduler.on_error(job, err) + $err = "#{job.class} #{job.original} #{err.message}" + rescue + p $! + end + + job = + @scheduler.schedule_in('1d') do + fail 'again' + end + + job.call(true) + + $err.should == 'Rufus::Scheduler::InJob 1d again' + end + end + + describe '#call(false)' do + + it 'calls the job and let errors slip through' do + + job = + @scheduler.schedule_in('1d') do + fail 'fast' + end + + begin + + #job.call(false) + job.call # false is the default + + false.should == true + + rescue => ex + + ex.message.should == 'fast' + end + end + end + context 'job-local variables' do describe '#[]=' do it 'sets a job-local variable' do