File: schedule_spec.rb

package info (click to toggle)
ruby-rufus-scheduler 3.8.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 524 kB
  • sloc: ruby: 4,324; makefile: 26
file content (72 lines) | stat: -rw-r--r-- 1,278 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

#
# Specifying rufus-scheduler
#
# Sat Aug 13 21:00:31 JST 2016
#

require 'spec_helper'


describe Rufus::Scheduler do

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

  describe '#schedule' do

    it 'leaves the schedule option hash untouched (2 args)' do

      opts = { :x => :y }

      job = @scheduler.schedule('1s', opts) {}

      expect(opts.size).to eq(1)
    end

    it 'leaves the schedule option hash untouched (3 args)' do

      opts = { :x => :y }
      callable = lambda {}

      job = @scheduler.schedule('1s', callable, opts)

      expect(opts.size).to eq(1)
    end

    it 'accepts a CronLine instance' do

      cl = Fugit.parse('* * * * *')
      job = @scheduler.schedule(cl) {}

      expect(job.cron_line.object_id).to eq(cl.object_id)
    end
  end

  describe '#at' do

    it 'leaves the schedule option hash untouched (2 args)' do

      opts = { :x => :y }

      job = @scheduler.at(Time.now + 10, opts) {}

      expect(opts.size).to eq(1)
    end

    it 'leaves the schedule option hash untouched (3 args)' do

      opts = { :x => :y }
      callable = lambda {}

      job = @scheduler.at(Time.now + 10, callable, opts)

      expect(opts.size).to eq(1)
    end
  end
end