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
@@ -1,3 +1,3 @@
1
1
  module Holidays
2
- VERSION = '5.7.0'
2
+ VERSION = '6.0.0'
3
3
  end
@@ -6,4 +6,5 @@ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
6
6
  SimpleCov.coverage_dir 'reports/coverage'
7
7
  SimpleCov.start do
8
8
  add_filter 'lib/generated_definitions/'
9
+ add_filter 'lib/holidays/factory/'
9
10
  end
@@ -26,3 +26,10 @@ months:
26
26
  year_ranges:
27
27
  - before: 2015
28
28
  - after: 2017
29
+
30
+ tests:
31
+ - given:
32
+ date: '2017-01-01'
33
+ regions: [custom_year_range_file]
34
+ expect:
35
+ name: "after_year"
@@ -3,7 +3,10 @@ months:
3
3
  - name: Company Founding!
4
4
  regions: [custom_multiple_files]
5
5
  mday: 5
6
- tests: |
7
- {Date.civil(2013,10,5) => 'Company Founding!'}.each do |date, name|
8
- assert_equal name, (Holidays.on(date, :custom_multiple_files)[0] || {})[:name]
9
- end
6
+
7
+ tests:
8
+ - given:
9
+ date: "2013-10-5"
10
+ regions: ["custom_multiple_files"]
11
+ expect:
12
+ name: "Company Founding!"
@@ -3,7 +3,10 @@ months:
3
3
  - name: Company Founding
4
4
  regions: [custom_single_file]
5
5
  mday: 20
6
- tests: |
7
- {Date.civil(2013,6,20) => 'Company Founding'}.each do |date, name|
8
- assert_equal name, (Holidays.on(date, :custom_single_file)[0] || {})[:name]
9
- end
6
+
7
+ tests:
8
+ - given:
9
+ date: '2013-06-20'
10
+ regions: [custom_single_file]
11
+ expect:
12
+ name: "Company Founding"
@@ -14,11 +14,15 @@ methods:
14
14
  source: |
15
15
  d = Date.civil(year, month, 1)
16
16
  d + 2
17
- tests: |
18
- {Date.civil(2013,6,20) => 'Company Founding'}.each do |date, name|
19
- assert_equal name, (Holidays.on(date, :custom_single_file)[0] || {})[:name]
20
- end
21
17
 
