holidays 5.7.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +1 -1
  3. data/CHANGELOG.md +11 -0
  4. data/lib/generated_definitions/north_america.rb +1 -1
  5. data/lib/generated_definitions/tr.rb +1 -0
  6. data/lib/generated_definitions/us.rb +1 -1
  7. data/lib/holidays/definition/context/generator.rb +5 -36
  8. data/lib/holidays/definition/decorator/test.rb +37 -0
  9. data/lib/holidays/definition/entity/test.rb +11 -0
  10. data/lib/holidays/definition/generator/test.rb +51 -0
  11. data/lib/holidays/definition/parser/test.rb +86 -0
  12. data/lib/holidays/definition/validator/test.rb +71 -0
  13. data/lib/holidays/errors.rb +3 -0
  14. data/lib/holidays/factory/definition.rb +24 -0
  15. data/lib/holidays/version.rb +1 -1
  16. data/test/coverage_report.rb +1 -0
  17. data/test/data/test_custom_year_range_holiday_defs.yaml +7 -0
  18. data/test/data/test_multiple_custom_holiday_defs.yaml +7 -4
  19. data/test/data/test_single_custom_holiday_defs.yaml +7 -4
  20. data/test/data/test_single_custom_holiday_with_custom_procs.yaml +11 -7
  21. data/test/defs/test_defs_ar.rb +33 -19
  22. data/test/defs/test_defs_at.rb +14 -11
  23. data/test/defs/test_defs_au.rb +172 -141
  24. data/test/defs/test_defs_be_fr.rb +23 -14
  25. data/test/defs/test_defs_be_nl.rb +23 -14
  26. data/test/defs/test_defs_bg.rb +29 -17
  27. data/test/defs/test_defs_br.rb +33 -19
  28. data/test/defs/test_defs_ca.rb +175 -176
  29. data/test/defs/test_defs_ch.rb +29 -23
  30. data/test/defs/test_defs_cl.rb +49 -27
  31. data/test/defs/test_defs_cr.rb +17 -11
  32. data/test/defs/test_defs_cz.rb +25 -15
  33. data/test/defs/test_defs_de.rb +52 -61
  34. data/test/defs/test_defs_dk.rb +31 -19
  35. data/test/defs/test_defs_ecb_target.rb +14 -10
  36. data/test/defs/test_defs_ee.rb +28 -20
  37. data/test/defs/test_defs_el.rb +29 -17
  38. data/test/defs/test_defs_es.rb +114 -52
  39. data/test/defs/test_defs_europe.rb +1154 -715
  40. data/test/defs/test_defs_federal_reserve.rb +99 -57
  41. data/test/defs/test_defs_fedex.rb +19 -12
  42. data/test/defs/test_defs_fi.rb +47 -27
  43. data/test/defs/test_defs_fr.rb +29 -24
  44. data/test/defs/test_defs_gb.rb +90 -51
  45. data/test/defs/test_defs_ge.rb +40 -28
  46. data/test/defs/test_defs_hk.rb +47 -26
  47. data/test/defs/test_defs_hr.rb +32 -18
  48. data/test/defs/test_defs_hu.rb +26 -16
  49. data/test/defs/test_defs_ie.rb +41 -25
  50. data/test/defs/test_defs_is.rb +39 -22
  51. data/test/defs/test_defs_it.rb +23 -14
  52. data/test/defs/test_defs_jp.rb +112 -59
  53. data/test/defs/test_defs_kr.rb +25 -17
  54. data/test/defs/test_defs_li.rb +20 -20
  55. data/test/defs/test_defs_lt.rb +51 -30
  56. data/test/defs/test_defs_lu.rb +17 -12
  57. data/test/defs/test_defs_ma.rb +17 -11
  58. data/test/defs/test_defs_mt_en.rb +28 -19
  59. data/test/defs/test_defs_mt_mt.rb +28 -19
  60. data/test/defs/test_defs_mx.rb +33 -22
  61. data/test/defs/test_defs_my.rb +11 -8
  62. data/test/defs/test_defs_nerc.rb +17 -11
  63. data/test/defs/test_defs_nl.rb +21 -13
  64. data/test/defs/test_defs_no.rb +31 -18
  65. data/test/defs/test_defs_north_america.rb +507 -393
  66. data/test/defs/test_defs_nyse.rb +26 -15
  67. data/test/defs/test_defs_nz.rb +47 -28
  68. data/test/defs/test_defs_pe.rb +35 -20
  69. data/test/defs/test_defs_ph.rb +17 -11
  70. data/test/defs/test_defs_pl.rb +200 -119
  71. data/test/defs/test_defs_pt.rb +33 -24
  72. data/test/defs/test_defs_ro.rb +39 -24
  73. data/test/defs/test_defs_rs_cyrl.rb +33 -26
  74. data/test/defs/test_defs_rs_la.rb +33 -26
  75. data/test/defs/test_defs_ru.rb +22 -16
  76. data/test/defs/test_defs_scandinavia.rb +193 -116
  77. data/test/defs/test_defs_se.rb +47 -28
  78. data/test/defs/test_defs_sg.rb +13 -9
  79. data/test/defs/test_defs_si.rb +93 -24
  80. data/test/defs/test_defs_sk.rb +29 -17
  81. data/test/defs/test_defs_tn.rb +15 -10
  82. data/test/defs/test_defs_tr.rb +39 -30
  83. data/test/defs/test_defs_united_nations.rb +0 -1
  84. data/test/defs/test_defs_ups.rb +19 -12
  85. data/test/defs/test_defs_us.rb +333 -217
  86. data/test/defs/test_defs_ve.rb +23 -16
  87. data/test/defs/test_defs_vi.rb +10 -8
  88. data/test/defs/test_defs_za.rb +23 -14
  89. data/test/holidays/definition/context/test_generator.rb +40 -13
  90. data/test/holidays/definition/decorator/test_test.rb +123 -0
  91. data/test/holidays/definition/generator/test_test.rb +113 -0
  92. data/test/holidays/definition/parser/test_test.rb +142 -0
  93. data/test/holidays/definition/validator/test_region.rb +5 -0
  94. data/test/holidays/definition/validator/test_test.rb +60 -0
  95. metadata +15 -8
  96. data/test/holidays/factory/test_date_calculator.rb +0 -32
  97. data/test/holidays/factory/test_definition.rb +0 -62
  98. data/test/holidays/factory/test_finder.rb +0 -25
