Sha256: e94b5ed30d39d632e2813d4a03cbe8f03962e40d55ab0c1a188da16775cf2f6e

Contents?: true

Size: 934 Bytes

Versions: 8

Compression:

Stored size: 934 Bytes

Contents

#
# Specifying rufus-scheduler
#
# Wed Apr 17 06:00:59 JST 2013
#

require 'spec_helper'


describe Rufus::Scheduler::AtJob do

  before :each do
    @scheduler = Rufus::Scheduler.new
  end
  after :each do
    @scheduler.shutdown
  end

  describe '#unschedule' do

    it 'unschedules the job' do

      job = @scheduler.at(Time.now + 3600, :job => true) do
      end

      job.unschedule

      sleep 0.4

      @scheduler.jobs.size.should == 0
    end
  end

  describe '#scheduled_at' do

    it 'returns the Time at which the job got scheduled' do

      job = @scheduler.schedule_at((t = Time.now) + 3600) {}

      job.scheduled_at.to_i.should >= t.to_i - 1
      job.scheduled_at.to_i.should <= t.to_i + 1
    end
  end

  describe '#time' do

    it 'returns the time at which the job will trigger' do

      t = Time.now + 3600

      job = @scheduler.schedule_at t do; end

      job.time.should == t
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rufus-scheduler-3.0.7 spec/job_at_spec.rb
rufus-scheduler-3.0.6 spec/job_at_spec.rb
rufus-scheduler-3.0.5 spec/job_at_spec.rb
rufus-scheduler-3.0.4 spec/job_at_spec.rb
rufus-scheduler-3.0.3 spec/job_at_spec.rb
rufus-scheduler-3.0.2 spec/job_at_spec.rb
rufus-scheduler-3.0.1 spec/job_at_spec.rb
rufus-scheduler-3.0.0 spec/job_at_spec.rb