Sha256: ef77a1b147dca847d9f68c72548deb9ce6c3f8b699b31b9e011b66ff75b8073a

Contents?: true

Size: 1.16 KB

Versions: 12

Compression:

Stored size: 1.16 KB

Contents

require 'rails_helper'

describe Kuroko2::JobSuspendSchedule do
  describe '#valid?' do
    it 'accepts only CRON notation' do
      expect(Kuroko2::JobSuspendSchedule.new(cron: '* * * * *')).to be_valid
      expect(Kuroko2::JobSuspendSchedule.new(cron: '1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,5-6/7 1,2-3,*,*/4,1-3/5')).to be_valid
      expect(Kuroko2::JobSuspendSchedule.new(cron: '* * * *')).not_to be_valid
    end

    it 'accepts only valid CRON notation' do
      expect(Kuroko2::JobSuspendSchedule.new(cron: '5-0 * * * *')).not_to be_valid
    end
  end

  describe '#suspend_times' do
    let(:suspend_schedule) { create(:job_suspend_schedule, cron: '* 10 * * *') }
    let(:time_from) { Time.new(2016, 1, 1, 10, 0, 0) }
    let(:time_to) { Time.new(2016, 1, 1, 10, 5, 0) }

    it 'returns suspend times' do
      expect(suspend_schedule.suspend_times(time_from, time_to)).to eq([
        Time.new(2016, 1, 1, 10, 0, 0),
        Time.new(2016, 1, 1, 10, 1, 0),
        Time.new(2016, 1, 1, 10, 2, 0),
        Time.new(2016, 1, 1, 10, 3, 0),
        Time.new(2016, 1, 1, 10, 4, 0),
        Time.new(2016, 1, 1, 10, 5, 0),
      ])
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
kuroko2-0.4.2 spec/models/job_suspend_schedule_spec.rb
kuroko2-0.4.1 spec/models/job_suspend_schedule_spec.rb
kuroko2-0.4.0 spec/models/job_suspend_schedule_spec.rb
kuroko2-0.3.4 spec/models/job_suspend_schedule_spec.rb
kuroko2-0.3.3 spec/models/job_suspend_schedule_spec.rb
kuroko2-0.3.2 spec/models/job_suspend_schedule_spec.rb
kuroko2-0.3.1 spec/models/job_suspend_schedule_spec.rb
kuroko2-0.3.0 spec/models/job_suspend_schedule_spec.rb
kuroko2-0.2.3 spec/models/job_suspend_schedule_spec.rb
kuroko2-0.2.2 spec/models/job_suspend_schedule_spec.rb
kuroko2-0.2.1 spec/models/job_suspend_schedule_spec.rb
kuroko2-0.2.0 spec/models/job_suspend_schedule_spec.rb