@@ -7,20 +7,29 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
7
7
  class Be_frDefinitionTests < Test::Unit::TestCase # :nodoc:
8
8
 
9
9
  def test_be_fr
10
- {Date.civil(2007,1,1) => 'Jour de l\'an',
11
- Date.civil(2007,4,8) => 'Pâques',
12
- Date.civil(2007,4,9) => 'Lundi de Pâques',
13
- Date.civil(2007,5,1) => 'Fête du travail',
14
- Date.civil(2007,5,17) => 'Ascension',
15
- Date.civil(2007,5,27) => 'Pentecôte',
16
- Date.civil(2007,5,28) => 'Lundi de Pentecôte',
17
- Date.civil(2007,7,21) => 'Fête nationale',
18
- Date.civil(2007,8,15) => 'Assomption',
19
- Date.civil(2007,11,1) => 'Toussaint',
20
- Date.civil(2007,11,11) => 'Armistice 1918',
21
- Date.civil(2007,12,25) => 'Noël'}.each do |date, name|
22
- assert_equal name, (Holidays.on(date, :be_fr, :informal)[0] || {})[:name]
23
- end
10
+ assert_equal "Jour de l'an", (Holidays.on(Date.civil(2007, 1, 1), [:be_fr], [:informal])[0] || {})[:name]
11
+
12
+ assert_equal "Pâques", (Holidays.on(Date.civil(2007, 4, 8), [:be_fr], [:informal])[0] || {})[:name]
13
+
14
+ assert_equal "Lundi de Pâques", (Holidays.on(Date.civil(2007, 4, 9), [:be_fr], [:informal])[0] || {})[:name]
15
+
16
+ assert_equal "Fête du travail", (Holidays.on(Date.civil(2007, 5, 1), [:be_fr], [:informal])[0] || {})[:name]
17
+
18
+ assert_equal "Ascension", (Holidays.on(Date.civil(2007, 5, 17), [:be_fr], [:informal])[0] || {})[:name]
19
+
20
+ assert_equal "Pentecôte", (Holidays.on(Date.civil(2007, 5, 27), [:be_fr], [:informal])[0] || {})[:name]
21
+
22
+ assert_equal "Lundi de Pentecôte", (Holidays.on(Date.civil(2007, 5, 28), [:be_fr], [:informal])[0] || {})[:name]
23
+
24
+ assert_equal "Fête nationale", (Holidays.on(Date.civil(2007, 7, 21), [:be_fr], [:informal])[0] || {})[:name]
25
+
26
+ assert_equal "Assomption", (Holidays.on(Date.civil(2007, 8, 15), [:be_fr], [:informal])[0] || {})[:name]
27
+
28
+ assert_equal "Toussaint", (Holidays.on(Date.civil(2007, 11, 1), [:be_fr], [:informal])[0] || {})[:name]
29
+
30
+ assert_equal "Armistice 1918", (Holidays.on(Date.civil(2007, 11, 11), [:be_fr], [:informal])[0] || {})[:name]
31
+
32
+ assert_equal "Noël", (Holidays.on(Date.civil(2007, 12, 25), [:be_fr], [:informal])[0] || {})[:name]
24
33
 
25
34
  end
26
35
  end
@@ -7,20 +7,29 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
7
7
  class Be_nlDefinitionTests < Test::Unit::TestCase # :nodoc:
8
8
 
9
9
  def test_be_nl
10
- {Date.civil(2007,1,1) => 'Nieuwjaar',
11
- Date.civil(2007,4,8) => 'Pasen',
12
- Date.civil(2007,4,9) => 'Paasmaandag',
13
- Date.civil(2007,5,1) => 'Feest van de Arbeid',
14
- Date.civil(2007,5,17) => 'O.H. Hemelvaart',
15
- Date.civil(2007,5,27) => 'Pinksteren',
16
- Date.civil(2007,5,28) => 'Pinkstermaandag',
17
- Date.civil(2007,7,21) => 'Nationale Feestdag',
18
- Date.civil(2007,8,15) => 'O.L.V. Hemelvaart',
19
- Date.civil(2007,11,1) => 'Allerheiligen',
20
- Date.civil(2007,11,11) => 'Wapenstilstand 1918',
21
- Date.civil(2007,12,25) => 'Kerstmis'}.each do |date, name|
22
- assert_equal name, (Holidays.on(date, :be_nl, :informal)[0] || {})[:name]
23
- end
10
+ assert_equal "Nieuwjaar", (Holidays.on(Date.civil(2007, 1, 1), [:be_nl], [:informal])[0] || {})[:name]
11
+
12
+ assert_equal "Pasen", (Holidays.on(Date.civil(2007, 4, 8), [:be_nl], [:informal])[0] || {})[:name]
13
+
14
+ assert_equal "Paasmaandag", (Holidays.on(Date.civil(2007, 4, 9), [:be_nl], [:informal])[0] || {})[:name]
15
+
16
+ assert_equal "Feest van de Arbeid", (Holidays.on(Date.civil(2007, 5, 1), [:be_nl], [:informal])[0] || {})[:name]
17
+
18
+ assert_equal "O.H. Hemelvaart", (Holidays.on(Date.civil(2007, 5, 17), [:be_nl], [:informal])[0] || {})[:name]
19
+
20
+ assert_equal "Pinksteren", (Holidays.on(Date.civil(2007, 5, 27), [:be_nl], [:informal])[0] || {})[:name]
21
+
22
+ assert_equal "Pinkstermaandag", (Holidays.on(Date.civil(2007, 5, 28), [:be_nl], [:informal])[0] || {})[:name]
23
+
24
+ assert_equal "Nationale Feestdag", (Holidays.on(Date.civil(2007, 7, 21), [:be_nl], [:informal])[0] || {})[:name]
25
+
26
+ assert_equal "O.L.V. Hemelvaart", (Holidays.on(Date.civil(2007, 8, 15), [:be_nl], [:informal])[0] || {})[:name]
27
+
28
+ assert_equal "Allerheiligen", (Holidays.on(Date.civil(2007, 11, 1), [:be_nl], [:informal])[0] || {})[:name]
29
+
30
+ assert_equal "Wapenstilstand 1918", (Holidays.on(Date.civil(2007, 11, 11), [:be_nl], [:informal])[0] || {})[:name]
31
+
32
+ assert_equal "Kerstmis", (Holidays.on(Date.civil(2007, 12, 25), [:be_nl], [:informal])[0] || {})[:name]
24
33
 
25
34
  end
26
35
  end
@@ -7,23 +7,35 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
7
7
  class BgDefinitionTests < Test::Unit::TestCase # :nodoc:
8
8
 
9
9
  def test_bg
10
- {Date.civil(2015,1,1) => "New Year's Day",
11
- Date.civil(2015,3,3) => "Liberation Day",
12
- Date.civil(2015,3,28) => "Good Friday",
13
- Date.civil(2015,3,29) => "Holy Saturday",
14
- Date.civil(2015,3,30) => "Easter Sunday",
15
- Date.civil(2015,3,31) => "Easter Monday",
16
- Date.civil(2015,5,1) => "Labour Day",
17
- Date.civil(2015,5,6) => "St. George's Day",
18
- Date.civil(2015,5,24) => "Slavic Literacy Day",
19
- Date.civil(2015,9,6) => "Unification Day",
20
- Date.civil(2015,9,22) => "The Independence Day",
21
- Date.civil(2015,11,1) => "Revival Leader's Day",
22
- Date.civil(2015,12,24) => "Christmas Eve",
23
- Date.civil(2015,12,25) => "Christmas",
24
- Date.civil(2015,12,26) => "Christmas"}.each do |date, name|
25
- assert_equal name, (Holidays.on(date, :bg_en)[0] || {})[:name]
26
- end
10
+ assert_equal "New Year's Day", (Holidays.on(Date.civil(2015, 1, 1), [:bg_en])[0] || {})[:name]
11
+
12
+ assert_equal "Liberation Day", (Holidays.on(Date.civil(2015, 3, 3), [:bg_en])[0] || {})[:name]
13
+
14
+ assert_equal "Good Friday", (Holidays.on(Date.civil(2015, 3, 28), [:bg_en])[0] || {})[:name]
15
+
16
+ assert_equal "Holy Saturday", (Holidays.on(Date.civil(2015, 3, 29), [:bg_en])[0] || {})[:name]
17
+
18
+ assert_equal "Easter Sunday", (Holidays.on(Date.civil(2015, 3, 30), [:bg_en])[0] || {})[:name]
19
+
20
+ assert_equal "Easter Monday", (Holidays.on(Date.civil(2015, 3, 31), [:bg_en])[0] || {})[:name]
21
+
22
+ assert_equal "Labour Day", (Holidays.on(Date.civil(2015, 5, 1), [:bg_en])[0] || {})[:name]
23
+
24
+ assert_equal "St. George's Day", (Holidays.on(Date.civil(2015, 5, 6), [:bg_en])[0] || {})[:name]
25
+
26
+ assert_equal "Slavic Literacy Day", (Holidays.on(Date.civil(2015, 5, 24), [:bg_en])[0] || {})[:name]
27
+
28
+ assert_equal "Unification Day", (Holidays.on(Date.civil(2015, 9, 6), [:bg_en])[0] || {})[:name]
29
+
30
+ assert_equal "The Independence Day", (Holidays.on(Date.civil(2015, 9, 22), [:bg_en])[0] || {})[:name]
31
+
32
+ assert_equal "Revival Leader's Day", (Holidays.on(Date.civil(2015, 11, 1), [:bg_en])[0] || {})[:name]
33
+
34
+ assert_equal "Christmas Eve", (Holidays.on(Date.civil(2015, 12, 24), [:bg_en])[0] || {})[:name]
35
+
36
+ assert_equal "Christmas", (Holidays.on(Date.civil(2015, 12, 25), [:bg_en])[0] || {})[:name]
37
+
38
+ assert_equal "Christmas", (Holidays.on(Date.civil(2015, 12, 26), [:bg_en])[0] || {})[:name]
27
39
 
28
40
  end
29
41
  end
@@ -7,25 +7,39 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
7
7
  class BrDefinitionTests < Test::Unit::TestCase # :nodoc:
8
8
 
9
9
  def test_br
