Skip to content

Instantly share code, notes, and snippets.

@jmettraux
Created September 24, 2015 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmettraux/e373c9978613c3bd8834 to your computer and use it in GitHub Desktop.
Save jmettraux/e373c9978613c3bd8834 to your computer and use it in GitHub Desktop.
RUBY_VERSION: 1.9.3
RUBY_PLATFORM: i386-mingw32
Rufus::Scheduler::CronLine
Rufus::Scheduler::CronLine
.new
.new
interprets cron strings correctly
interprets cron strings correctly
rejects invalid weekday expressions
rejects invalid weekday expressions
rejects invalid cronlines
rejects invalid cronlines
interprets cron strings with TZ correctly
interprets cron strings with TZ correctly
interprets cron strings with / (slashes) correctly
interprets cron strings with / (slashes) correctly
accepts lonely / (slashes) (like <= 2.0.19 did)
accepts lonely / (slashes) (like <= 2.0.19 did)
rejects / for days (every other wednesday)
rejects / for days (every other wednesday)
does not support ranges for monthdays (sun#1-sun#2)
does not support ranges for monthdays (sun#1-sun#2)
accepts items with initial 0
accepts items with initial 0
interprets cron strings with L correctly
interprets cron strings with L correctly
does not support ranges for L
does not support ranges for L
does not support multiple Ls
does not support multiple Ls
raises if L is used for something else than days
raises if L is used for something else than days
raises for out of range input
raises for out of range input
sorts seconds
sorts seconds
sorts minutes
sorts minutes
sorts days
sorts days
sorts months
sorts months
sorts days of week
sorts days of week
#next_time
#next_time
computes the next occurence correctly (FAILED - 1)
computes the next occurence correctly (FAILED - 1)
computes the next occurence correctly in local TZ (TZ not specified)
computes the next occurence correctly in local TZ (TZ not specified)
computes the next occurence correctly in UTC (TZ specified) (FAILED - 2)
computes the next occurence correctly in UTC (TZ specified) (FAILED - 2)
computes the next time correctly when there is a sun#2 involved
computes the next time correctly when there is a sun#2 involved
computes next time correctly when there is a sun#2,sun#3 involved
computes next time correctly when there is a sun#2,sun#3 involved
understands sun#L
understands sun#L
understands sun#-1
understands sun#-1
understands sun#-2
understands sun#-2
computes the next time correctly when "L" (last day of month)
computes the next time correctly when "L" (last day of month)
returns a time with subseconds chopped off
returns a time with subseconds chopped off
survives TZInfo::AmbiguousTime
survives TZInfo::AmbiguousTime
survives TZInfo::PeriodNotFound (FAILED - 3)
survives TZInfo::PeriodNotFound (FAILED - 3)
understands six-field crontabs
understands six-field crontabs
#next_second
#next_second
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:00 +0900) is 0
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:00 +0900) is 0
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:01 +0900) is 9
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:01 +0900) is 9
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:09 +0900) is 1
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:09 +0900) is 1
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:10 +0900) is 0
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:10 +0900) is 0
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:11 +0900) is 9
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:11 +0900) is 9
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:19 +0900) is 1
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:19 +0900) is 1
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:20 +0900) is 0
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:20 +0900) is 0
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:21 +0900) is 9
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:21 +0900) is 9
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:49 +0900) is 1
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:49 +0900) is 1
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:50 +0900) is 0
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:50 +0900) is 0
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:51 +0900) is 9
ensures that next_second('*/10 * * * * *', 1970-01-01 01:01:51 +0900) is 9
#previous_time
#previous_time
returns the previous time the cron should have triggered
returns the previous time the cron should have triggered
survives TZInfo::AmbiguousTime
survives TZInfo::AmbiguousTime
survives TZInfo::PeriodNotFound
survives TZInfo::PeriodNotFound
computes correctly when * 0,10,20
computes correctly when * 0,10,20
computes correctly when * */10
computes correctly when * */10
#matches?
#matches?
matches correctly in local TZ (TZ not specified)
matches correctly in local TZ (TZ not specified)
matches correctly in UTC (TZ specified) (FAILED - 4)
matches correctly in UTC (TZ specified) (FAILED - 4)
matches correctly when there is a sun#2 involved
matches correctly when there is a sun#2 involved
matches correctly when there is a L involved
matches correctly when there is a L involved
matches correctly when there is a sun#2,sun#3 involved
matches correctly when there is a sun#2,sun#3 involved
matches correctly for seconds
matches correctly for seconds
matches correctly for seconds / interval
matches correctly for seconds / interval
#monthdays
#monthdays
returns the appropriate "sun#2"-like string
returns the appropriate "sun#2"-like string
#frequency
#frequency
returns the shortest delta between two occurrences
returns the shortest delta between two occurrences
spots B-A vs C-B asymmetry in five-field forms
spots B-A vs C-B asymmetry in five-field forms
spots B-A vs C-B asymmetry in six-field forms
spots B-A vs C-B asymmetry in six-field forms
handles crontab steps syntax in five-field forms
handles crontab steps syntax in five-field forms
handles crontab steps syntax in six-field forms
handles crontab steps syntax in six-field forms
#brute_frequency
#brute_frequency
returns the shortest delta between two occurrences
returns the shortest delta between two occurrences
does not go into an infinite loop
does not go into an infinite loop
spots B-A vs C-B asymmetry in five-field forms
spots B-A vs C-B asymmetry in five-field forms
spots B-A vs C-B asymmetry in six-field forms
spots B-A vs C-B asymmetry in six-field forms
handles crontab modulo syntax in five-field forms
handles crontab modulo syntax in five-field forms
handles crontab modulo syntax in six-field forms
handles crontab modulo syntax in six-field forms
summer time
summer time
schedules correctly through a switch into summer time (FAILED - 5)
schedules correctly through a switch into summer time (FAILED - 5)
schedules correctly through a switch out of summer time (FAILED - 6)
schedules correctly through a switch out of summer time (FAILED - 6)
correctly increments through a DST transition
correctly increments through a DST transition
correctly increments every minute through a DST transition (FAILED - 7)
correctly increments every minute through a DST transition (FAILED - 7)
correctly decrements through a DST transition
correctly decrements through a DST transition
correctly decrements every minute through a DST transition (FAILED - 8)
correctly decrements every minute through a DST transition (FAILED - 8)
Failures:
1) Rufus::Scheduler::CronLine#next_time computes the next occurence correctly
Failure/Error: expect(nt('* * * * sun', now)).to eq(now + 259200)
expected: 1970-01-03 23:00:00.000000000 +0000
got: 1970-01-04 00:00:00.000000000 +0000
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-1970-01-03 23:00:00 +0000
+1970-01-04 00:00:00 +0000
# ./spec/cronline_spec.rb:273:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:67:in `call'
# ./spec/spec_helper.rb:67:in `in_zone'
# ./spec/cronline_spec.rb:268:in `block (3 levels) in <top (required)>'
2) Rufus::Scheduler::CronLine#next_time computes the next occurence correctly in UTC (TZ specified)
Failure/Error: expect(nt("* * * * * #{zone}", now)).to eq(utc(1969, 12, 31, 23, 1))
expected: 1969-12-31 23:01:00.000000000 +0000
got: 1970-01-01 00:01:00.000000000 +0000
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-1969-12-31 23:01:00 UTC
+1970-01-01 00:01:00 +0000
# ./spec/cronline_spec.rb:317:in `block (3 levels) in <top (required)>'
3) Rufus::Scheduler::CronLine#next_time survives TZInfo::PeriodNotFound
Failure/Error: )
expected: 2015-03-09 02:00:00.000000000 +0000
got: 2014-03-09 02:00:00.000000000 +0000
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-2015-03-09 02:00:00 +0000
+2014-03-09 02:00:00 +0000
# ./spec/cronline_spec.rb:407:in `block (3 levels) in <top (required)>'
4) Rufus::Scheduler::CronLine#matches? matches correctly in UTC (TZ specified)
Failure/Error: expect(cl(line).matches?(time)).to eq(true)
expected: true
got: false
(compared using ==)
# ./spec/cronline_spec.rb:40:in `match'
# ./spec/cronline_spec.rb:568:in `block (3 levels) in <top (required)>'
5) Rufus::Scheduler::CronLine summer time schedules correctly through a switch into summer time
Failure/Error: expect(n0.strftime('%H:%M:%S %^a')).to eq('00:02:00 TUE')
expected: "00:02:00 TUE"
got: "00:02:00 MON"
(compared using ==)
# ./spec/cronline_spec.rb:796:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:67:in `call'
# ./spec/spec_helper.rb:67:in `in_zone'
# ./spec/cronline_spec.rb:770:in `block (3 levels) in <top (required)>'
6) Rufus::Scheduler::CronLine summer time schedules correctly through a switch out of summer time
Failure/Error: (n0 - 24 * 3600 * 3).strftime('%H:%M:%S %^a')).to eq('01:02:00 FRI')
expected: "01:02:00 FRI"
got: "00:02:00 FRI"
(compared using ==)
# ./spec/cronline_spec.rb:844:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:67:in `call'
# ./spec/spec_helper.rb:67:in `in_zone'
# ./spec/cronline_spec.rb:811:in `block (3 levels) in <top (required)>'
7) Rufus::Scheduler::CronLine summer time correctly increments every minute through a DST transition
Failure/Error: expect(points).to eq(
expected: ["01:58:00l 09:58:00u", "01:59:00l 09:59:00u", "03:00:00l 10:00:00u", "03:01:00l 10:01:00u"]
got: ["01:58:00l 01:58:00u", "01:59:00l 01:59:00u", "02:00:00l 02:00:00u", "02:01:00l 02:01:00u"]
(compared using ==)
# ./spec/cronline_spec.rb:871:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:67:in `call'
# ./spec/spec_helper.rb:67:in `in_zone'
# ./spec/cronline_spec.rb:859:in `block (3 levels) in <top (required)>'
8) Rufus::Scheduler::CronLine summer time correctly decrements every minute through a DST transition
Failure/Error: expect(points).to eq(
expected: ["03:01:00l 10:01:00u", "03:00:00l 10:00:00u", "01:59:00l 09:59:00u", "01:58:00l 09:58:00u"]
got: ["03:01:00l 03:01:00u", "03:00:00l 03:00:00u", "02:59:00l 02:59:00u", "02:58:00l 02:58:00u"]
(compared using ==)
# ./spec/cronline_spec.rb:903:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:67:in `call'
# ./spec/spec_helper.rb:67:in `in_zone'
# ./spec/cronline_spec.rb:891:in `block (3 levels) in <top (required)>'
Failures:
1) Rufus::Scheduler::CronLine#next_time computes the next occurence correctly
Failure/Error: expect(nt('* * * * sun', now)).to eq(now + 259200)
expected: 1970-01-03 23:00:00.000000000 +0000
got: 1970-01-04 00:00:00.000000000 +0000
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-1970-01-03 23:00:00 +0000
+1970-01-04 00:00:00 +0000
# ./spec/cronline_spec.rb:273:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:67:in `call'
# ./spec/spec_helper.rb:67:in `in_zone'
# ./spec/cronline_spec.rb:268:in `block (3 levels) in <top (required)>'
2) Rufus::Scheduler::CronLine#next_time computes the next occurence correctly in UTC (TZ specified)
Failure/Error: expect(nt("* * * * * #{zone}", now)).to eq(utc(1969, 12, 31, 23, 1))
expected: 1969-12-31 23:01:00.000000000 +0000
got: 1970-01-01 00:01:00.000000000 +0000
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-1969-12-31 23:01:00 UTC
+1970-01-01 00:01:00 +0000
# ./spec/cronline_spec.rb:317:in `block (3 levels) in <top (required)>'
3) Rufus::Scheduler::CronLine#next_time survives TZInfo::PeriodNotFound
Failure/Error: )
expected: 2015-03-09 02:00:00.000000000 +0000
got: 2014-03-09 02:00:00.000000000 +0000
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-2015-03-09 02:00:00 +0000
+2014-03-09 02:00:00 +0000
# ./spec/cronline_spec.rb:407:in `block (3 levels) in <top (required)>'
4) Rufus::Scheduler::CronLine#matches? matches correctly in UTC (TZ specified)
Failure/Error: expect(cl(line).matches?(time)).to eq(true)
expected: true
got: false
(compared using ==)
# ./spec/cronline_spec.rb:40:in `match'
# ./spec/cronline_spec.rb:568:in `block (3 levels) in <top (required)>'
5) Rufus::Scheduler::CronLine summer time schedules correctly through a switch into summer time
Failure/Error: expect(n0.strftime('%H:%M:%S %^a')).to eq('00:02:00 TUE')
expected: "00:02:00 TUE"
got: "00:02:00 MON"
(compared using ==)
# ./spec/cronline_spec.rb:796:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:67:in `call'
# ./spec/spec_helper.rb:67:in `in_zone'
# ./spec/cronline_spec.rb:770:in `block (3 levels) in <top (required)>'
6) Rufus::Scheduler::CronLine summer time schedules correctly through a switch out of summer time
Failure/Error: (n0 - 24 * 3600 * 3).strftime('%H:%M:%S %^a')).to eq('01:02:00 FRI')
expected: "01:02:00 FRI"
got: "00:02:00 FRI"
(compared using ==)
# ./spec/cronline_spec.rb:844:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:67:in `call'
# ./spec/spec_helper.rb:67:in `in_zone'
# ./spec/cronline_spec.rb:811:in `block (3 levels) in <top (required)>'
7) Rufus::Scheduler::CronLine summer time correctly increments every minute through a DST transition
Failure/Error: expect(points).to eq(
expected: ["01:58:00l 09:58:00u", "01:59:00l 09:59:00u", "03:00:00l 10:00:00u", "03:01:00l 10:01:00u"]
got: ["01:58:00l 01:58:00u", "01:59:00l 01:59:00u", "02:00:00l 02:00:00u", "02:01:00l 02:01:00u"]
(compared using ==)
# ./spec/cronline_spec.rb:871:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:67:in `call'
# ./spec/spec_helper.rb:67:in `in_zone'
# ./spec/cronline_spec.rb:859:in `block (3 levels) in <top (required)>'
8) Rufus::Scheduler::CronLine summer time correctly decrements every minute through a DST transition
Failure/Error: expect(points).to eq(
expected: ["03:01:00l 10:01:00u", "03:00:00l 10:00:00u", "01:59:00l 09:59:00u", "01:58:00l 09:58:00u"]
got: ["03:01:00l 03:01:00u", "03:00:00l 03:00:00u", "02:59:00l 02:59:00u", "02:58:00l 02:58:00u"]
(compared using ==)
# ./spec/cronline_spec.rb:903:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:67:in `call'
# ./spec/spec_helper.rb:67:in `in_zone'
# ./spec/cronline_spec.rb:891:in `block (3 levels) in <top (required)>'
Finished in 1 minute 13.65 seconds (files took 0.14952 seconds to load)
73 examples, 8 failures
Failed examples:
rspec ./spec/cronline_spec.rb:266 # Rufus::Scheduler::CronLine#next_time computes the next occurence correctly
rspec ./spec/cronline_spec.rb:312 # Rufus::Scheduler::CronLine#next_time computes the next occurence correctly in UTC (TZ specified)
rspec ./spec/cronline_spec.rb:401 # Rufus::Scheduler::CronLine#next_time survives TZInfo::PeriodNotFound
rspec ./spec/cronline_spec.rb:563 # Rufus::Scheduler::CronLine#matches? matches correctly in UTC (TZ specified)
rspec ./spec/cronline_spec.rb:768 # Rufus::Scheduler::CronLine summer time schedules correctly through a switch into summer time
rspec ./spec/cronline_spec.rb:809 # Rufus::Scheduler::CronLine summer time schedules correctly through a switch out of summer time
rspec ./spec/cronline_spec.rb:857 # Rufus::Scheduler::CronLine summer time correctly increments every minute through a DST transition
rspec ./spec/cronline_spec.rb:889 # Rufus::Scheduler::CronLine summer time correctly decrements every minute through a DST transition
Finished in 1 minute 13.65 seconds (files took 0.14952 seconds to load)
73 examples, 8 failures
Failed examples:
rspec ./spec/cronline_spec.rb:266 # Rufus::Scheduler::CronLine#next_time computes the next occurence correctly
rspec ./spec/cronline_spec.rb:312 # Rufus::Scheduler::CronLine#next_time computes the next occurence correctly in UTC (TZ specified)
rspec ./spec/cronline_spec.rb:401 # Rufus::Scheduler::CronLine#next_time survives TZInfo::PeriodNotFound
rspec ./spec/cronline_spec.rb:563 # Rufus::Scheduler::CronLine#matches? matches correctly in UTC (TZ specified)
rspec ./spec/cronline_spec.rb:768 # Rufus::Scheduler::CronLine summer time schedules correctly through a switch into summer time
rspec ./spec/cronline_spec.rb:809 # Rufus::Scheduler::CronLine summer time schedules correctly through a switch out of summer time
rspec ./spec/cronline_spec.rb:857 # Rufus::Scheduler::CronLine summer time correctly increments every minute through a DST transition
rspec ./spec/cronline_spec.rb:889 # Rufus::Scheduler::CronLine summer time correctly decrements every minute through a DST transition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment