spec/cron_spec.rb in rufus-scheduler-2.0.6 vs spec/cron_spec.rb in rufus-scheduler-2.0.7
- old
+ new
@@ -3,87 +3,87 @@
# Specifying rufus-scheduler
#
# Sun Mar 22 19:59:12 JST 2009
#
-require File.dirname(__FILE__) + '/spec_base'
+require File.join(File.dirname(__FILE__), 'spec_base')
describe "#{SCHEDULER_CLASS}#cron" do
- before do
+ before(:each) do
@s = start_scheduler
end
- after do
+ after(:each) do
stop_scheduler(@s)
end
- it 'should have job ids with the class name in it' do
+ it 'has job ids with the class name in it' do
j0 = @s.cron('7 10-12 * * * *') {}
- j0.job_id.should.match(/Rufus::Scheduler::CronJob/)
+ j0.job_id.should match(/Rufus::Scheduler::CronJob/)
end
- it 'should cron every second' do
+ it 'crons 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)
+ seconds.uniq.size.should == seconds.size
end
- it 'should unschedule' do
+ it 'unschedules' do
second = nil
job = @s.cron '* * * * * *' do |job|
second = job.last.sec
end
- second.should.be.nil
+ second.should == nil
sleep 2
- second.should.not.be.nil
+ second.should_not == nil
job.unschedule
after = second
sleep 2
- second.should.equal(after)
+ second.should == after
end
- it 'should keep track of cron jobs' do
+ it 'keeps 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)
+ @s.cron_jobs.keys.sort.should == [ j0.job_id, j1.job_id ].sort
end
- it 'should accept tags for jobs' do
+ it 'accepts 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)
+ @s.find_by_tag('spec').size.should == 1
+ @s.find_by_tag('spec').first.job_id.should == job.job_id
end
- it 'should accept job.unschedule within the job' do
+ it 'accepts job.unschedule within the job' do
stack = []
@s.cron '* * * * * *' do |job|
if stack.size > 2
@@ -94,29 +94,29 @@
end
end
sleep 4
- @s.jobs.size.should.equal(0)
- stack.should.equal(%w[ ok ok ok done ])
+ @s.jobs.size.should == 0
+ stack.should == %w[ ok ok ok done ]
end
end
describe Rufus::Scheduler::CronJob do
- before do
+ before(:each) do
@s = start_scheduler
end
- after do
+ after(:each) do
stop_scheduler(@s)
end
- it 'should respond to #next_time' do
+ it 'responds to #next_time' do
job = @s.cron '* * * * *' do
end
- (job.next_time.to_i - Time.now.to_i).should.satisfy { |v| v < 60 }
+ (job.next_time.to_i - Time.now.to_i).should satisfy { |v| v < 60 }
end
end