holidays 4.2.0 → 8.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (330) hide show
  1. checksums.yaml +5 -5
  2. data/.gitmodules +3 -0
  3. data/CHANGELOG.md +195 -0
  4. data/Makefile +45 -0
  5. data/README.md +253 -77
  6. data/Rakefile +10 -11
  7. data/bin/console +0 -0
  8. data/bin/setup +1 -0
  9. data/doc/CONTRIBUTING.md +72 -0
  10. data/doc/MAINTAINERS.md +81 -0
  11. data/{REFERENCES → doc/REFERENCES} +0 -0
  12. data/holidays.gemspec +9 -9
  13. data/lib/generated_definitions/MANIFEST +26 -4
  14. data/lib/generated_definitions/REGIONS.rb +3 -1
  15. data/lib/generated_definitions/ar.rb +4 -10
  16. data/lib/generated_definitions/at.rb +3 -9
  17. data/lib/generated_definitions/au.rb +32 -25
  18. data/lib/generated_definitions/be_fr.rb +2 -8
  19. data/lib/generated_definitions/be_nl.rb +2 -8
  20. data/lib/generated_definitions/bg.rb +2 -8
  21. data/lib/generated_definitions/br.rb +2 -8
  22. data/lib/generated_definitions/ca.rb +33 -32
  23. data/lib/generated_definitions/ch.rb +17 -11
  24. data/lib/generated_definitions/cl.rb +38 -12
  25. data/lib/generated_definitions/co.rb +121 -0
  26. data/lib/generated_definitions/cr.rb +2 -8
  27. data/lib/generated_definitions/cz.rb +2 -8
  28. data/lib/generated_definitions/de.rb +11 -14
  29. data/lib/generated_definitions/dk.rb +2 -8
  30. data/lib/generated_definitions/{ecb_target.rb → ecbtarget.rb} +10 -16
  31. data/lib/generated_definitions/ee.rb +36 -0
  32. data/lib/generated_definitions/el.rb +2 -8
  33. data/lib/generated_definitions/es.rb +8 -11
  34. data/lib/generated_definitions/europe.rb +121 -51
  35. data/lib/generated_definitions/federalreserve.rb +34 -0
  36. data/lib/generated_definitions/{federal_reserve.rb → federalreservebanks.rb} +14 -20
  37. data/lib/generated_definitions/fedex.rb +3 -9
  38. data/lib/generated_definitions/fi.rb +2 -8
  39. data/lib/generated_definitions/fr.rb +6 -10
  40. data/lib/generated_definitions/gb.rb +12 -16
  41. data/lib/generated_definitions/ge.rb +41 -0
  42. data/lib/generated_definitions/hk.rb +106 -0
  43. data/lib/generated_definitions/hr.rb +10 -14
  44. data/lib/generated_definitions/hu.rb +4 -9
  45. data/lib/generated_definitions/ie.rb +3 -17
  46. data/lib/generated_definitions/is.rb +3 -9
  47. data/lib/generated_definitions/it.rb +16 -13
  48. data/lib/generated_definitions/jp.rb +47 -36
  49. data/lib/generated_definitions/kr.rb +40 -0
  50. data/lib/generated_definitions/kz.rb +38 -0
  51. data/lib/generated_definitions/li.rb +2 -8
  52. data/lib/generated_definitions/lt.rb +2 -8
  53. data/lib/generated_definitions/lu.rb +35 -0
  54. data/lib/generated_definitions/lv.rb +52 -0
  55. data/lib/generated_definitions/ma.rb +2 -8
  56. data/lib/generated_definitions/mt_en.rb +38 -0
  57. data/lib/generated_definitions/mt_mt.rb +38 -0
  58. data/lib/generated_definitions/mx.rb +6 -12
  59. data/lib/generated_definitions/my.rb +30 -0
  60. data/lib/generated_definitions/nerc.rb +2 -8
  61. data/lib/generated_definitions/ng.rb +33 -0
  62. data/lib/generated_definitions/nl.rb +2 -8
  63. data/lib/generated_definitions/no.rb +2 -8
  64. data/lib/generated_definitions/northamerica.rb +223 -0
  65. data/lib/generated_definitions/nyse.rb +3 -9
  66. data/lib/generated_definitions/nz.rb +2 -9
  67. data/lib/generated_definitions/pe.rb +43 -0
  68. data/lib/generated_definitions/ph.rb +4 -10
  69. data/lib/generated_definitions/pl.rb +2 -8
  70. data/lib/generated_definitions/pt.rb +12 -12
  71. data/lib/generated_definitions/ro.rb +6 -9
  72. data/lib/generated_definitions/rs_cyrl.rb +39 -0
  73. data/lib/generated_definitions/rs_la.rb +39 -0
  74. data/lib/generated_definitions/ru.rb +37 -0
  75. data/lib/generated_definitions/scandinavia.rb +3 -9
  76. data/lib/generated_definitions/se.rb +2 -8
  77. data/lib/generated_definitions/sg.rb +2 -8
  78. data/lib/generated_definitions/si.rb +2 -8
  79. data/lib/generated_definitions/sk.rb +2 -8
  80. data/lib/generated_definitions/southamerica.rb +228 -0
  81. data/lib/generated_definitions/th.rb +36 -0
  82. data/lib/generated_definitions/tn.rb +32 -0
  83. data/lib/generated_definitions/tr.rb +64 -0
  84. data/lib/generated_definitions/ua.rb +37 -0
  85. data/lib/generated_definitions/{united_nations.rb → unitednations.rb} +61 -67
  86. data/lib/generated_definitions/ups.rb +3 -9
  87. data/lib/generated_definitions/us.rb +113 -23
  88. data/lib/generated_definitions/ve.rb +2 -8
  89. data/lib/generated_definitions/vi.rb +6 -11
  90. data/lib/generated_definitions/za.rb +2 -8
  91. data/lib/holidays/core_extensions/date.rb +21 -3
  92. data/lib/holidays/core_extensions/time.rb +23 -0
  93. data/lib/holidays/date_calculator/day_of_month.rb +3 -3
  94. data/lib/holidays/date_calculator/lunar_date.rb +371 -0
  95. data/lib/holidays/date_calculator/weekend_modifier.rb +0 -7
  96. data/lib/holidays/definition/context/function_processor.rb +91 -0
  97. data/lib/holidays/definition/context/generator.rb +37 -96
  98. data/lib/holidays/definition/context/load.rb +29 -0
  99. data/lib/holidays/definition/context/merger.rb +0 -4
  100. data/lib/holidays/definition/decorator/test.rb +37 -0
  101. data/lib/holidays/definition/entity/test.rb +11 -0
  102. data/lib/holidays/definition/generator/module.rb +54 -0
  103. data/lib/holidays/definition/generator/regions.rb +55 -0
  104. data/lib/holidays/definition/generator/test.rb +51 -0
  105. data/lib/holidays/definition/parser/custom_method.rb +3 -5
  106. data/lib/holidays/definition/parser/test.rb +86 -0
  107. data/lib/holidays/definition/repository/cache.rb +23 -9
  108. data/lib/holidays/definition/repository/holidays_by_month.rb +10 -2
  109. data/lib/holidays/definition/repository/proc_result_cache.rb +1 -1
  110. data/lib/holidays/definition/repository/regions.rb +23 -13
  111. data/lib/holidays/definition/validator/custom_method.rb +1 -1
  112. data/lib/holidays/definition/validator/region.rb +2 -11
  113. data/lib/holidays/definition/validator/test.rb +71 -0
  114. data/lib/holidays/errors.rb +5 -0
  115. data/lib/holidays/factory/date_calculator.rb +42 -0
  116. data/lib/holidays/factory/definition.rb +143 -0
  117. data/lib/holidays/factory/finder.rb +70 -0
  118. data/lib/holidays/finder/context/between.rb +45 -0
  119. data/lib/holidays/{use_case → finder}/context/dates_driver_builder.rb +11 -15
  120. data/lib/holidays/finder/context/next_holiday.rb +57 -0
  121. data/lib/holidays/finder/context/parse_options.rb +104 -0
  122. data/lib/holidays/finder/context/search.rb +110 -0
  123. data/lib/holidays/finder/context/year_holiday.rb +57 -0
  124. data/lib/holidays/finder/rules/in_region.rb +31 -0
  125. data/lib/holidays/finder/rules/year_range.rb +58 -0
  126. data/lib/holidays/load_all_definitions.rb +16 -17
  127. data/lib/holidays/version.rb +1 -1
  128. data/lib/holidays.rb +50 -125
  129. data/test/coverage_report.rb +26 -0
  130. data/test/data/test_custom_informal_holidays_defs.yaml +11 -0
  131. data/test/data/test_custom_year_range_holiday_defs.yaml +13 -10
  132. data/test/data/test_invalid_region.rb +15 -0
  133. data/test/data/test_multiple_custom_holiday_defs.yaml +7 -4
  134. data/test/data/test_multiple_regions_with_conflicts_region_1.yaml +38 -0
  135. data/test/data/test_multiple_regions_with_conflicts_region_2.yaml +38 -0
  136. data/test/data/test_region.rb +15 -0
  137. data/test/data/test_single_custom_holiday_defs.yaml +7 -4
  138. data/test/data/test_single_custom_holiday_with_custom_procs.yaml +11 -7
  139. data/test/defs/test_defs_ar.rb +41 -19
  140. data/test/defs/test_defs_at.rb +18 -11
  141. data/test/defs/test_defs_au.rb +185 -126
  142. data/test/defs/test_defs_be_fr.rb +33 -14
  143. data/test/defs/test_defs_be_nl.rb +33 -14
  144. data/test/defs/test_defs_bg.rb +29 -17
  145. data/test/defs/test_defs_br.rb +33 -19
  146. data/test/defs/test_defs_ca.rb +246 -136
  147. data/test/defs/test_defs_ch.rb +35 -23
  148. data/test/defs/test_defs_cl.rb +57 -27
  149. data/test/defs/test_defs_co.rb +113 -0
  150. data/test/defs/test_defs_cr.rb +17 -11
  151. data/test/defs/test_defs_cz.rb +25 -15
  152. data/test/defs/test_defs_de.rb +60 -59
  153. data/test/defs/test_defs_dk.rb +31 -19
  154. data/test/defs/test_defs_ecbtarget.rb +27 -0
  155. data/test/defs/test_defs_ee.rb +41 -0
  156. data/test/defs/test_defs_el.rb +29 -17
  157. data/test/defs/test_defs_es.rb +116 -52
  158. data/test/defs/test_defs_europe.rb +1382 -701
  159. data/test/defs/test_defs_federalreserve.rb +113 -0
  160. data/test/defs/test_defs_federalreservebanks.rb +247 -0
  161. data/test/defs/test_defs_fedex.rb +19 -12
  162. data/test/defs/test_defs_fi.rb +47 -27
  163. data/test/defs/test_defs_fr.rb +31 -18
  164. data/test/defs/test_defs_gb.rb +120 -51
  165. data/test/defs/test_defs_ge.rb +53 -0
  166. data/test/defs/test_defs_hk.rb +59 -0
  167. data/test/defs/test_defs_hr.rb +32 -18
  168. data/test/defs/test_defs_hu.rb +34 -16
  169. data/test/defs/test_defs_ie.rb +41 -25
  170. data/test/defs/test_defs_is.rb +39 -22
  171. data/test/defs/test_defs_it.rb +43 -14
  172. data/test/defs/test_defs_jp.rb +141 -55
  173. data/test/defs/test_defs_kr.rb +37 -0
  174. data/test/defs/test_defs_kz.rb +39 -0
  175. data/test/defs/test_defs_li.rb +20 -20
  176. data/test/defs/test_defs_lt.rb +51 -30
  177. data/test/defs/test_defs_lu.rb +35 -0
  178. data/test/defs/test_defs_lv.rb +90 -0
  179. data/test/defs/test_defs_ma.rb +17 -11
  180. data/test/defs/test_defs_mt_en.rb +41 -0
  181. data/test/defs/test_defs_mt_mt.rb +41 -0
  182. data/test/defs/test_defs_mx.rb +34 -23
  183. data/test/defs/test_defs_my.rb +23 -0
  184. data/test/defs/test_defs_nerc.rb +17 -11
  185. data/test/defs/test_defs_ng.rb +29 -0
  186. data/test/defs/test_defs_nl.rb +21 -13
  187. data/test/defs/test_defs_no.rb +31 -18
  188. data/test/defs/test_defs_northamerica.rb +644 -0
  189. data/test/defs/test_defs_nyse.rb +27 -11
  190. data/test/defs/test_defs_nz.rb +47 -28
  191. data/test/defs/test_defs_pe.rb +47 -0
  192. data/test/defs/test_defs_ph.rb +17 -13
  193. data/test/defs/test_defs_pl.rb +200 -119
  194. data/test/defs/test_defs_pt.rb +35 -15
  195. data/test/defs/test_defs_ro.rb +53 -24
  196. data/test/defs/test_defs_rs_cyrl.rb +46 -0
  197. data/test/defs/test_defs_rs_la.rb +46 -0
  198. data/test/defs/test_defs_ru.rb +34 -0
  199. data/test/defs/test_defs_scandinavia.rb +193 -116
  200. data/test/defs/test_defs_se.rb +47 -28
  201. data/test/defs/test_defs_sg.rb +13 -9
  202. data/test/defs/test_defs_si.rb +93 -24
  203. data/test/defs/test_defs_sk.rb +29 -17
  204. data/test/defs/test_defs_southamerica.rb +307 -0
  205. data/test/defs/test_defs_th.rb +33 -0
  206. data/test/defs/test_defs_tn.rb +27 -0
  207. data/test/defs/test_defs_tr.rb +60 -0
  208. data/test/defs/test_defs_ua.rb +41 -0
  209. data/test/defs/{test_defs_united_nations.rb → test_defs_unitednations.rb} +3 -4
  210. data/test/defs/test_defs_ups.rb +19 -12
  211. data/test/defs/test_defs_us.rb +370 -30
  212. data/test/defs/test_defs_ve.rb +23 -16
  213. data/test/defs/test_defs_vi.rb +10 -6
  214. data/test/defs/test_defs_za.rb +23 -14
  215. data/test/holidays/core_extensions/test_date.rb +3 -2
  216. data/test/holidays/core_extensions/test_date_time.rb +60 -0
  217. data/test/holidays/date_calculator/test_lunar_date.rb +89 -0
  218. data/test/holidays/definition/context/test_function_processor.rb +199 -0
  219. data/test/holidays/definition/context/test_generator.rb +66 -35
  220. data/test/holidays/definition/context/test_load.rb +37 -0
  221. data/test/holidays/definition/decorator/test_test.rb +123 -0
  222. data/test/holidays/definition/generator/test_module.rb +268 -0
  223. data/test/holidays/definition/generator/test_regions.rb +97 -0
  224. data/test/holidays/definition/generator/test_test.rb +113 -0
  225. data/test/holidays/definition/parser/test_custom_method.rb +6 -6
  226. data/test/holidays/definition/parser/test_test.rb +142 -0
  227. data/test/holidays/definition/repository/test_cache.rb +47 -6
  228. data/test/holidays/definition/repository/test_holidays_by_month.rb +121 -1
  229. data/test/holidays/definition/repository/test_proc_result_cache.rb +8 -1
  230. data/test/holidays/definition/repository/test_regions.rb +31 -13
  231. data/test/holidays/definition/validator/test_custom_method.rb +5 -0
  232. data/test/holidays/definition/validator/test_region.rb +16 -12
  233. data/test/holidays/definition/validator/test_test.rb +60 -0
  234. data/test/holidays/finder/context/test_between.rb +172 -0
  235. data/test/holidays/{use_case → finder}/context/test_dates_driver_builder.rb +2 -2
  236. data/test/holidays/finder/context/test_next_holiday.rb +156 -0
  237. data/test/holidays/finder/context/test_parse_options.rb +141 -0
  238. data/test/holidays/finder/context/test_search.rb +232 -0
  239. data/test/holidays/finder/context/test_year_holiday.rb +202 -0
  240. data/test/holidays/finder/rules/test_in_region.rb +42 -0
  241. data/test/holidays/finder/rules/test_year_range.rb +166 -0
  242. data/test/integration/README.md +9 -0
  243. data/test/{test_all_regions.rb → integration/test_all_regions.rb} +18 -4
  244. data/test/integration/test_any_holidays_during_work_week.rb +90 -0
  245. data/test/integration/test_available_regions.rb +23 -0
  246. data/test/{test_custom_holidays.rb → integration/test_custom_holidays.rb} +6 -6
  247. data/test/integration/test_custom_informal_holidays.rb +15 -0
  248. data/test/{test_custom_year_range_holidays.rb → integration/test_custom_year_range_holidays.rb} +1 -9
  249. data/test/{test_holidays.rb → integration/test_holidays.rb} +100 -69
  250. data/test/{test_holidays_between.rb → integration/test_holidays_between.rb} +19 -17
  251. data/test/integration/test_multiple_regions.rb +71 -0
  252. data/test/integration/test_multiple_regions_with_conflict.rb +29 -0
  253. data/test/integration/test_nonstandard_regions.rb +25 -0
  254. data/test/test_helper.rb +7 -3
  255. metadata +204 -132
  256. data/CONTRIBUTING.md +0 -41
  257. data/benchmark.rb +0 -8
  258. data/definitions/README.md +0 -353
  259. data/definitions/ar.yaml +0 -93
  260. data/definitions/at.yaml +0 -72
  261. data/definitions/au.yaml +0 -375
  262. data/definitions/be_fr.yaml +0 -69
  263. data/definitions/be_nl.yaml +0 -69
  264. data/definitions/bg.yaml +0 -127
  265. data/definitions/br.yaml +0 -77
  266. data/definitions/ca.yaml +0 -302
  267. data/definitions/ch.yaml +0 -193
  268. data/definitions/cl.yaml +0 -94
  269. data/definitions/cr.yaml +0 -65
  270. data/definitions/cz.yaml +0 -73
  271. data/definitions/de.yaml +0 -209
  272. data/definitions/dk.yaml +0 -130
  273. data/definitions/ecb_target.yaml +0 -44
  274. data/definitions/el.yaml +0 -84
  275. data/definitions/es.yaml +0 -203
  276. data/definitions/federal_reserve.yaml +0 -114
  277. data/definitions/fedex.yaml +0 -62
  278. data/definitions/fi.yaml +0 -115
  279. data/definitions/fr.yaml +0 -79
  280. data/definitions/gb.yaml +0 -151
  281. data/definitions/hr.yaml +0 -79
  282. data/definitions/hu.yaml +0 -63
  283. data/definitions/ie.yaml +0 -89
  284. data/definitions/index.yaml +0 -57
  285. data/definitions/is.yaml +0 -146
  286. data/definitions/it.yaml +0 -67
  287. data/definitions/jp.yaml +0 -316
  288. data/definitions/li.yaml +0 -107
  289. data/definitions/lt.yaml +0 -89
  290. data/definitions/ma.yaml +0 -52
  291. data/definitions/mx.yaml +0 -106
  292. data/definitions/nerc.yaml +0 -51
  293. data/definitions/nl.yaml +0 -73
  294. data/definitions/no.yaml +0 -90
  295. data/definitions/north_america_informal.yaml +0 -61
  296. data/definitions/nyse.yaml +0 -64
  297. data/definitions/nz.yaml +0 -163
  298. data/definitions/ph.yaml +0 -94
  299. data/definitions/pl.yaml +0 -320
  300. data/definitions/pt.yaml +0 -69
  301. data/definitions/ro.yaml +0 -78
  302. data/definitions/se.yaml +0 -120
  303. data/definitions/sg.yaml +0 -56
  304. data/definitions/si.yaml +0 -86
  305. data/definitions/sk.yaml +0 -80
  306. data/definitions/united_nations.yaml +0 -189
  307. data/definitions/ups.yaml +0 -62
  308. data/definitions/us.yaml +0 -103
  309. data/definitions/ve.yaml +0 -74
  310. data/definitions/vi.yaml +0 -29
  311. data/definitions/za.yaml +0 -80
  312. data/lib/generated_definitions/north_america.rb +0 -126
  313. data/lib/holidays/date_calculator_factory.rb +0 -35
  314. data/lib/holidays/definition_factory.rb +0 -86
  315. data/lib/holidays/option/context/parse_options.rb +0 -106
  316. data/lib/holidays/option_factory.rb +0 -15
  317. data/lib/holidays/use_case/context/between.rb +0 -45
  318. data/lib/holidays/use_case/context/context_common.rb +0 -123
  319. data/lib/holidays/use_case/context/next_holiday.rb +0 -54
  320. data/lib/holidays/use_case_factory.rb +0 -31
  321. data/test/defs/test_defs_ecb_target.rb +0 -23
  322. data/test/defs/test_defs_federal_reserve.rb +0 -69
  323. data/test/defs/test_defs_north_america.rb +0 -195
  324. data/test/holidays/option/context/test_parse_options.rb +0 -74
  325. data/test/holidays/test_date_calculator_factory.rb +0 -27
  326. data/test/holidays/test_definition_factory.rb +0 -49
  327. data/test/holidays/test_option_factory.rb +0 -9
  328. data/test/holidays/test_use_case_factory.rb +0 -13
  329. data/test/holidays/use_case/context/test_between.rb +0 -77
  330. data/test/test_multiple_regions.rb +0 -24
@@ -1,69 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
3
-
4
- # This file is generated by the Ruby Holiday gem.
5
- #
6
- # Definitions loaded: definitions/federal_reserve.yaml
7
- class Federal_reserveDefinitionTests < Test::Unit::TestCase # :nodoc:
8
-
9
- def test_federal_reserve
10
- {Date.civil(2012,1,2) => "New Year's Day",
11
- Date.civil(2012,1,16) => "Birthday of Martin Luther King, Jr",
12
- Date.civil(2012,2,20) => "Washington's Birthday",
13
- Date.civil(2012,5,28) => "Memorial Day",
14
- Date.civil(2012,7,4) => "Independence Day",
15
- Date.civil(2012,9,3) => "Labor Day",
16
- Date.civil(2012,10,8) => "Columbus Day",
17
- Date.civil(2012,11,12) => "Veterans Day",
18
- Date.civil(2012,11,22) => "Thanksgiving Day",
19
- Date.civil(2012,12,25) => "Christmas Day",
20
-
21
- Date.civil(2013,1,1) => "New Year's Day",
22
- Date.civil(2013,1,21) => "Birthday of Martin Luther King, Jr",
23
- Date.civil(2013,2,18) => "Washington's Birthday",
24
- Date.civil(2013,5,27) => "Memorial Day",
25
- Date.civil(2013,7,4) => "Independence Day",
26
- Date.civil(2013,9,2) => "Labor Day",
27
- Date.civil(2013,10,14) => "Columbus Day",
28
- Date.civil(2013,11,11) => "Veterans Day",
29
- Date.civil(2013,11,28) => "Thanksgiving Day",
30
- Date.civil(2013,12,25) => "Christmas Day",
31
-
32
- Date.civil(2014,1,1) => "New Year's Day",
33
- Date.civil(2014,1,20) => "Birthday of Martin Luther King, Jr",
34
- Date.civil(2014,2,17) => "Washington's Birthday",
35
- Date.civil(2014,5,26) => "Memorial Day",
36
- Date.civil(2014,7,4) => "Independence Day",
37
- Date.civil(2014,9,1) => "Labor Day",
38
- Date.civil(2014,10,13) => "Columbus Day",
39
- Date.civil(2014,11,11) => "Veterans Day",
40
- Date.civil(2014,11,27) => "Thanksgiving Day",
41
- Date.civil(2014,12,25) => "Christmas Day",
42
-
43
- Date.civil(2015,1,1) => "New Year's Day",
44
- Date.civil(2015,1,19) => "Birthday of Martin Luther King, Jr",
45
- Date.civil(2015,2,16) => "Washington's Birthday",
46
- Date.civil(2015,5,25) => "Memorial Day",
47
- Date.civil(2015,7,4) => "Independence Day",
48
- Date.civil(2015,9,7) => "Labor Day",
49
- Date.civil(2015,10,12) => "Columbus Day",
50
- Date.civil(2015,11,11) => "Veterans Day",
51
- Date.civil(2015,11,26) => "Thanksgiving Day",
52
- Date.civil(2015,12,25) => "Christmas Day",
53
-
54
- Date.civil(2016,1,1) => "New Year's Day",
55
- Date.civil(2016,1,18) => "Birthday of Martin Luther King, Jr",
56
- Date.civil(2016,2,15) => "Washington's Birthday",
57
- Date.civil(2016,5,30) => "Memorial Day",
58
- Date.civil(2016,7,4) => "Independence Day",
59
- Date.civil(2016,9,5) => "Labor Day",
60
- Date.civil(2016,10,10) => "Columbus Day",
61
- Date.civil(2016,11,11) => "Veterans Day",
62
- Date.civil(2016,11,24) => "Thanksgiving Day",
63
- Date.civil(2016,12,26) => "Christmas Day",
64
- }.each do |date, name|
65
- assert_equal name, (Holidays.on(date, :federal_reserve, :observed)[0] || {})[:name]
66
- end
67
-
68
- end
69
- end
@@ -1,195 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
3
-
4
- # This file is generated by the Ruby Holiday gem.
5
- #
6
- # Definitions loaded: definitions/ca.yaml, definitions/mx.yaml, definitions/us.yaml, definitions/north_america_informal.yaml
7
- class North_americaDefinitionTests < Test::Unit::TestCase # :nodoc:
8
-
9
- def test_north_america
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,5,19) => 'Victoria Day',
15
- Date.civil(2008,7,1) => 'Canada Day',
16
- Date.civil(2008,9,1) => 'Labour Day',
17
- Date.civil(2008,10,13) => 'Thanksgiving',
18
- Date.civil(2008,11,11) => 'Remembrance Day',
19
- Date.civil(2008,12,25) => 'Christmas Day',
20
- Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
21
- assert_equal name, (Holidays.on(date, :ca, :informal)[0] || {})[:name]
22
- end
23
-
24
- # Family Day in Alberta - Should only be active on 1990 or later
25
- [
26
- Date.civil(1990,2,19),
27
- Date.civil(2013,2,18),
28
- Date.civil(2014,2,17),
29
- Date.civil(2044,2,15),
30
- ].each do |date|
31
- assert_equal 'Family Day', Holidays.on(date, :ca_ab)[0][:name]
32
- end
33
-
34
- # Family Day in Alberta - should not be active before 1990
35
- [
36
- Date.civil(1970,2,16),
37
- Date.civil(1988,2,15),
38
- Date.civil(1989,2,20),
39
- ].each do |date|
40
- assert_equal [], Holidays.on(date, :ca_ab)
41
- end
42
-
43
- # Family Day in Saskatchewan - Should only be active on 2007 or later
44
- [
45
- Date.civil(2007,2,19),
46
- Date.civil(2013,2,18),
47
- Date.civil(2014,2,17),
48
- Date.civil(2044,2,15),
49
- ].each do |date|
50
- assert_equal 'Family Day', Holidays.on(date, :ca_sk)[0][:name]
51
- end
52
-
53
- # Family Day in Saskatchewan - should not be active before 2007
54
- [
55
- Date.civil(1970,2,16),
56
- Date.civil(1988,2,15),
57
- Date.civil(1989,2,20),
58
- Date.civil(2006,2,20),
59
- ].each do |date|
60
- assert_equal [], Holidays.on(date, :ca_sk)
61
- end
62
-
63
- # Family Day in Ontario - Should only be active on 2008 or later
64
- [
65
- Date.civil(2008,2,18),
66
- Date.civil(2013,2,18),
67
- Date.civil(2014,2,17),
68
- Date.civil(2044,2,15),
69
- ].each do |date|
70
- assert_equal 'Family Day', Holidays.on(date, :ca_on)[0][:name]
71
- end
72
-
73
- # Family Day in Ontario - should not be active before 2008
74
- [
75
- Date.civil(1970,2,16),
76
- Date.civil(1988,2,15),
77
- Date.civil(1989,2,20),
78
- Date.civil(2006,2,20),
79
- Date.civil(2007,2,19),
80
- ].each do |date|
81
- assert_equal [], Holidays.on(date, :ca_on)
82
- end
83
-
84
- # Family Day in BC - Should only be active on 2013 or later
85
- [
86
- Date.civil(2013,2,11),
87
- Date.civil(2014,2,10),
88
- Date.civil(2044,2,8),
89
- ].each do |date|
90
- assert_equal 'Family Day', Holidays.on(date, :ca_bc)[0][:name]
91
- end
92
-
93
- # Family Day in BC - should not be active before 2013
94
- [
95
- Date.civil(2000,2,14),
96
- Date.civil(2011,2,14),
97
- Date.civil(2012,2,13),
98
- ].each do |date|
99
- assert_equal [], Holidays.on(date, :ca_bc)
100
- end
101
-
102
- # Nova Scotia Heritage Day - should only be active on 2015 and later
103
- [
104
- Date.civil(2015,2,16),
105
- Date.civil(2016,2,15),
106
- Date.civil(2017,2,20),
107
- Date.civil(2044,2,15),
108
- ].each do |date|
109
- assert_equal 'Nova Scotia Heritage Day', Holidays.on(date, :ca_ns)[0][:name]
110
- end
111
-
112
- # Nova Scotia Heritage Day - should not be active before 2015
113
- [
114
- Date.civil(2000,2,21),
115
- Date.civil(2012,2,20),
116
- Date.civil(2013,2,18),
117
- Date.civil(2014,2,17),
118
- ].each do |date|
119
- assert_equal [], Holidays.on(date, :ca_ns)
120
- end
121
-
122
- # Islander Day in PE
123
- [ Date.civil(2013,2,18), Date.civil(2014,2,17) ].each do |date|
124
- assert_equal 'Islander Day', Holidays.on(date, :ca_pe)[0][:name]
125
- end
126
-
127
- # Victoria Day
128
- [Date.civil(2004,5,24), Date.civil(2005,5,23), Date.civil(2006,5,22),
129
- Date.civil(2007,5,21), Date.civil(2008,5,19)].each do |date|
130
- assert_equal 'Victoria Day', Holidays.on(date, :ca)[0][:name]
131
- end
132
-
133
- # First Monday in August
134
- [Date.civil(2013,8,5), Date.civil(2014,8,4), Date.civil(2015,8,3)].each do |date|
135
- { :ca_bc => 'BC Day',
136
- :ca_sk => 'Saskatchewan Day',
137
- :ca_ab => 'Heritage Day',
138
- :ca_ns => 'Natal Day',
139
- :ca_on => 'Civic Holiday',
140
- :ca_nt => 'Civic Holiday',
141
- :ca_nu => 'Civic Holiday',
142
- :ca_pe => 'Civic Holiday',
143
- :ca_nb => 'New Brunswick Day' }.each do |region, name|
144
- assert_equal name, Holidays.on(date, region)[0][:name]
145
- end
146
- end
147
-
148
-
149
- {Date.civil(2007,1,1) => 'Año nuevo',
150
- Date.civil(2007,2,5) => 'Día de la Constitución',
151
- Date.civil(2007,5,1) => 'Día del Trabajo',
152
- Date.civil(2007,5,5) => 'Cinco de Mayo',
153
- Date.civil(2007,9,16) => 'Día de la Independencia',
154
- Date.civil(2007,11,1) => 'Todos los Santos',
155
- Date.civil(2007,11,2) => 'Los Fieles Difuntos',
156
- Date.civil(2007,11,19) => 'Día de la Revolución',
157
- Date.civil(2007,12,25) => 'Navidad'}.each do |date, name|
158
- assert_equal name, (Holidays.on(date, :mx, :informal)[0] || {})[:name]
159
- end
160
-
161
-
162
- {Date.civil(2008,1,1) => 'New Year\'s Day',
163
- Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
164
- Date.civil(2008,2,18) => 'Presidents\' Day',
165
- Date.civil(2008,5,26) => 'Memorial Day',
166
- Date.civil(2008,7,4) => 'Independence Day',
167
- Date.civil(2008,9,1) => 'Labor Day',
168
- Date.civil(2008,10,13) => 'Columbus Day',
169
- Date.civil(2008,11,11) => 'Veterans Day',
170
- Date.civil(2008,11,27) => 'Thanksgiving',
171
- Date.civil(2013,11,28) => 'Thanksgiving',
172
- Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
173
- assert_equal name, (Holidays.on(date, :us)[0] || {})[:name]
174
- end
175
- {Date.civil(2008, 3, 31) => 'Cesar Chavez Day',
176
- Date.civil(2008, 11, 28) => 'Day after Thanksgiving',
177
- Date.civil(2013, 11, 29) => 'Day after Thanksgiving'}.each do |date, name|
178
- assert_equal name, (Holidays.on(date, :us, :us_ca)[0] || {})[:name]
179
- end
180
-
181
-
182
- {Date.civil(2013,2,2) => 'Groundhog Day',
183
- Date.civil(2013,2,14) => 'Valentine\'s Day',
184
- Date.civil(2013,3,17) => 'St. Patrick\'s Day',
185
- Date.civil(2013,4,1) => 'April Fool\'s Day',
186
- Date.civil(2013,4,22) => 'Earth Day',
187
- Date.civil(2013,5,12) => 'Mother\'s Day',
188
- Date.civil(2013,5,18) => 'Armed Forces Day',
189
- Date.civil(2013,6,16) => 'Father\'s Day',
190
- Date.civil(2013,10,31) => 'Halloween'}.each do |date, name|
191
- assert_equal name, (Holidays.on(date, :us, :informal)[0] || {})[:name]
192
- end
193
-
194
- end
195
- end
@@ -1,74 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../../../test_helper'
2
-
3
- require 'holidays/option/context/parse_options'
4
-
5
- #TODO This set of tests need love. Since the class itself requires actual
6
- # definition files we have real defs in here, meaning that these tests
7
- # could break if a definition is removed/changed.
8
- # Also, there are no actual tests that the files are actually required.
9
- # We need a mechanism to load things from the defs and then BOOM. We can test
10
- # that this mechanism is called.
11
- class ParseOptionsTests < Test::Unit::TestCase
12
- def setup
13
- @regions_repo = mock()
14
-
15
- @region_validator = mock()
16
- @region_validator.stubs(:valid?).returns(true)
17
-
18
- # As mentioned above, this set of tests is NOT isolated. We need
19
- # the real merger code here.
20
- @definition_merger = Holidays::DefinitionFactory.merger
21
-
22
- @subject = Holidays::Option::Context::ParseOptions.new(
23
- @regions_repo,
24
- @region_validator,
25
- @definition_merger,
26
- )
27
- end
28
-
29
- def test_returns_observed_true_if_options_contains_observed_flag
30
- @regions_repo.expects(:exists?).returns(false)
31
- regions, observed, informal = @subject.call([:ca, :observed])
32
- assert_equal(true, observed)
33
- end
34
-
35
- def test_returns_observed_false_if_options_contains_observed_flag
36
- @regions_repo.expects(:exists?).returns(false)
37
- regions, observed, informal = @subject.call([:ca])
38
- assert_equal(false, observed)
39
- end
40
-
41
- def test_returns_informal_true_if_options_contains_informal_flag
42
- @regions_repo.expects(:exists?).returns(false)
43
- regions, observed, informal = @subject.call([:ca, :informal])
44
- assert_equal(true, informal)
45
- end
46
-
47
- def test_returns_informal_false_if_options_contains_informal_flag
48
- @regions_repo.expects(:exists?).returns(false)
49
- regions, observed, informal = @subject.call([:ca])
50
- assert_equal(false, informal)
51
- end
52
-
53
- def test_returns_any_if_no_regions_are_provided
54
- regions, observed, informal = @subject.call(:informal)
55
- assert_equal([:any], regions)
56
- end
57
-
58
- def test_wildcard_regions_are_removed_if_found
59
- @regions_repo.expects(:exists?).with(:ch).returns(true)
60
- @regions_repo.expects(:exists?).with(:ch_zh).returns(true)
61
- @regions_repo.expects(:search).with('ch_').returns([:ch_zh])
62
-
63
- regions, observed, informal = @subject.call([:ch_])
64
- assert_equal(false, regions.include?(:ch_))
65
- end
66
-
67
- def test_raises_error_if_regions_are_invalid
68
- @region_validator.stubs(:valid?).returns(false)
69
-
70
- assert_raise Holidays::UnknownRegionError do
71
- @subject.call([:unknown_region])
72
- end
73
- end
74
- end
@@ -1,27 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
-
3
- require 'holidays/date_calculator_factory'
4
-
5
- class DateCalculatorFactoryTests < Test::Unit::TestCase
6
- def setup
7
- @subject = Holidays::DateCalculatorFactory
8
- end
9
-
10
- def test_day_of_month_calculator
11
- assert @subject.day_of_month_calculator.is_a?(Holidays::DateCalculator::DayOfMonth)
12
- end
13
-
14
- def test_weekend_modifier
15
- assert @subject.weekend_modifier.is_a?(Holidays::DateCalculator::WeekendModifier)
16
- end
17
-
18
- def test_easter_calculator_gregorian
19
- @subject = @subject::Easter::Gregorian
20
- assert @subject.easter_calculator.is_a?(Holidays::DateCalculator::Easter::Gregorian)
21
- end
22
-
23
- def test_easter_calculator_julian
24
- @subject = @subject::Easter::Julian
25
- assert @subject.easter_calculator.is_a?(Holidays::DateCalculator::Easter::Julian)
26
- end
27
- end
@@ -1,49 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
-
3
- require 'holidays/definition_factory'
4
-
5
- class DefinitionFactoryTests < Test::Unit::TestCase
6
- def test_definition_file_parser
7
- assert Holidays::DefinitionFactory.file_parser.is_a?(Holidays::Definition::Context::Generator)
8
- end
9
-
10
- def test_definition_source_generator
11
- assert Holidays::DefinitionFactory.source_generator.is_a?(Holidays::Definition::Context::Generator)
12
- end
13
-
14
- def test_definition_merger
15
- assert Holidays::DefinitionFactory.merger.is_a?(Holidays::Definition::Context::Merger)
16
- end
17
-
18
- def test_holidays_by_month_repository
19
- assert Holidays::DefinitionFactory.holidays_by_month_repository.is_a?(Holidays::Definition::Repository::HolidaysByMonth)
20
- end
21
-
22
- def test_regions_repository
23
- assert Holidays::DefinitionFactory.regions_repository.is_a?(Holidays::Definition::Repository::Regions)
24
- end
25
-
26
- def test_cache_repository
27
- assert Holidays::DefinitionFactory.cache_repository.is_a?(Holidays::Definition::Repository::Cache)
28
- end
29
-
30
- def test_proc_result_cache_repository
31
- assert Holidays::DefinitionFactory.proc_result_cache_repository.is_a?(Holidays::Definition::Repository::ProcResultCache)
32
- end
33
-
34
- def test_custom_method_parser
35
- assert Holidays::DefinitionFactory.custom_method_parser.is_a?(Holidays::Definition::Parser::CustomMethod)
36
- end
37
-
38
- def test_custom_method_source_decorator
39
- assert Holidays::DefinitionFactory.custom_method_source_decorator.is_a?(Holidays::Definition::Decorator::CustomMethodSource)
40
- end
41
-
42
- def test_custom_method_validator
43
- assert Holidays::DefinitionFactory.custom_method_validator.is_a?(Holidays::Definition::Validator::CustomMethod)
44
- end
45
-
46
- def test_region_validator
47
- assert Holidays::DefinitionFactory.region_validator.is_a?(Holidays::Definition::Validator::Region)
48
- end
49
- end
@@ -1,9 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
-
3
- require 'holidays/option_factory'
4
-
5
- class OptionFactoryTests < Test::Unit::TestCase
6
- def test_parse_options_factory
7
- assert Holidays::OptionFactory.parse_options.is_a?(Holidays::Option::Context::ParseOptions)
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
-
3
- require 'holidays/use_case_factory'
4
-
5
- class UseCaseFactoryTests < Test::Unit::TestCase
6
- def test_between_factory
7
- assert Holidays::UseCaseFactory.between.is_a?(Holidays::UseCase::Context::Between)
8
- end
9
-
10
- def test_dates_driver_builder_factory
11
- assert Holidays::UseCaseFactory.dates_driver_builder.is_a?(Holidays::UseCase::Context::DatesDriverBuilder)
12
- end
13
- end
@@ -1,77 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../../../test_helper'
2
-
3
- require 'holidays/use_case/context/between'
4
-
5
- #TODO These tests need love. This is the heart of the holiday logic and I'm only
6
- # now starting to tear bits and pieces of it apart to untangle it. This is a start
7
- # but definitely needs more coverage.
8
- class BetweenTests < Test::Unit::TestCase
9
- def setup
10
- @holidays_by_month_repo = mock()
11
- @day_of_month_calculator = mock()
12
- @custom_method_repo = mock()
13
- @proc_cache_repo = mock()
14
-
15
- @subject = Holidays::UseCase::Context::Between.new(
16
- @holidays_by_month_repo,
17
- @day_of_month_calculator,
18
- @custom_method_repo,
19
- @proc_cache_repo,
20
- )
21
-
22
- @start_date = Date.civil(2015, 1, 1)
23
- @end_date = Date.civil(2015, 1, 1)
24
- @dates_driver = {2015 => [0, 1, 2], 2014 => [0, 12]}
25
- @regions = [:us]
26
- @observed = false
27
- @informal = false
28
- end
29
-
30
- def test_returns_error_if_start_date_is_missing
31
- assert_raise ArgumentError do
32
- @subject.call(nil, @end_date, @dates_driver, @regions, @observed, @informal)
33
- end
34
- end
35
-
36
- def test_returns_error_if_end_date_is_missing
37
- assert_raise ArgumentError do
38
- @subject.call(@start_date, nil, @dates_driver, @regions, @observed, @informal)
39
- end
40
- end
41
-
42
- def test_returns_error_if_driver_hash_is_nil
43
- assert_raise ArgumentError do
44
- @subject.call(@start_date, @end_date, nil, @regions, @observed, @informal)
45
- end
46
- end
47
-
48
- def test_returns_error_if_driver_hash_is_empty
49
- assert_raise ArgumentError do
50
- @subject.call(@start_date, @end_date, {}, @regions, @observed, @informal)
51
- end
52
- end
53
-
54
- def test_returns_error_if_driver_hash_has_empty_months_array
55
- assert_raise ArgumentError do
56
- @subject.call(@start_date, @end_date, {2015 => nil}, @regions, @observed, @informal)
57
- end
58
-
59
- assert_raise ArgumentError do
60
- @subject.call(@start_date, @end_date, {2015 => []}, @regions, @observed, @informal)
61
- end
62
-
63
- assert_raise ArgumentError do
64
- @subject.call(@start_date, @end_Date, {2015 => [1], 2016 => [1], 2017 => []}, @regions, @observed, @informal)
65
- end
66
- end
67
-
68
- def test_returns_error_if_regions_are_missing_or_empty
69
- assert_raise ArgumentError do
70
- @subject.call(@start_date, @end_date, @dates_driver, nil, @observed, @informal)
71
- end
72
-
73
- assert_raise ArgumentError do
74
- @subject.call(@start_date, @end_date, @dates_driver, [], @observed, @informal)
75
- end
76
- end
77
- end
@@ -1,24 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/test_helper'
2
- require "#{Holidays::DEFINITIONS_PATH}/gb"
3
- require "#{Holidays::DEFINITIONS_PATH}/ie"
4
-
5
- class MultipleRegionsTests < Test::Unit::TestCase
6
- def setup
7
- @date = Date.civil(2008,1,1)
8
- end
9
-
10
- def test_defining_holidays
11
- h = Holidays.on(Date.civil(2008,12,26), :ie)
12
- assert_equal 'St. Stephen\'s Day', h[0][:name]
13
-
14
- h = Holidays.on(Date.civil(2008,5,9), :gb_)
15
- assert_equal 'Liberation Day', (h[0] || {})[:name]
16
-
17
-
18
- h = Holidays.on(Date.civil(2008,5,9), :je)
19
- assert_equal 'Liberation Day', h[0][:name]
20
-
21
- h = Holidays.on(Date.civil(2008,5,9), :gb)
22
- assert h.empty?
23
- end
24
- end