22
- {Date.civil(2015, 1, 1) => 'Custom Holiday'}.each do |date, name|
23
- assert_equal name, (Holidays.on(date, :custom_single_file)[0] || {}[:name]
24
- end
18
+ tests:
19
+ - given:
20
+ date: '2013-06-20'
21
+ regions: [custom_single_file]
22
+ expect:
23
+ name: "Company Founding"
24
+ - given:
25
+ date: '2015-01-01'
26
+ regions: [custom_single_file]
27
+ expect:
28
+ name: "Custom Holiday"
@@ -7,25 +7,39 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
7
7
  class ArDefinitionTests < Test::Unit::TestCase # :nodoc:
8
8
 
9
9
  def test_ar
10
- {Date.civil(2016,1,1) => 'Año Nuevo',
11
- Date.civil(2016,2,8) => 'Carnaval',
12
- Date.civil(2016,2,9) => 'Carnaval',
13
- Date.civil(2016,3,24) => 'Día Nacional de la Memoria por la Verdad y la Justicia',
14
- Date.civil(2016,3,25) => 'Viernes Santo',
15
- Date.civil(2016,4,2) => 'Día del Veterano y de los Caídos en la Guerra de Malvinas',
16
- Date.civil(2016,5,1) => 'Día del Trabajador',
17
- Date.civil(2016,5,25) => 'Día de la Revolución de Mayo',
18
- Date.civil(2016,6,20) => 'Día de la Bandera',
19
- Date.civil(2016,7,8) => 'Feriado puente turístico',
20
- Date.civil(2016,7,9) => 'Día de la Independencia',
21
- Date.civil(2016,8,15) => 'Paso a la Inmortalidad del General José de San Martín',
22
- Date.civil(2016,10,12) => 'Día del Respeto a la Diversidad Cultural',
23
- Date.civil(2016,11,20) => 'Día de la Soberanía Nacional',
24
- Date.civil(2016,12,8) => 'Inmaculada Concepción de María',
25
- Date.civil(2016,12,9) => 'Feriado puente turístico',
26
- Date.civil(2016,12,25) => 'Navidad'}.each do |date, name|
27
- assert_equal name, (Holidays.on(date, :ar, :informal)[0] || {})[:name]
28
- end
10
+ assert_equal "Año Nuevo", (Holidays.on(Date.civil(2016, 1, 1), [:ar], [:informal])[0] || {})[:name]
11
+
12
+ assert_equal "Carnaval", (Holidays.on(Date.civil(2016, 2, 8), [:ar], [:informal])[0] || {})[:name]
13
+
14
+ assert_equal "Carnaval", (Holidays.on(Date.civil(2016, 2, 9), [:ar], [:informal])[0] || {})[:name]
15
+
16
+ assert_equal "Día Nacional de la Memoria por la Verdad y la Justicia", (Holidays.on(Date.civil(2016, 3, 24), [:ar], [:informal])[0] || {})[:name]
17
+
18
+ assert_equal "Viernes Santo", (Holidays.on(Date.civil(2016, 3, 25), [:ar], [:informal])[0] || {})[:name]
19
+
20
+ assert_equal "Día del Veterano y de los Caídos en la Guerra de Malvinas", (Holidays.on(Date.civil(2016, 4, 2), [:ar], [:informal])[0] || {})[:name]
21
+
22
+ assert_equal "Día del Trabajador", (Holidays.on(Date.civil(2016, 5, 1), [:ar], [:informal])[0] || {})[:name]
23
+
24
+ assert_equal "Día de la Revolución de Mayo", (Holidays.on(Date.civil(2016, 5, 25), [:ar], [:informal])[0] || {})[:name]
25
+
26
+ assert_equal "Día de la Bandera", (Holidays.on(Date.civil(2016, 6, 20), [:ar], [:informal])[0] || {})[:name]
27
+
28
+ assert_equal "Feriado puente turístico", (Holidays.on(Date.civil(2016, 7, 8), [:ar], [:informal])[0] || {})[:name]
29
+
30
+ assert_equal "Día de la Independencia", (Holidays.on(Date.civil(2016, 7, 9), [:ar], [:informal])[0] || {})[:name]
31
+
32
+ assert_equal "Paso a la Inmortalidad del General José de San Martín", (Holidays.on(Date.civil(2016, 8, 15), [:ar], [:informal])[0] || {})[:name]
33
+
34
+ assert_equal "Día del Respeto a la Diversidad Cultural", (Holidays.on(Date.civil(2016, 10, 12), [:ar], [:informal])[0] || {})[:name]
35
+
36
+ assert_equal "Día de la Soberanía Nacional", (Holidays.on(Date.civil(2016, 11, 20), [:ar], [:informal])[0] || {})[:name]
37
+
38
+ assert_equal "Inmaculada Concepción de María", (Holidays.on(Date.civil(2016, 12, 8), [:ar], [:informal])[0] || {})[:name]
39
+
40
+ assert_equal "Feriado puente turístico", (Holidays.on(Date.civil(2016, 12, 9), [:ar], [:informal])[0] || {})[:name]
41
+
42
+ assert_equal "Navidad", (Holidays.on(Date.civil(2016, 12, 25), [:ar], [:informal])[0] || {})[:name]
29
43
 
30
44
  end
31
45
  end
@@ -7,18 +7,21 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
7
7
  class AtDefinitionTests < Test::Unit::TestCase # :nodoc:
8
8
 
9
9
  def test_at
10
- {Date.civil(2009,1,1) => 'Neujahrstag',
11
- Date.civil(2009,4,13) => 'Ostermontag',
12
- Date.civil(2009,5,1) => 'Staatsfeiertag',
13
- Date.civil(2009,5,21) => 'Christi Himmelfahrt',
14
- Date.civil(2009,6,1) => 'Pfingstmontag',
15
- Date.civil(2009,10,26) => 'Nationalfeiertag',
16
- Date.civil(2009,12,25) => '1. Weihnachtstag',
17
- Date.civil(2009,12,26) => '2. Weihnachtstag'}.each do |date, name|
18
- assert_equal name, (Holidays.on(date, :at, :informal)[0] || {})[:name]
19
- end
10
+ assert_equal "Neujahrstag", (Holidays.on(Date.civil(2009, 1, 1), [:at], [:informal])[0] || {})[:name]
11
+
12
+ assert_equal "Ostermontag", (Holidays.on(Date.civil(2009, 4, 13), [:at], [:informal])[0] || {})[:name]
13
+
14
+ assert_equal "Christi Himmelfahrt", (Holidays.on(Date.civil(2009, 5, 21), [:at], [:informal])[0] || {})[:name]
15
+
16
+ assert_equal "Pfingstmontag", (Holidays.on(Date.civil(2009, 6, 1), [:at], [:informal])[0] || {})[:name]
17
+
18
+ assert_equal "Nationalfeiertag", (Holidays.on(Date.civil(2009, 10, 26), [:at], [:informal])[0] || {})[:name]
19
+
20
+ assert_equal "1. Weihnachtstag", (Holidays.on(Date.civil(2009, 12, 25), [:at], [:informal])[0] || {})[:name]
21
+
22
+ assert_equal "2. Weihnachtstag", (Holidays.on(Date.civil(2009, 12, 26), [:at], [:informal])[0] || {})[:name]
20
23
 
21
- assert_equal [], Holidays.on(Date.civil(2010,5,8), :at), '2010-05-08 is not a holiday in Austria'
24
+ assert_nil (Holidays.on(Date.civil(2010, 5, 8), [:at])[0] || {})[:name]
22
25
 
23
26
  end
24
27
  end
@@ -7,152 +7,183 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
7
7
  class AuDefinitionTests < Test::Unit::TestCase # :nodoc:
8
8
 
9
9
  def test_au
10
- {Date.civil(2007,1,1) => 'New Year\'s Day',
11
- Date.civil(2007,1,26) => 'Australia Day',
12
- Date.civil(2007,4,6) => 'Good Friday',
13
- Date.civil(2007,4,9) => 'Easter Monday',
14
- Date.civil(2007,4,25) => 'ANZAC Day'}.each do |date, name|
15
- assert_equal name, (Holidays.on(date, :au, :informal)[0] || {})[:name]
16
- end
10
+ assert_equal "Labour Day", (Holidays.on(Date.civil(2013, 10, 7), [:au_qld])[0] || {})[:name]
17
11
 
18
- [:au_sa, :au_act, :au_nsw, :au_].each do |r|
19
- assert_equal 'Labour Day', Holidays.on(Date.civil(2007,10,1), r)[0][:name]
20
- end
12
+ assert_equal "Labour Day", (Holidays.on(Date.civil(2012, 5, 7), [:au_qld])[0] || {})[:name]
21
13
 
22
- [:au_sa, :au_act, :au_nsw, :au_vic, :au_tas, :au_qld, :au_nt, :au_].each do |r|
23
- assert_equal 'Queen\'s Birthday', Holidays.on(Date.civil(2007,6,11), r)[0][:name]
24
- end
14
+ assert_equal "Labour Day", (Holidays.on(Date.civil(2015, 10, 5), [:au_qld])[0] || {})[:name]
25
15
 
26
- assert_equal 'Labour Day', Holidays.on(Date.civil(2007,3,5), :au_wa)[0][:name]
27
- assert_equal 'Labour Day', Holidays.on(Date.civil(2007,3,12), :au_vic)[0][:name]
28
- assert_equal 'Labour Day', Holidays.on(Date.civil(2007,5,7), :au_qld)[0][:name]
29
-
30
- assert_equal 'Easter Sunday', Holidays.on(Date.civil(2007,4,8), :au_nsw)[0][:name]
31
-
32
- assert_equal 'May Day', Holidays.on(Date.civil(2007,5,7), :au_nt)[0][:name]
33
-
34
- assert_equal 'Eight Hours Day', Holidays.on(Date.civil(2007,3,12), :au_tas)[0][:name]
35
-
36
- assert_equal 'Labour Day', Holidays.on(Date.civil(2013,10,7), :au_qld)[0][:name]
37
- assert_equal 'Labour Day', Holidays.on(Date.civil(2012,5,7), :au_qld)[0][:name]
38
- assert_equal 'Labour Day', Holidays.on(Date.civil(2015,10,5), :au_qld)[0][:name]
39
- assert_equal 'Labour Day', Holidays.on(Date.civil(2016,5,2), :au_qld)[0][:name]
40
-
41
- assert_equal "Queen's Birthday", Holidays.on(Date.civil(2012,6,11), :au_qld)[0][:name]
42
- assert_equal "Queen's Birthday", Holidays.on(Date.civil(2012,10,1), :au_qld)[0][:name]
43
- assert_equal "Queen's Birthday", Holidays.on(Date.civil(2013,6,10), :au_qld)[0][:name]
44
- assert_equal "Queen's Birthday", Holidays.on(Date.civil(2015,6,8), :au_qld)[0][:name]
45
- assert_equal "Queen's Birthday", Holidays.on(Date.civil(2016,10,3), :au_qld)[0][:name]
46
-
47
- assert_equal "Queen's Birthday", Holidays.on(Date.civil(2014, 9, 29), :au_wa)[0][:name]
48
- assert_equal "Queen's Birthday", Holidays.on(Date.civil(2015, 9, 28), :au_wa)[0][:name]
49
- assert_equal "Queen's Birthday", Holidays.on(Date.civil(2016, 9, 26), :au_wa)[0][:name]
50
-
51
- assert_equal "Family & Community Day", Holidays.on(Date.civil(2014, 9, 29), :au_act)[0][:name]
52
- assert_equal "Family & Community Day", Holidays.on(Date.civil(2015, 9, 28), :au_act)[0][:name]
53
- assert_equal "Family & Community Day", Holidays.on(Date.civil(2016, 9, 26), :au_act)[0][:name]
54
-
55
- assert_equal 'Australia Day', Holidays.on(Date.civil(2014,1,26), :au_qld)[0][:name]
56
- assert_equal 'Australia Day', Holidays.on(Date.civil(2014,1,27), :au_qld, :observed)[0][:name]
57
-
58
- assert_equal 'Cairns Show', Holidays.on(Date.civil(2014,7,18), :au_qld_cairns)[0][:name]
59
- assert_equal 'Cairns Show', Holidays.on(Date.civil(2013,7,19), :au_qld_cairns)[0][:name]
60
-
61
- assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2013, 10, 24), :au_tas_south)[0][:name]
62
- assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2014, 10, 23), :au_tas_south)[0][:name]
63
- assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2015, 10, 22), :au_tas_south)[0][:name]
64
- assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2016, 10, 20), :au_tas_south)[0][:name]
65
-
66
- assert_equal 'Recreation Day', Holidays.on(Date.civil(2013, 11, 4), :au_tas_north)[0][:name]
67
- assert_equal 'Recreation Day', Holidays.on(Date.civil(2014, 11, 3), :au_tas_north)[0][:name]
68
- assert_equal 'Recreation Day', Holidays.on(Date.civil(2015, 11, 2), :au_tas_north)[0][:name]
69
- assert_equal 'Recreation Day', Holidays.on(Date.civil(2016, 11, 7), :au_tas_north)[0][:name]
70
-
71
- assert_nil Date.civil(2014,11,4).holidays(:au_vic)[0]
72
- assert_nil Date.civil(2015,11,3).holidays(:au_vic)[0]
73
-
74
- assert_equal 'Melbourne Cup Day', Holidays.on(Date.civil(2014,11,4), :au_vic_melbourne)[0][:name]
75
- assert_equal 'Melbourne Cup Day', Holidays.on(Date.civil(2015,11,3), :au_vic_melbourne)[0][:name]
76
-
77
- assert_equal 'Friday before the AFL Grand Final', Date.civil(2015,10,2).holidays(:au_vic)[0][:name]
78
- assert_equal 'Friday before the AFL Grand Final', Date.civil(2016,9,30).holidays(:au_vic)[0][:name]
79
- assert_equal 'Friday before the AFL Grand Final', Date.civil(2017,9,29).holidays(:au_vic)[0][:name]
80
-
81
- assert_equal "May Public Holiday", Date.civil(2005, 5, 16).holidays(:au_sa)[0][:name]
82
- assert_equal [], Date.civil(2014, 5, 19).holidays(:au_sa)
83
-
84
- assert_equal [], Date.civil(2005, 3, 14).holidays(:au_sa)
85
- assert_equal "March Public Holiday", Date.civil(2014, 3, 10).holidays(:au_sa)[0][:name]
86
- assert_equal "March Public Holiday", Date.civil(2015, 3, 9).holidays(:au_sa)[0][:name]
87
- assert_equal "March Public Holiday", Date.civil(2016, 3, 14).holidays(:au_sa)[0][:name]
88
- assert_equal "March Public Holiday", Date.civil(2017, 3, 13).holidays(:au_sa)[0][:name]
89
-
90
- assert_equal "ANZAC Day", Date.civil(2015, 4, 25).holidays(:au_qld)[0][:name]
91
- assert_equal "ANZAC Day", Date.civil(2015, 4, 25).holidays(:au_wa)[0][:name]
92
- assert_equal [], Date.civil(2015, 4, 27).holidays(:au_qld, :observed)
93
- assert_equal "ANZAC Day", Date.civil(2015, 4, 27).holidays(:au_wa, :observed)[0][:name]
94
-
95
- # BOXING DAY - QLD observes weekend and monday
96
- assert_equal "Boxing Day", Date.civil(2015, 12, 26).holidays(:au_qld)[0][:name]
97
- assert_equal "Boxing Day", Date.civil(2015, 12, 28).holidays(:au_qld, :observed)[0][:name]
98
-
99
- # BOXING DAY - SA gets monday only. same for TAS and NT.
100
- assert_nil Date.civil(2015, 12, 26).holidays(:au_sa)[0]
101
- assert_equal "Proclamation Day", Date.civil(2015, 12, 28).holidays(:au_sa)[0][:name]
102
- assert_nil Date.civil(2015, 12, 26).holidays(:au_tas)[0]
103
- assert_equal "Boxing Day", Date.civil(2015, 12, 28).holidays(:au_tas)[0][:name]
104
- assert_nil Date.civil(2015, 12, 26).holidays(:au_nt)[0]
105
- assert_equal "Boxing Day", Date.civil(2015, 12, 28).holidays(:au_nt)[0][:name]
106
-
107
- assert_equal 'G20 Day', Holidays.on(Date.civil(2014,11,14), :au_qld_brisbane)[0][:name]
108
- assert_equal [], Holidays.on(Date.civil(2014,11,14), :au_qld)
109
- assert_equal [], Holidays.on(Date.civil(2015,11,14), :au_qld_brisbane)
110
-
111
- assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2012, 2, 13), :au_tas_south)[0][:name]
112
- assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2014, 2, 10), :au_tas_south)[0][:name]
113
- assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2015, 2, 9), :au_tas_south)[0][:name]
114
- assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2016, 2, 8), :au_tas_south)[0][:name]
115
-
116
- # CHRISTMAS DAY - ACT, NSW, QLD, Tas, WA observe on 27th (and 25th) if 25th is a Sunday
117
- assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_qld)[0][:name]
118
- assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_qld, :observed)[0][:name]
119
- assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_nsw)[0][:name]
120
- assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_nsw, :observed)[0][:name]
121
- assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_act)[0][:name]
122
- assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_act, :observed)[0][:name]
123
- assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_tas)[0][:name]
124
- assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_tas, :observed)[0][:name]
125
- assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_wa)[0][:name]
126
- assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_wa, :observed)[0][:name]
127
-
128
- # CHRISTMAS DAY - SA observes on 26th if 25th is a Sunday (Boxing Day goes to 27th)
129
- assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_sa)[0][:name]
130
- assert_equal "Christmas Day", Date.civil(2016, 12, 26).holidays(:au_sa, :observed)[0][:name]
131
- assert_equal "Proclamation Day", Date.civil(2016, 12, 27).holidays(:au_sa)[0][:name]
132
-
133
- # CHRISTMAS DAY - Victoria and NT now observe both 25th and 27th if weekend
134
- assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_vic)[0][:name]
135
- assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_nt)[0][:name]
136
- assert_equal "Boxing Day", Date.civil(2016, 12, 26).holidays(:au_vic)[0][:name]
137
- assert_equal "Boxing Day", Date.civil(2016, 12, 26).holidays(:au_nt)[0][:name]
138
- assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_vic, :observed)[0][:name]
139
- assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_nt, :observed)[0][:name]
140
-
141
- # NEW YEAR'S DAY - observed on both 1st and 2nd of Jan for 2017
142
- regions = [:au, :au_qld, :au_nsw, :au_act, :au_vic, :au_sa, :au_wa, :au_nt]
143
- regions.each do |r|
144
- assert_equal "New Year's Day", Date.civil(2017, 1, 1).holidays(r)[0][:name]
145
- assert_equal "New Year's Day", Date.civil(2017, 1, 2).holidays(r, :observed)[0][:name]
146
- end
16
+ assert_equal "Labour Day", (Holidays.on(Date.civil(2016, 5, 2), [:au_qld])[0] || {})[:name]
17
+
18
+ assert_equal "Queen's Birthday", (Holidays.on(Date.civil(2012, 6, 11), [:au_qld])[0] || {})[:name]
19
+ assert_equal "Queen's Birthday", (Holidays.on(Date.civil(2012, 10, 1), [:au_qld])[0] || {})[:name]
20
+ assert_equal "Queen's Birthday", (Holidays.on(Date.civil(2013, 6, 10), [:au_qld])[0] || {})[:name]
21
+ assert_equal "Queen's Birthday", (Holidays.on(Date.civil(2015, 6, 8), [:au_qld])[0] || {})[:name]
22
+ assert_equal "Queen's Birthday", (Holidays.on(Date.civil(2016, 10, 3), [:au_qld])[0] || {})[:name]
23
+
24
+ assert_equal "Queen's Birthday", (Holidays.on(Date.civil(2014, 9, 29), [:au_wa])[0] || {})[:name]
25
+ assert_equal "Queen's Birthday", (Holidays.on(Date.civil(2015, 9, 28), [:au_wa])[0] || {})[:name]
26
+ assert_equal "Queen's Birthday", (Holidays.on(Date.civil(2016, 9, 26), [:au_wa])[0] || {})[:name]
27
+
28
+ assert_equal "Family & Community Day", (Holidays.on(Date.civil(2014, 9, 29), [:au_act])[0] || {})[:name]
29
+
30
+ assert_equal "Family & Community Day", (Holidays.on(Date.civil(2015, 9, 28), [:au_act])[0] || {})[:name]
31
+
32
+ assert_equal "Family & Community Day", (Holidays.on(Date.civil(2016, 9, 26), [:au_act])[0] || {})[:name]
33
+
34
+ assert_equal "Australia Day", (Holidays.on(Date.civil(2014, 1, 26), [:au_qld])[0] || {})[:name]
35
+
36
+ assert_equal "Australia Day", (Holidays.on(Date.civil(2014, 1, 27), [:au_qld], [:observed])[0] || {})[:name]
37
+
38
+ assert_equal "Cairns Show", (Holidays.on(Date.civil(2014, 7, 18), [:au_qld_cairns])[0] || {})[:name]
39
+
40
+ assert_equal "Cairns Show", (Holidays.on(Date.civil(2013, 7, 19), [:au_qld_cairns])[0] || {})[:name]
41
+
42
+ assert_equal "Royal Hobart Show", (Holidays.on(Date.civil(2013, 10, 24), [:au_tas_south])[0] || {})[:name]
43
+
44
+ assert_equal "Royal Hobart Show", (Holidays.on(Date.civil(2014, 10, 23), [:au_tas_south])[0] || {})[:name]
45
+
46
+ assert_equal "Royal Hobart Show", (Holidays.on(Date.civil(2015, 10, 22), [:au_tas_south])[0] || {})[:name]
47
+
48
+ assert_equal "Royal Hobart Show", (Holidays.on(Date.civil(2016, 10, 20), [:au_tas_south])[0] || {})[:name]
49
+
50
+ assert_equal "Recreation Day", (Holidays.on(Date.civil(2013, 11, 4), [:au_tas_north])[0] || {})[:name]
51
+
52
+ assert_equal "Recreation Day", (Holidays.on(Date.civil(2014, 11, 3), [:au_tas_north])[0] || {})[:name]
53
+
54
+ assert_equal "Recreation Day", (Holidays.on(Date.civil(2015, 11, 2), [:au_tas_north])[0] || {})[:name]
55
+
56
+ assert_equal "Recreation Day", (Holidays.on(Date.civil(2016, 11, 7), [:au_tas_north])[0] || {})[:name]
57
+
58
+ assert_nil (Holidays.on(Date.civil(2015, 12, 26), [:au_tas])[0] || {})[:name]
59
+
60
+ assert_nil (Holidays.on(Date.civil(2015, 11, 14), [:au_qld_brisbane])[0] || {})[:name]
61
+
62
+ assert_nil (Holidays.on(Date.civil(2015, 12, 26), [:au_nt])[0] || {})[:name]
63
+
64
+ assert_equal "Proclamation Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_sa])[0] || {})[:name]
65
+
66
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_nt])[0] || {})[:name]
67
+
68
+ assert_nil (Holidays.on(Date.civil(2014, 11, 4), [:au_vic])[0] || {})[:name]
69
+
70
+ assert_nil (Holidays.on(Date.civil(2015, 11, 3), [:au_vic])[0] || {})[:name]
71
+
72
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_vic])[0] || {})[:name]
73
+
74
+ assert_nil (Holidays.on(Date.civil(2014, 5, 19), [:au_sa])[0] || {})[:name]
75
+
76
+ assert_nil (Holidays.on(Date.civil(2005, 3, 14), [:au_sa])[0] || {})[:name]
77
+
78
+ assert_nil (Holidays.on(Date.civil(2015, 12, 26), [:au_sa])[0] || {})[:name]
79
+
80
+ assert_nil (Holidays.on(Date.civil(2015, 4, 27), [:au_qld], [:observed])[0] || {})[:name]
81
+
82
+ assert_nil (Holidays.on(Date.civil(2014, 11, 14), [:au_qld])[0] || {})[:name]
83
+
84
+ assert_equal "Melbourne Cup Day", (Holidays.on(Date.civil(2014, 11, 4), [:au_vic_melbourne])[0] || {})[:name]
85
+
86
+ assert_equal "Melbourne Cup Day", (Holidays.on(Date.civil(2015, 11, 3), [:au_vic_melbourne])[0] || {})[:name]
87
+
88
+ assert_equal "Friday before the AFL Grand Final", (Holidays.on(Date.civil(2015, 10, 2), [:au_vic])[0] || {})[:name]
89
+
90
+ assert_equal "Friday before the AFL Grand Final", (Holidays.on(Date.civil(2016, 9, 30), [:au_vic])[0] || {})[:name]
91
+
92
+ assert_equal "Friday before the AFL Grand Final", (Holidays.on(Date.civil(2017, 9, 29), [:au_vic])[0] || {})[:name]
93
+
94
+ assert_equal "May Public Holiday", (Holidays.on(Date.civil(2005, 5, 16), [:au_sa])[0] || {})[:name]
95
+
96
+ assert_equal "March Public Holiday", (Holidays.on(Date.civil(2014, 3, 10), [:au_sa])[0] || {})[:name]
97
+
98
+ assert_equal "March Public Holiday", (Holidays.on(Date.civil(2015, 3, 9), [:au_sa])[0] || {})[:name]
99
+
100
+ assert_equal "March Public Holiday", (Holidays.on(Date.civil(2016, 3, 14), [:au_sa])[0] || {})[:name]
101
+
102
+ assert_equal "March Public Holiday", (Holidays.on(Date.civil(2017, 3, 13), [:au_sa])[0] || {})[:name]
103
+
104
+ assert_equal "ANZAC Day", (Holidays.on(Date.civil(2015, 4, 25), [:au_qld, :au_wa])[0] || {})[:name]
105
+
106
+ assert_equal "ANZAC Day", (Holidays.on(Date.civil(2015, 4, 27), [:au_wa], [:observed])[0] || {})[:name]
107
+
108
+ assert_equal "Boxing Day", (Holidays.on(Date.civil(2015, 12, 26), [:au_qld])[0] || {})[:name]
109
+
110
+ assert_equal "Boxing Day", (Holidays.on(Date.civil(2015, 12, 28), [:au_qld], [:observed])[0] || {})[:name]
111
+
112
+ assert_nil (Holidays.on(Date.civil(2015, 12, 26), [:au_sa])[0] || {})[:name]
113
+
114
+ assert_equal "Proclamation Day", (Holidays.on(Date.civil(2015, 12, 28), [:au_sa])[0] || {})[:name]
115
+
116
+ assert_nil (Holidays.on(Date.civil(2015, 12, 26), [:au_tas])[0] || {})[:name]
117
+
118
+ assert_equal "Boxing Day", (Holidays.on(Date.civil(2015, 12, 28), [:au_tas])[0] || {})[:name]
119
+
120
+ assert_nil (Holidays.on(Date.civil(2015, 12, 26), [:au_nt])[0] || {})[:name]
121
+
122
+ assert_equal "Boxing Day", (Holidays.on(Date.civil(2015, 12, 28), [:au_nt])[0] || {})[:name]
123
+
124
+ assert_equal "Royal Hobart Regatta", (Holidays.on(Date.civil(2012, 2, 13), [:au_tas_south])[0] || {})[:name]
125
+
126
+ assert_equal "Royal Hobart Regatta", (Holidays.on(Date.civil(2014, 2, 10), [:au_tas_south])[0] || {})[:name]
127
+
128
+ assert_equal "Royal Hobart Regatta", (Holidays.on(Date.civil(2015, 2, 9), [:au_tas_south])[0] || {})[:name]
129
+
130
+ assert_equal "Royal Hobart Regatta", (Holidays.on(Date.civil(2016, 2, 8), [:au_tas_south])[0] || {})[:name]
131
+
132
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_qld])[0] || {})[:name]
133
+
134
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_qld], [:observed])[0] || {})[:name]
135
+
136
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_nsw])[0] || {})[:name]
137
+
138
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_nsw], [:observed])[0] || {})[:name]
139
+
140
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_act])[0] || {})[:name]
141
+
142
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_act], [:observed])[0] || {})[:name]
143
+
144
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_tas])[0] || {})[:name]
145
+
146
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_tas], [:observed])[0] || {})[:name]
147
+
148
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_wa])[0] || {})[:name]
149
+
150
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_wa], [:observed])[0] || {})[:name]
151
+
152
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_sa])[0] || {})[:name]
153
+
154
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 26), [:au_sa], [:observed])[0] || {})[:name]
155
+
156
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_nsw])[0] || {})[:name]
157
+
158
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_nsw], [:observed])[0] || {})[:name]
159
+
160
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_act])[0] || {})[:name]
161
+
162
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_act], [:observed])[0] || {})[:name]
163
+
164
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_tas])[0] || {})[:name]
165
+
166
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_tas], [:observed])[0] || {})[:name]
167
+
168
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_wa])[0] || {})[:name]
169
+
170
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_wa], [:observed])[0] || {})[:name]
171
+
172
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 25), [:au_sa])[0] || {})[:name]
173
+
174
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 26), [:au_sa], [:observed])[0] || {})[:name]
175
+
176
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_vic], [:observed])[0] || {})[:name]
177
+
178
+ assert_equal "Christmas Day", (Holidays.on(Date.civil(2016, 12, 27), [:au_nt], [:observed])[0] || {})[:name]
179
+
180
+ assert_equal "New Year's Day", (Holidays.on(Date.civil(2017, 1, 1), [:au, :au_qld, :au_nsw, :au_act, :au_vic, :au_sa, :au_wa, :au_nt])[0] || {})[:name]
181
+
182
+ assert_equal "New Year's Day", (Holidays.on(Date.civil(2017, 1, 2), [:au, :au_qld, :au_nsw, :au_act, :au_vic, :au_sa, :au_wa, :au_nt], [:observed])[0] || {})[:name]
147
183
 
148
- # Tasmania is different
149
- #FIXME This commented test is valid but the current code in the ruby repo won't allow it
150
- # to work. We need to discuss potential solutions but in the meantime I'm taking it out.
151
- #assert_equal [], Date.civil(2017,1,1).holidays(:au_tas)
152
- assert_equal "New Year's Day", Date.civil(2017, 1, 2).holidays(:au_tas)[0][:name]
184
+ assert_equal "New Year's Day", (Holidays.on(Date.civil(2017, 1, 2), [:au_tas])[0] || {})[:name]
153
185
 
154
- #QLD now celebrates Easter Sunday
155
- assert_equal "Easter Sunday", Date.civil(2017, 4, 16).holidays(:au_qld)[0][:name]
186
+ assert_equal "Easter Sunday", (Holidays.on(Date.civil(2017, 4, 16), [:au_qld])[0] || {})[:name]
156
187
 
157
188
  end
158
189
  end