-
-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathdate_time_util_spec.rb
50 lines (46 loc) · 1.81 KB
/
date_time_util_spec.rb
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
require 'rails_helper'
RSpec.describe DateTimeUtil do
describe '.every_year_array' do
let(:from) { Time.zone.local(2015, 1, 1) }
let(:to) { Time.zone.local(2017, 12, 31) }
subject { DateTimeUtil.every_year_array(from, to) }
it do
is_expected.to match_array([Time.zone.local(2015, 1, 1),
Time.zone.local(2016, 1, 1),
Time.zone.local(2017, 1, 1)])
end
end
describe '.ever_month_array' do
let(:from) { Time.zone.local(2017, 4, 2) }
let(:to) { Time.zone.local(2017, 7, 1) }
subject { DateTimeUtil.every_month_array(from, to) }
it do
is_expected.to match_array([Time.zone.local(2017, 4, 2),
Time.zone.local(2017, 5, 2),
Time.zone.local(2017, 6, 2)])
end
end
describe '.ever_week_array' do
let(:from) { Time.zone.local(2017, 9, 3) }
let(:to) { Time.zone.local(2017, 9, 29) }
subject { DateTimeUtil.every_week_array(from, to) }
it do
is_expected.to match_array([Time.zone.local(2017, 9, 3),
Time.zone.local(2017, 9, 10),
Time.zone.local(2017, 9, 17),
Time.zone.local(2017, 9, 24)])
end
end
describe '.ever_day_array' do
let(:from) { Time.zone.local(2017, 11, 11) }
let(:to) { Time.zone.local(2017, 11, 15) }
subject { DateTimeUtil.every_day_array(from, to) }
it do
is_expected.to match_array([Time.zone.local(2017, 11, 11),
Time.zone.local(2017, 11, 12),
Time.zone.local(2017, 11, 13),
Time.zone.local(2017, 11, 14),
Time.zone.local(2017, 11, 15)])
end
end
end