Sha256: aea9977e34e87cf0f4918a96276c3a2bacdbf57f094a0f9a95cdc259f21addf0

Contents?: true

Size: 825 Bytes

Versions: 1

Compression:

Stored size: 825 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: "18:55"),
      Crono::Period.new(1.day, at: "15:30"),
      Crono::Period.new(7.day, at: "06:05")
    ].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[1]
    end

    it "should return next based on last" do
      expect(@scheduler.next)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crono-0.6.1 spec/scheduler_spec.rb