10
- {Date.civil(2008,1,1) => 'Dia da Confraternização Universal',
11
- Date.civil(2005,2,8) => 'Carnaval',
12
- Date.civil(2006,2,28) => 'Carnaval',
13
- Date.civil(2007,2,20) => 'Carnaval',
14
- Date.civil(2008,2,5) => 'Carnaval',
15
- Date.civil(2008,3,21) => 'Sexta-feira Santa',
16
- Date.civil(2008,3,23) => 'Páscoa',
17
- Date.civil(2008,4,21) => 'Dia de Tiradentes',
18
- Date.civil(2008,5,1) => 'Dia do Trabalho',
19
- Date.civil(2005,5,26) => 'Corpus Christi',
20
- Date.civil(2007,6,7) => 'Corpus Christi',
21
- Date.civil(2008,5,22) => 'Corpus Christi',
22
- Date.civil(2008,9,7) => 'Proclamação da Independência',
23
- Date.civil(2008,10,12) => 'Dia de Nossa Senhora Aparecida',
24
- Date.civil(2008,11,2) => 'Dia de Finados',
25
- Date.civil(2008,11,15) => 'Proclamação da República',
26
- Date.civil(2008,12,25) => 'Natal'}.each do |date, name|
27
- assert_equal name, (Holidays.on(date, :br, :informal)[0] || {})[:name]
28
- end
10
+ assert_equal "Dia da Confraternização Universal", (Holidays.on(Date.civil(2008, 1, 1), [:br], [:informal])[0] || {})[:name]
11
+
12
+ assert_equal "Carnaval", (Holidays.on(Date.civil(2005, 2, 8), [:br], [:informal])[0] || {})[:name]
13
+
14
+ assert_equal "Carnaval", (Holidays.on(Date.civil(2006, 2, 28), [:br], [:informal])[0] || {})[:name]
15
+
16
+ assert_equal "Carnaval", (Holidays.on(Date.civil(2007, 2, 20), [:br], [:informal])[0] || {})[:name]
17
+
18
+ assert_equal "Carnaval", (Holidays.on(Date.civil(2008, 2, 5), [:br], [:informal])[0] || {})[:name]
19
+
20
+ assert_equal "Sexta-feira Santa", (Holidays.on(Date.civil(2008, 3, 21), [:br], [:informal])[0] || {})[:name]
21
+
22
+ assert_equal "Páscoa", (Holidays.on(Date.civil(2008, 3, 23), [:br], [:informal])[0] || {})[:name]
23
+
24
+ assert_equal "Dia de Tiradentes", (Holidays.on(Date.civil(2008, 4, 21), [:br], [:informal])[0] || {})[:name]
25
+
26
+ assert_equal "Dia do Trabalho", (Holidays.on(Date.civil(2008, 5, 1), [:br], [:informal])[0] || {})[:name]
27
+
28
+ assert_equal "Corpus Christi", (Holidays.on(Date.civil(2005, 5, 26), [:br], [:informal])[0] || {})[:name]
29
+
30
+ assert_equal "Corpus Christi", (Holidays.on(Date.civil(2007, 6, 7), [:br], [:informal])[0] || {})[:name]
31
+
32
+ assert_equal "Corpus Christi", (Holidays.on(Date.civil(2008, 5, 22), [:br], [:informal])[0] || {})[:name]
33
+
34
+ assert_equal "Proclamação da Independência", (Holidays.on(Date.civil(2008, 9, 7), [:br], [:informal])[0] || {})[:name]
35
+
36
+ assert_equal "Dia de Nossa Senhora Aparecida", (Holidays.on(Date.civil(2008, 10, 12), [:br], [:informal])[0] || {})[:name]
37
+
38
+ assert_equal "Dia de Finados", (Holidays.on(Date.civil(2008, 11, 2), [:br], [:informal])[0] || {})[:name]
39
+
40
+ assert_equal "Proclamação da República", (Holidays.on(Date.civil(2008, 11, 15), [:br], [:informal])[0] || {})[:name]
41
+
42
+ assert_equal "Natal", (Holidays.on(Date.civil(2008, 12, 25), [:br], [:informal])[0] || {})[:name]
29
43
 
30
44
  end
31
45
  end
@@ -7,205 +7,204 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
7
7
  class CaDefinitionTests < Test::Unit::TestCase # :nodoc:
8
8
 
9
9
  def test_ca
10
- {Date.civil(2008,1,1) => 'New Year\'s Day',
11
- Date.civil(2008,3,21) => 'Good Friday',
12
- Date.civil(2013,3,31) => 'Easter Sunday',
13
- Date.civil(2008,3,24) => 'Easter Monday',
14
- Date.civil(2008,7,1) => 'Canada Day',
15
- Date.civil(2008,9,1) => 'Labour Day',
16
- Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
17
- assert_equal name, (Holidays.on(date, :ca, :informal)[0] || {})[:name]
18
- end
10
+ assert_equal "New Year's Day", (Holidays.on(Date.civil(2008, 1, 1), [:ca], [:informal])[0] || {})[:name]
19
11
 
20
- # Family Day in Alberta - Should only be active on 1990 or later
21
- [
22
- Date.civil(1990,2,19),
23
- Date.civil(2013,2,18),
24
- Date.civil(2014,2,17),
25
- Date.civil(2044,2,15),
26
- ].each do |date|
27
- assert_equal 'Family Day', Holidays.on(date, :ca_ab)[0][:name]
28
- end
12
+ assert_equal "Good Friday", (Holidays.on(Date.civil(2008, 3, 21), [:ca], [:informal])[0] || {})[:name]
29
13
 
30
- # Family Day in Alberta - should not be active before 1990
31
- [
32
- Date.civil(1970,2,16),
33
- Date.civil(1988,2,15),
34
- Date.civil(1989,2,20),
35
- ].each do |date|
36
- assert_equal [], Holidays.on(date, :ca_ab)
37
- end
14
+ assert_equal "Easter Sunday", (Holidays.on(Date.civil(2013, 3, 31), [:ca], [:informal])[0] || {})[:name]
38
15
 
39
- # Family Day in Saskatchewan - Should only be active on 2007 or later
40
- [
41
- Date.civil(2007,2,19),
42
- Date.civil(2013,2,18),
43
- Date.civil(2014,2,17),
44
- Date.civil(2044,2,15),
45
- ].each do |date|
46
- assert_equal 'Family Day', Holidays.on(date, :ca_sk)[0][:name]
47
- end
16
+ assert_equal "Easter Monday", (Holidays.on(Date.civil(2008, 3, 24), [:ca], [:informal])[0] || {})[:name]
48
17
 
49
- # Family Day in Saskatchewan - should not be active before 2007
50
- [
51
- Date.civil(1970,2,16),
52
- Date.civil(1988,2,15),
53
- Date.civil(1989,2,20),
54
- Date.civil(2006,2,20),
55
- ].each do |date|
56
- assert_equal [], Holidays.on(date, :ca_sk)
57
- end
18
+ assert_equal "Canada Day", (Holidays.on(Date.civil(2008, 7, 1), [:ca], [:informal])[0] || {})[:name]
58
19
 
59
- # Family Day in Ontario - Should only be active on 2008 or later
60
- [
61
- Date.civil(2008,2,18),
62
- Date.civil(2013,2,18),
63
- Date.civil(2014,2,17),
64
- Date.civil(2044,2,15),
65
- ].each do |date|
66
- assert_equal 'Family Day', Holidays.on(date, :ca_on)[0][:name]
67
- end
20
+ assert_equal "Labour Day", (Holidays.on(Date.civil(2008, 9, 1), [:ca], [:informal])[0] || {})[:name]
68
21
 
69
- # Family Day in Ontario - should not be active before 2008
70
- [
71
- Date.civil(1970,2,16),
72
- Date.civil(1988,2,15),
73
- Date.civil(1989,2,20),
74
- Date.civil(2006,2,20),
75
- Date.civil(2007,2,19),
76
- ].each do |date|
77
- assert_equal [], Holidays.on(date, :ca_on)
78
- end
22
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2008, 12, 25), [:ca], [:informal])[0] || {})[:name]
79
23
 
80
- # Family Day in BC - Should only be active on 2013 or later
81
- [
82
- Date.civil(2013,2,11),
83
- Date.civil(2014,2,10),
84
- Date.civil(2044,2,8),
85
- ].each do |date|
86
- assert_equal 'Family Day', Holidays.on(date, :ca_bc)[0][:name]
87
- end
24
+ assert_equal "Family Day", (Holidays.on(Date.civil(1990, 2, 19), [:ca_ab])[0] || {})[:name]
88
25
 
89
- # Family Day in BC - should not be active before 2013
90
- [
91
- Date.civil(2000,2,14),
92
- Date.civil(2011,2,14),
93
- Date.civil(2012,2,13),
94
- ].each do |date|
95
- assert_equal [], Holidays.on(date, :ca_bc)
96
- end
26
+ assert_equal "Family Day", (Holidays.on(Date.civil(2013, 2, 18), [:ca_ab])[0] || {})[:name]
97
27
 
98
- # Nova Scotia Heritage Day - should only be active on 2015 and later
99
- [
100
- Date.civil(2015,2,16),
101
- Date.civil(2016,2,15),
102
- Date.civil(2017,2,20),
103
- Date.civil(2044,2,15),
104
- ].each do |date|
105
- assert_equal 'Nova Scotia Heritage Day', Holidays.on(date, :ca_ns)[0][:name]
106
- end
28
+ assert_equal "Family Day", (Holidays.on(Date.civil(2014, 2, 17), [:ca_ab])[0] || {})[:name]
107
29
 
108
- # Nova Scotia Heritage Day - should not be active before 2015
109
- [
110
- Date.civil(2000,2,21),
111
- Date.civil(2012,2,20),
112
- Date.civil(2013,2,18),
113
- Date.civil(2014,2,17),
114
- ].each do |date|
115
- assert_equal [], Holidays.on(date, :ca_ns)
116
- end
30
+ assert_equal "Family Day", (Holidays.on(Date.civil(2044, 2, 15), [:ca_ab])[0] || {})[:name]
117
31
 
118
- # Islander Day in PE
119
- [ Date.civil(2013,2,18), Date.civil(2014,2,17) ].each do |date|
120
- assert_equal 'Islander Day', Holidays.on(date, :ca_pe)[0][:name]
121
- end
32
+ assert_nil (Holidays.on(Date.civil(1970, 2, 16), [:ca_ab])[0] || {})[:name]
122
33
 
34
+ assert_nil (Holidays.on(Date.civil(1988, 2, 15), [:ca_ab])[0] || {})[:name]
123
35
 
124
- # Victoria Day
125
- [:ca_ab, :ca_bc, :ca_mb, :ca_nt, :ca_nu, :ca_on, :ca_sk, :ca_yt].each do |r|
126
- [
127
- Date.civil(2004,5,24), Date.civil(2005,5,23), Date.civil(2006,5,22),
128
- Date.civil(2007,5,21), Date.civil(2008,5,19)
129
- ].each do |date|
130
- assert_equal 'Victoria Day', Holidays.on(date, r)[0][:name]
131
- end
132
- end
36
+ assert_nil (Holidays.on(Date.civil(1989, 2, 20), [:ca_ab])[0] || {})[:name]
133
37
 
134
- # First Monday in August
135
- [Date.civil(2013,8,5), Date.civil(2014,8,4), Date.civil(2015,8,3)].each do |date|
136
- { :ca_bc => 'B.C. Day',
137
- :ca_sk => 'Saskatchewan Day',
138
- :ca_ab => 'Heritage Day',
139
- :ca_ns => 'Natal Day',
140
- :ca_nt => 'Civic Holiday',
141
- :ca_nu => 'Civic Holiday',
142
- :ca_pe => 'Civic Holiday',
143
- :ca_nb => 'New Brunswick Day'
144
- }.each do |region, name|
145
- assert_equal name, Holidays.on(date, region)[0][:name]
146
- end
147
- end
38
+ assert_equal "Family Day", (Holidays.on(Date.civil(2007, 2, 19), [:ca_sk])[0] || {})[:name]
148
39
 
