Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
1bd54949
Commit
1bd54949
authored
Apr 01, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve cron_parser_spec
parent
a2c4a2a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
spec/lib/ci/cron_parser_spec.rb
spec/lib/ci/cron_parser_spec.rb
+17
-11
No files found.
spec/lib/ci/cron_parser_spec.rb
View file @
1bd54949
...
...
@@ -2,6 +2,10 @@ require 'spec_helper'
module
Ci
describe
CronParser
,
lib:
true
do
shared_examples_for
"returns time in the future"
do
it
{
is_expected
.
to
be
>
Time
.
now
}
end
describe
'#next_time_from'
do
subject
{
described_class
.
new
(
cron
,
cron_time_zone
).
next_time_from
(
Time
.
now
)
}
...
...
@@ -10,8 +14,9 @@ module Ci
let
(
:cron
)
{
'3 4 5 6 *'
}
let
(
:cron_time_zone
)
{
'UTC'
}
it
'returns exact time in the future'
do
expect
(
subject
).
to
be
>
Time
.
now
it_behaves_like
"returns time in the future"
it
'returns exact time'
do
expect
(
subject
.
min
).
to
eq
(
3
)
expect
(
subject
.
hour
).
to
eq
(
4
)
expect
(
subject
.
day
).
to
eq
(
5
)
...
...
@@ -23,8 +28,9 @@ module Ci
let
(
:cron
)
{
'* * * * 0'
}
let
(
:cron_time_zone
)
{
'UTC'
}
it
'returns exact day of week in the future'
do
expect
(
subject
).
to
be
>
Time
.
now
it_behaves_like
"returns time in the future"
it
'returns exact day of week'
do
expect
(
subject
.
wday
).
to
eq
(
0
)
end
end
...
...
@@ -33,8 +39,9 @@ module Ci
let
(
:cron
)
{
'*/10 */6 */10 */10 *'
}
let
(
:cron_time_zone
)
{
'UTC'
}
it
'returns exact minute'
do
expect
(
subject
).
to
be
>
Time
.
now
it_behaves_like
"returns time in the future"
it
'returns specific time'
do
expect
(
subject
.
min
).
to
be_in
([
0
,
10
,
20
,
30
,
40
,
50
])
expect
(
subject
.
hour
).
to
be_in
([
0
,
6
,
12
,
18
])
expect
(
subject
.
day
).
to
be_in
([
1
,
11
,
21
,
31
])
...
...
@@ -46,8 +53,9 @@ module Ci
let
(
:cron
)
{
'0,20,40 * 1-5 * *'
}
let
(
:cron_time_zone
)
{
'UTC'
}
it
'returns next time from now'
do
expect
(
subject
).
to
be
>
Time
.
now
it_behaves_like
"returns time in the future"
it
'returns specific time'
do
expect
(
subject
.
min
).
to
be_in
([
0
,
20
,
40
])
expect
(
subject
.
day
).
to
be_in
((
1
..
5
).
to_a
)
end
...
...
@@ -57,9 +65,7 @@ module Ci
let
(
:cron
)
{
'0 0 * * *'
}
let
(
:cron_time_zone
)
{
'US/Pacific'
}
it
'returns next time from now'
do
expect
(
subject
).
to
be
>
Time
.
now
end
it_behaves_like
"returns time in the future"
it
'converts time in server time zone'
do
expect
(
subject
.
hour
).
to
eq
(
7
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment