Sha256: 3ae7b868ac2f3a9b3b3c81eae50e432922477edee035bf0b1e5418d676ba42aa

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'
require 'timecop'
require 'rspec-sidekiq'

describe DelayedCron::Scheduling do

  describe ".schedule" do
    it "schedules cron jobs" do
      DelayedCron.schedule("SomeClass", "long_method", { interval: 1.hour })
      expect(DelayedCron.processor).to be_processed_in :cron_job
      expect(DelayedCron.processor.jobs.size).to eq(1)

      expect(DelayedCron.processor.jobs.last["args"])
        .to eq(["SomeClass", "long_method", { "interval" => 1.hour.to_s }])
    end
  end

  describe ".timing_opts" do

    let(:options) do
      { interval: 1.day, at: "05:00:00 -0400" }
    end

    it "collects the timing options" do
      interval = { interval: 1.day }
      timing_opts = DelayedCron.timing_opts(options)
      expect(timing_opts).to eq(options)
      expect(timing_opts).not_to eq(interval)
    end

    it "passes time_zone through" do
      options_with_zone = options.merge(time_zone: "UTC")
      timing_opts = DelayedCron.timing_opts(options_with_zone)
      expect(timing_opts).to eq(options_with_zone)
    end

    it "ignores unknown parameters" do
      timing_opts = DelayedCron.timing_opts(foo: :bar)

      expect(timing_opts).to_not have_key(:foo)
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
delayed_cron-0.2.11 spec/scheduling_spec.rb
delayed_cron-0.2.10 spec/scheduling_spec.rb