149
- # Civic Holiday is only by convention in :ca_on
150
- [Date.civil(2013,8,5), Date.civil(2014,8,4), Date.civil(2015,8,3)].each do |date|
151
- assert_equal 'Civic Holiday', Holidays.on(date, :ca_on, :informal)[0][:name]
152
- end
40
+ assert_equal "Family Day", (Holidays.on(Date.civil(2013, 2, 18), [:ca_sk])[0] || {})[:name]
153
41
 
154
- # Remembrance Day in all Canadian provinces
155
- # except (Nova Scotia, Manitoba, Ontario, and Quebec)
156
- [
157
- :ca_ab,
158
- :ca_sk,
159
- :ca_bc,
160
- :ca_pe,
161
- :ca_nl,
162
- :ca_nt,
163
- :ca_nu,
164
- :ca_nb,
165
- :ca_yt
166
- ].each do |province|
167
- # Remembrance Day observed
168
- [Date.civil(2010, 11, 11), Date.civil(2012, 11, 12), Date.civil(2017, 11, 13)].each do |date|
169
- assert_equal 'Remembrance Day', Holidays.on(date, province, :observed)[0][:name]
170
- end
42
+ assert_equal "Family Day", (Holidays.on(Date.civil(2014, 2, 17), [:ca_sk])[0] || {})[:name]
171
43
 
172
- # Remembrance Day
173
- assert_equal "Remembrance Day", Holidays.on(Date.civil(2016,11,11), province)[0][:name]
174
- end
44
+ assert_equal "Family Day", (Holidays.on(Date.civil(2044, 2, 15), [:ca_sk])[0] || {})[:name]
175
45
 
176
- # New years observed date
177
- [Date.civil(2011, 1, 3), Date.civil(2012, 1, 2), Date.civil(2016, 1, 1)].each do |date|
178
- assert_equal 'New Year\'s Day', Holidays.on(date, :ca, :observed)[0][:name]
179
- end
46
+ assert_nil (Holidays.on(Date.civil(1970, 2, 16), [:ca_sk])[0] || {})[:name]
180
47
 
181
- # Canada Day observed date
182
- [Date.civil(2011, 7, 1), Date.civil(2012, 7, 2), Date.civil(2017, 7, 3)].each do |date|
183
- assert_equal 'Canada Day', Holidays.on(date, :ca, :observed)[0][:name]
184
- end
48
+ assert_nil (Holidays.on(Date.civil(1988, 2, 15), [:ca_sk])[0] || {})[:name]
185
49
 
186
- # Christmas observed date
187
- [Date.civil(2010, 12, 27), Date.civil(2012, 12, 25), Date.civil(2016, 12, 26)].each do |date|
188
- assert_equal 'Christmas Day', Holidays.on(date, :ca, :observed)[0][:name]
189
- end
50
+ assert_nil (Holidays.on(Date.civil(1989, 2, 20), [:ca_sk])[0] || {})[:name]
190
51
 
191
- # Boxing Day observed date
192
- [Date.civil(2010, 12, 28), Date.civil(2012, 12, 26), Date.civil(2016, 12, 27),
193
- Date.civil(2015, 12, 28)].each do |date|
194
- assert_equal 'Boxing Day', Holidays.on(date, :ca_on, :observed)[0][:name]
195
- end
52
+ assert_nil (Holidays.on(Date.civil(2006, 2, 20), [:ca_sk])[0] || {})[:name]
196
53
 
54
+ assert_equal "Family Day", (Holidays.on(Date.civil(2008, 2, 18), [:ca_on])[0] || {})[:name]
197
55
 
