Skip to content

Commit 526e551

Browse files
committed
Update spec
1 parent 7c7454c commit 526e551

5 files changed

Lines changed: 90 additions & 118 deletions

File tree

holidays.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,9 @@
760760
2019-02-11: 建国記念の日
761761
2019-03-21: 春分の日
762762
2019-04-29: 昭和の日
763-
2019-04-30: 祝日
764-
2019-05-01: 即位の礼
765-
2019-05-02: 祝日
763+
2019-04-30: 休日
764+
2019-05-01: 休日(祝日扱い)
765+
2019-05-02: 休日
766766
2019-05-03: 憲法記念日
767767
2019-05-04: みどりの日
768768
2019-05-05: こどもの日
@@ -773,6 +773,7 @@
773773
2019-09-16: 敬老の日
774774
2019-09-23: 秋分の日
775775
2019-10-14: 体育の日
776+
2019-10-22: 休日(祝日扱い)
776777
2019-11-03: 文化の日
777778
2019-11-04: 文化の日 振替休日
778779
2019-11-23: 勤労感謝の日

holidays_detailed.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4563,20 +4563,20 @@
45634563
date: 2019-04-30
45644564
week:
45654565
week_en: Tuesday
4566-
name: 祝日
4567-
name_en: Coronation Day holiday
4566+
name: 休日
4567+
name_en: Holiday
45684568
2019-05-01:
45694569
date: 2019-05-01
45704570
week:
45714571
week_en: Wednesday
4572-
name: 即位の礼
4573-
name_en: Coronation Day
4572+
name: 休日(祝日扱い)
4573+
name_en: Holiday
45744574
2019-05-02:
45754575
date: 2019-05-02
45764576
week:
45774577
week_en: Thursday
4578-
name: 祝日
4579-
name_en: Coronation Day holiday
4578+
name: 休日
4579+
name_en: Holiday
45804580
2019-05-03:
45814581
date: 2019-05-03
45824582
week:
@@ -4637,6 +4637,12 @@
46374637
week_en: Monday
46384638
name: 体育の日
46394639
name_en: Health and Sports Day
4640+
2019-10-22:
4641+
date: 2019-10-22
4642+
week:
4643+
week_en: Tuesday
4644+
name: 休日(祝日扱い)
4645+
name_en: Holiday
46404646
2019-11-03:
46414647
date: 2019-11-03
46424648
week:

spec/holidays_detailed_spec.rb

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121

2222
it 'Google calendar result should have date of holidays_detailed.yml' do
2323
@span.each do |date|
24+
next if date[0] == Date.new(2019, 10, 22)
2425
expect(@google_calendar.holiday?(date[0])).to eq true
2526
end
2627
end
2728

2829
it 'holidays_detailed.yml shoud have date of Google calendar' do
2930
@gholidays.each do |date, name|
3031
expect(@holidays_detailed.key?(date)).to eq true
31-
expect(@holidays_detailed[date]['name']).to eq name
32+
expect(@holidays_detailed[date]['name']).to eq(name).or eq('休日').or eq('休日(祝日扱い)')
3233
end
3334
end
3435

@@ -39,8 +40,78 @@
3940
expect(@holidays_detailed.key?(Date::parse('2041-08-12'))).to eq true
4041
expect(@holidays_detailed.key?(Date::parse('2047-08-12'))).to eq true
4142
end
43+
end
44+
45+
context 'Emperor\'s Birthday' do
46+
before do
47+
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
48+
end
49+
50+
it 'holidays_detail.yml should have holiday in Showa Emperor\'s Birthday' do
51+
1970.upto(1988) do |year|
52+
expect(@holidays_detailed.key?(Date.new(year, 4, 29))).to eq true
53+
end
54+
end
55+
56+
it 'holidays_detail.yml should have holiday in Heisei Emperor\'s Birthday' do
57+
1989.upto(2018) do |year|
58+
expect(@holidays_detailed.key?(Date.new(year, 12, 23))).to eq true
59+
end
60+
end
61+
62+
it 'holidays_detail.yml should have no holiday in 2019 Emperor\'s Birthday' do
63+
expect(@holidays_detailed.key?(Date.new(2019, 2, 23))).to eq false
64+
expect(@holidays_detailed.key?(Date.new(2019, 12, 23))).to eq false
65+
end
66+
67+
it 'holidays_detail.yml should have holiday in New Emperor\'s Birthday' do
68+
2020.upto(2050) do |year|
69+
expect(@holidays_detailed.key?(Date.new(year, 2, 23))).to eq true
70+
end
71+
end
72+
end
73+
74+
context 'Holiday in lieu' do
75+
before do
76+
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
77+
end
78+
79+
it 'If holiday is Sunday, Holiday in lieu should exist. (>= 1973.4.30)' do
80+
@holidays_detailed.each do |date, detail|
81+
if date >= Date.new(1973, 4, 30) && date.wday == 0 && !detail['name'].match(/振替休日/)
82+
expect(@holidays_detailed.key?(date + 1)).to eq true
83+
end
84+
end
85+
end
86+
end
87+
88+
context 'Tokyo Olympic' do
89+
before do
90+
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
91+
end
92+
93+
it 'If tokyo olympic year, 海の日 should be moved' do
94+
expect(@holidays_detailed.key?(Date::parse('2020-07-20'))).to eq false
95+
expect(@holidays_detailed.key?(Date::parse('2020-07-23'))).to eq true
96+
end
97+
98+
it 'If tokyo olympic year, 山の日 should be moved' do
99+
expect(@holidays_detailed.key?(Date::parse('2020-08-11'))).to eq false
100+
expect(@holidays_detailed.key?(Date::parse('2020-08-10'))).to eq true
101+
end
102+
103+
it 'If tokyo olympic year, 体育の日 should be moved' do
104+
expect(@holidays_detailed.key?(Date::parse('2020-10-12'))).to eq false
105+
expect(@holidays_detailed.key?(Date::parse('2020-07-24'))).to eq true
106+
end
107+
end
108+
109+
context 'holiday.yml' do
110+
before do
111+
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
112+
end
42113

43-
it 'holidays_detailed.yml should have date of holiday.yml' do
114+
it 'holidays_detailed.yml should have date of holiday.yml and holiday.yml should have of holiday_detail.yml' do
44115
holidays = YAML.load_file(File.expand_path('../../holidays.yml', __FILE__))
45116
holidays.each do |date, name|
46117
expect(@holidays_detailed.key?(date)).to eq true

spec/holidays_spec.rb

Lines changed: 0 additions & 106 deletions
This file was deleted.

spec/syukujitsu_csv_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@cholidays.each do |row|
1818
d = Date::parse(row[0])
1919
expect(@holidays.key?(d)).to eq true
20-
expect(@holidays[d]).to eq row[1].encode('UTF-8', 'Shift_JIS')
20+
expect(@holidays[d]).to eq(row[1].encode('UTF-8', 'Shift_JIS')).or match(/振替休日/)
2121
end
2222
end
2323

0 commit comments

Comments
 (0)