Sha256: 847b75c8585875c858f1d251c71734e65c331e4c09f130599086bd46e548efc2

Contents?: true

Size: 831 Bytes

Versions: 1

Compression:

Stored size: 831 Bytes

Contents

require "spec_helper"

class TestJob
  def perform;end
end

describe Crono::Scheduler do
  before(:each) do
    @scheduler = Crono::Scheduler.new
    @jobs = [
      Crono::Period.new(3.day, at: 10.minutes.from_now.strftime("%H:%M")),
      Crono::Period.new(1.day, at: 20.minutes.from_now.strftime("%H:%M")),
      Crono::Period.new(7.day, at: 40.minutes.from_now.strftime("%H:%M"))
    ].map { |period| Crono::Job.new(TestJob, period) }
    @scheduler.jobs = @jobs
  end

  describe "#add_job" do
    it "should call Job#load on Job" do
      @job = Crono::Job.new(TestJob, Crono::Period.new(10.day, at: "04:05"))
      expect(@job).to receive(:load)
      @scheduler.add_job(@job)
    end
  end

  describe "#next" do
    it "should return next job in schedule" do
      expect(@scheduler.next).to be @jobs[0]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crono-0.7.0 spec/scheduler_spec.rb