198
- {Date.civil(2013,2,2) => 'Groundhog Day',
199
- Date.civil(2013,2,14) => 'Valentine\'s Day',
200
- Date.civil(2013,3,17) => 'St. Patrick\'s Day',
201
- Date.civil(2013,4,1) => 'April Fool\'s Day',
202
- Date.civil(2013,4,22) => 'Earth Day',
203
- Date.civil(2013,5,12) => 'Mother\'s Day',
204
- Date.civil(2013,5,18) => 'Armed Forces Day',
205
- Date.civil(2013,6,16) => 'Father\'s Day',
206
- Date.civil(2013,10,31) => 'Halloween'}.each do |date, name|
207
- assert_equal name, (Holidays.on(date, :us, :informal)[0] || {})[:name]
208
- end
56
+ assert_equal "Family Day", (Holidays.on(Date.civil(2013, 2, 18), [:ca_on])[0] || {})[:name]
57
+
58
+ assert_equal "Family Day", (Holidays.on(Date.civil(2014, 2, 17), [:ca_on])[0] || {})[:name]
59
+
60
+ assert_equal "Family Day", (Holidays.on(Date.civil(2044, 2, 15), [:ca_on])[0] || {})[:name]
61
+
62
+ assert_nil (Holidays.on(Date.civil(1970, 2, 16), [:ca_on])[0] || {})[:name]
63
+
64
+ assert_nil (Holidays.on(Date.civil(1988, 2, 15), [:ca_on])[0] || {})[:name]
65
+
66
+ assert_nil (Holidays.on(Date.civil(1989, 2, 20), [:ca_on])[0] || {})[:name]
67
+
68
+ assert_nil (Holidays.on(Date.civil(2006, 2, 20), [:ca_on])[0] || {})[:name]
69
+
70
+ assert_nil (Holidays.on(Date.civil(2007, 2, 19), [:ca_on])[0] || {})[:name]
71
+
72
+ assert_equal "Family Day", (Holidays.on(Date.civil(2013, 2, 11), [:ca_bc])[0] || {})[:name]
73
+
74
+ assert_equal "Family Day", (Holidays.on(Date.civil(2014, 2, 10), [:ca_bc])[0] || {})[:name]
75
+
76
+ assert_equal "Family Day", (Holidays.on(Date.civil(2044, 2, 8), [:ca_bc])[0] || {})[:name]
77
+
78
+ assert_nil (Holidays.on(Date.civil(2000, 2, 14), [:ca_bc])[0] || {})[:name]
79
+
80
+ assert_nil (Holidays.on(Date.civil(2011, 2, 14), [:ca_bc])[0] || {})[:name]
81
+
82
+ assert_nil (Holidays.on(Date.civil(2012, 2, 13), [:ca_bc])[0] || {})[:name]
83
+
84
+ assert_equal "Nova Scotia Heritage Day", (Holidays.on(Date.civil(2015, 2, 16), [:ca_ns])[0] || {})[:name]
85
+
86
+ assert_equal "Nova Scotia Heritage Day", (Holidays.on(Date.civil(2016, 2, 15), [:ca_ns])[0] || {})[:name]
87
+
88
+ assert_equal "Nova Scotia Heritage Day", (Holidays.on(Date.civil(2017, 2, 20), [:ca_ns])[0] || {})[:name]
89
+
90
+ assert_equal "Nova Scotia Heritage Day", (Holidays.on(Date.civil(2044, 2, 15), [:ca_ns])[0] || {})[:name]
91
+
92
+ assert_nil (Holidays.on(Date.civil(2000, 2, 21), [:ca_ns])[0] || {})[:name]
93
+
94
+ assert_nil (Holidays.on(Date.civil(2012, 2, 20), [:ca_ns])[0] || {})[:name]
95
+
96
+ assert_nil (Holidays.on(Date.civil(2013, 2, 18), [:ca_ns])[0] || {})[:name]
97
+
98
+ assert_nil (Holidays.on(Date.civil(2014, 2, 17), [:ca_ns])[0] || {})[:name]
99
+
100
+ assert_equal "Islander Day", (Holidays.on(Date.civil(2013, 2, 18), [:ca_pe])[0] || {})[:name]
101
+
102
+ assert_equal "Islander Day", (Holidays.on(Date.civil(2014, 2, 17), [:ca_pe])[0] || {})[:name]
103
+
104
+ assert_equal "Victoria Day", (Holidays.on(Date.civil(2004, 5, 24), [:ca_ab, :ca_bc, :ca_mb, :ca_nt, :ca_nu, :ca_on, :ca_sk, :ca_yt])[0] || {})[:name]
105
+ assert_equal "Victoria Day", (Holidays.on(Date.civil(2005, 5, 23), [:ca_ab, :ca_bc, :ca_mb, :ca_nt, :ca_nu, :ca_on, :ca_sk, :ca_yt])[0] || {})[:name]
106
+ assert_equal "Victoria Day", (Holidays.on(Date.civil(2006, 5, 22), [:ca_ab, :ca_bc, :ca_mb, :ca_nt, :ca_nu, :ca_on, :ca_sk, :ca_yt])[0] || {})[:name]
107
+ assert_equal "Victoria Day", (Holidays.on(Date.civil(2007, 5, 21), [:ca_ab, :ca_bc, :ca_mb, :ca_nt, :ca_nu, :ca_on, :ca_sk, :ca_yt])[0] || {})[:name]
108
+ assert_equal "Victoria Day", (Holidays.on(Date.civil(2008, 5, 19), [:ca_ab, :ca_bc, :ca_mb, :ca_nt, :ca_nu, :ca_on, :ca_sk, :ca_yt])[0] || {})[:name]
109
+
110
+ assert_equal "B.C. Day", (Holidays.on(Date.civil(2013, 8, 5), [:ca_bc])[0] || {})[:name]
111
+
112
+ assert_equal "Saskatchewan Day", (Holidays.on(Date.civil(2013, 8, 5), [:ca_sk])[0] || {})[:name]
113
+
114
+ assert_equal "Heritage Day", (Holidays.on(Date.civil(2013, 8, 5), [:ca_ab])[0] || {})[:name]
115
+
116
+ assert_equal "Natal Day", (Holidays.on(Date.civil(2013, 8, 5), [:ca_ns])[0] || {})[:name]
117
+
118
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2013, 8, 5), [:ca_on], [:informal])[0] || {})[:name]
119
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2014, 8, 4), [:ca_on], [:informal])[0] || {})[:name]
120
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2015, 8, 3), [:ca_on], [:informal])[0] || {})[:name]
121
+
122
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2013, 8, 5), [:ca_nt])[0] || {})[:name]
123
+
124
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2013, 8, 5), [:ca_nu])[0] || {})[:name]
125
+
126
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2013, 8, 5), [:ca_pe])[0] || {})[:name]
127
+
128
+ assert_equal "New Brunswick Day", (Holidays.on(Date.civil(2013, 8, 5), [:ca_nb])[0] || {})[:name]
129
+
130
+ assert_equal "B.C. Day", (Holidays.on(Date.civil(2014, 8, 4), [:ca_bc])[0] || {})[:name]
131
+
132
+ assert_equal "Saskatchewan Day", (Holidays.on(Date.civil(2014, 8, 4), [:ca_sk])[0] || {})[:name]
133
+
134
+ assert_equal "Heritage Day", (Holidays.on(Date.civil(2014, 8, 4), [:ca_ab])[0] || {})[:name]
135
+
136
+ assert_equal "Natal Day", (Holidays.on(Date.civil(2014, 8, 4), [:ca_ns])[0] || {})[:name]
137
+
138
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2014, 8, 4), [:ca_nt])[0] || {})[:name]
139
+
140
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2014, 8, 4), [:ca_nu])[0] || {})[:name]
141
+
142
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2014, 8, 4), [:ca_pe])[0] || {})[:name]
143
+
144
+ assert_equal "New Brunswick Day", (Holidays.on(Date.civil(2014, 8, 4), [:ca_nb])[0] || {})[:name]
145
+
146
+ assert_equal "B.C. Day", (Holidays.on(Date.civil(2015, 8, 3), [:ca_bc])[0] || {})[:name]
147
+
148
+ assert_equal "Saskatchewan Day", (Holidays.on(Date.civil(2015, 8, 3), [:ca_sk])[0] || {})[:name]
149
+
150
+ assert_equal "Heritage Day", (Holidays.on(Date.civil(2015, 8, 3), [:ca_ab])[0] || {})[:name]
151
+
152
+ assert_equal "Natal Day", (Holidays.on(Date.civil(2015, 8, 3), [:ca_ns])[0] || {})[:name]
153
+
154
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2015, 8, 3), [:ca_nt])[0] || {})[:name]
155
+
156
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2015, 8, 3), [:ca_nu])[0] || {})[:name]
157
+
158
+ assert_equal "Civic Holiday", (Holidays.on(Date.civil(2015, 8, 3), [:ca_pe])[0] || {})[:name]
159
+
160
+ assert_equal "New Brunswick Day", (Holidays.on(Date.civil(2015, 8, 3), [:ca_nb])[0] || {})[:name]
161
+
162
+ assert_equal "Remembrance Day", (Holidays.on(Date.civil(2010, 11, 11), [:ca_ab, :ca_sk, :ca_bc, :ca_pe, :ca_nl, :ca_nt, :ca_nu, :ca_nb, :ca_yt], [:observed])[0] || {})[:name]
163
+ assert_equal "Remembrance Day", (Holidays.on(Date.civil(2012, 11, 12), [:ca_ab, :ca_sk, :ca_bc, :ca_pe, :ca_nl, :ca_nt, :ca_nu, :ca_nb, :ca_yt], [:observed])[0] || {})[:name]
164
+ assert_equal "Remembrance Day", (Holidays.on(Date.civil(2017, 11, 13), [:ca_ab, :ca_sk, :ca_bc, :ca_pe, :ca_nl, :ca_nt, :ca_nu, :ca_nb, :ca_yt], [:observed])[0] || {})[:name]
165
+
166
+ assert_equal "Remembrance Day", (Holidays.on(Date.civil(2016, 11, 11), [:ca_ab, :ca_sk, :ca_bc, :ca_pe, :ca_nl, :ca_nt, :ca_nu, :ca_nb, :ca_yt])[0] || {})[:name]
167
+
168
+ assert_equal "New Year's Day", (Holidays.on(Date.civil(2011, 1, 3), [:ca], [:observed])[0] || {})[:name]
169
+
170
+ assert_equal "New Year's Day", (Holidays.on(Date.civil(2012, 1, 2), [:ca], [:observed])[0] || {})[:name]
171
+
172
+ assert_equal "New Year's Day", (Holidays.on(Date.civil(2016, 1, 1), [:ca], [:observed])[0] || {})[:name]
173
+
174
+ assert_equal "Canada Day", (Holidays.on(Date.civil(2011, 7, 1), [:ca], [:observed])[0] || {})[:name]
175
+
176
+ assert_equal "Canada Day", (Holidays.on(Date.civil(2012, 7, 2), [:ca], [:observed])[0] || {})[:name]
177
+
178
+ assert_equal "Canada Day", (Holidays.on(Date.civil(2017, 7, 3), [:ca], [:observed])[0] || {})[:name]
179
+
180
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2010, 12, 27), [:ca], [:observed])[0] || {})[:name]
181
+
182
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2012, 12, 25), [:ca], [:observed])[0] || {})[:name]
183
+
184
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 26), [:ca], [:observed])[0] || {})[:name]
185
+
186
+ assert_equal "Boxing Day", (Holidays.on(Date.civil(2010, 12, 28), [:ca_on], [:observed])[0] || {})[:name]
187
+ assert_equal "Boxing Day", (Holidays.on(Date.civil(2012, 12, 26), [:ca_on], [:observed])[0] || {})[:name]
188
+ assert_equal "Boxing Day", (Holidays.on(Date.civil(2015, 12, 28), [:ca_on], [:observed])[0] || {})[:name]
189
+ assert_equal "Boxing Day", (Holidays.on(Date.civil(2016, 12, 27), [:ca_on], [:observed])[0] || {})[:name]
190
+
191
+ assert_equal "Groundhog Day", (Holidays.on(Date.civil(2013, 2, 2), [:us], [:informal])[0] || {})[:name]
192
+
193
+ assert_equal "Valentine's Day", (Holidays.on(Date.civil(2013, 2, 14), [:us], [:informal])[0] || {})[:name]
194
+
195
+ assert_equal "St. Patrick's Day", (Holidays.on(Date.civil(2013, 3, 17), [:us], [:informal])[0] || {})[:name]
196
+
197
+ assert_equal "April Fool's Day", (Holidays.on(Date.civil(2013, 4, 1), [:us], [:informal])[0] || {})[:name]
198
+
199
+ assert_equal "Earth Day", (Holidays.on(Date.civil(2013, 4, 22), [:us], [:informal])[0] || {})[:name]
200
+
201
+ assert_equal "Mother's Day", (Holidays.on(Date.civil(2013, 5, 12), [:us], [:informal])[0] || {})[:name]
202
+
203
+ assert_equal "Armed Forces Day", (Holidays.on(Date.civil(2013, 5, 18), [:us], [:informal])[0] || {})[:name]
204
+
205
+ assert_equal "Father's Day", (Holidays.on(Date.civil(2013, 6, 16), [:us], [:informal])[0] || {})[:name]
206
+
207
+ assert_equal "Halloween", (Holidays.on(Date.civil(2013, 10, 31), [:us], [:informal])[0] || {})[:name]
209
208
 
210
209
  end
211
210
  end