spec/scheduler_spec.rb in rufus-scheduler-2.0.19 vs spec/scheduler_spec.rb in rufus-scheduler-2.0.20
- old
+ new
@@ -198,9 +198,41 @@
@s.running_jobs.should == [ job ]
end
end
end
+
+ context 'termination' do
+
+ describe '#stop(true)' do
+
+ it 'terminates the scheduler, blocking until all the jobs are unscheduled' do
+
+ $every = nil
+ $cron = nil
+
+ s = start_scheduler
+ s.every '1s' do
+ $every = :in
+ sleep 0.5
+ $every = :out
+ end
+ s.cron '* * * * * *' do
+ $cron = :in
+ sleep 0.5
+ $cron = :out
+ end
+
+ sleep 2
+
+ s.stop(:terminate => true)
+
+ s.jobs.size.should == 0
+ $every.should == :out
+ $cron.should == :out
+ end
+ end
+ end
end
describe 'Rufus::Scheduler#start_new' do
it 'piggybacks EM if present and running' do