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
@@ -0,0 +1,97 @@
1
+ require File.expand_path(File.dirname(__FILE__)) + '/../../../test_helper'
2
+
3
+ require 'holidays/definition/generator/regions'
4
+
5
+ class GeneratorRegionsTests < Test::Unit::TestCase
6
+ def setup
7
+ @generator = Holidays::Definition::Generator::Regions.new
8
+ end
9
+
10
+ def test_generates_regions_single_region_multiple_subregions
11
+ regions = {:region1 => [:test, :test2]}
12
+ expected = <<-EOE
13
+ # encoding: utf-8
14
+ module Holidays
15
+ REGIONS = [:test, :test2]
16
+
17
+ PARENT_REGION_LOOKUP = {:test=>:region1, :test2=>:region1}
18
+ end
19
+ EOE
20
+
21
+ assert_equal expected, @generator.call(regions)
22
+ end
23
+
24
+ def test_generates_regions_multiple_regions_single_unique_subregions
25
+ regions = {:region1 => [:test], :region2 => [:test2]}
26
+ expected = <<-EOE
27
+ # encoding: utf-8
28
+ module Holidays
29
+ REGIONS = [:test, :test2]
30
+
31
+ PARENT_REGION_LOOKUP = {:test=>:region1, :test2=>:region2}
32
+ end
33
+ EOE
34
+
35
+ assert_equal expected, @generator.call(regions)
36
+ end
37
+
38
+ def test_generates_regions_multiple_regions_multiple_overlapping_subregions
39
+ regions = {:region1 => [:test], :region2 => [:test, :test2], :region3 => [:test3, :test]}
40
+ expected = <<-EOE
41
+ # encoding: utf-8
42
+ module Holidays
43
+ REGIONS = [:test, :test2, :test3]
44
+
45
+ PARENT_REGION_LOOKUP = {:test=>:region1, :test2=>:region2, :test3=>:region3}
46
+ end
47
+ EOE
48
+
49
+ assert_equal expected, @generator.call(regions)
50
+ end
51
+
52
+ def test_generates_regions_multiple_regions_multiple_overlapping_subregions_complex
53
+ regions = {
54
+ :region1 => [:test],
55
+ :region2 => [:test, :test2],
56
+ :region3 => [:test3, :test],
57
+ :region4 => [:test4, :test2],
58
+ :region5 => [:test4, :test5, :test3],
59
+ :region6 => [:test4, :test6, :test],
60
+ }
61
+
62
+ expected = <<-EOE
63
+ # encoding: utf-8
64
+ module Holidays
65
+ REGIONS = [:test, :test2, :test3, :test4, :test5, :test6]
66
+
67
+ PARENT_REGION_LOOKUP = {:test=>:region1, :test2=>:region2, :test3=>:region3, :test4=>:region4, :test5=>:region5, :test6=>:region6}
68
+ end
69
+ EOE
70
+
71
+ assert_equal expected, @generator.call(regions)
72
+ end
73
+
74
+ def test_returns_error_if_regions_is_empty
75
+ regions = {}
76
+
77
+ assert_raises ArgumentError do
78
+ @generator.call(regions)
79
+ end
80
+ end
81
+
82
+ def test_returns_error_if_regions_is_not_a_hash
83
+ regions = "invalid"
84
+
85
+ assert_raises ArgumentError do
86
+ @generator.call(regions)
87
+ end
88
+ end
89
+
90
+ def test_returns_error_if_regions_is_nil
91
+ regions = nil
92
+
93
+ assert_raises ArgumentError do
94
+ @generator.call(regions)
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,113 @@
1
+ # Heh at this file name
2
+ require File.expand_path(File.dirname(__FILE__)) + '/../../../test_helper'
3
+
4
+ require 'holidays/definition/generator/test'
5
+ require 'holidays/definition/entity/test'
6
+
7
+ class TestGeneratorTests < Test::Unit::TestCase
8
+ def setup
9
+ @module_name = "Test"
10
+ @files = ["file1.rb"]
11
+ @tests = [
12
+ Holidays::Definition::Entity::Test.new(
13
+ :dates => [DateTime.parse("2016-01-01")],
14
+ :regions => [:test],
15
+ :name => "Test Holiday",
16
+ ),
17
+ ]
18
+
19
+ @decorator = mock()
20
+
21
+ @generator = Holidays::Definition::Generator::Test.new(@decorator)
22
+ end
23
+
24
+ def test_generate_tests_raises_error_if_module_name_is_invalid
25
+ assert_raises ArgumentError do
26
+ @generator.call(nil, @files, @tests)
27
+ end
28
+
29
+ assert_raises ArgumentError do
30
+ @generator.call("", @files, @tests)
31
+ end
32
+ end
33
+
34
+ def test_generate_tests_raises_error_if_files_is_invalid
35
+ assert_raises ArgumentError do
36
+ @generator.call(@module_name, nil, @tests)
37
+ end
38
+
39
+ assert_raises ArgumentError do
40
+ @generator.call(@module_name, "", @tests)
41
+ end
42
+ end
43
+
44
+ def test_generate_tests_raises_error_if_tests_are_missing
45
+ assert_raises ArgumentError do
46
+ @generator.call(@module_name, @files, nil)
47
+ end
48
+ end
49
+
50
+ def test_generate_source_from_single_test
51
+ @decorator.expects(:call).with(@tests.first).returns("test")
52
+
53
+ expected = <<-EOT
54
+ # encoding: utf-8
55
+ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
56
+
57
+ # This file is generated by the Ruby Holiday gem.
58
+ #
59
+ # Definitions loaded: #{@files.join(', ')}
60
+ class #{@module_name.to_s.capitalize}DefinitionTests < Test::Unit::TestCase # :nodoc:
61
+
62
+ def test_#{@module_name.to_s.downcase}
63
+ test
64
+ end
65
+ end
66
+ EOT
67
+
68
+ assert_equal(expected, @generator.call(@module_name, @files, @tests))
69
+ end
70
+
71
+ def test_generate_source_from_multiple_tests
72
+ @tests = [
73
+ Holidays::Definition::Entity::Test.new(
74
+ :dates => [DateTime.parse("2016-01-01")],
75
+ :regions => [:test],
76
+ :name => "Test Holiday",
77
+ ),
78
+ Holidays::Definition::Entity::Test.new(
79
+ :dates => [DateTime.parse("2016-02-01")],
80
+ :regions => [:test2],
81
+ :name => "Test Holiday2",
82
+ ),
83
+ Holidays::Definition::Entity::Test.new(
84
+ :dates => [DateTime.parse("2016-03-01")],
85
+ :regions => [:test3],
86
+ :name => "Test Holiday3",
87
+ ),
88
+ ]
89
+
90
+ @decorator.expects(:call).with(@tests[0]).returns("test")
91
+ @decorator.expects(:call).with(@tests[1]).returns("test2")
92
+ @decorator.expects(:call).with(@tests[2]).returns("test3")
93
+
94
+ expected = <<-EOT
95
+ # encoding: utf-8
96
+ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
97
+
98
+ # This file is generated by the Ruby Holiday gem.
99
+ #
100
+ # Definitions loaded: #{@files.join(', ')}
101
+ class #{@module_name.to_s.capitalize}DefinitionTests < Test::Unit::TestCase # :nodoc:
102
+
103
+ def test_#{@module_name.to_s.downcase}
104
+ test
105
+ test2
106
+ test3
107
+ end
108
+ end
109
+ EOT
110
+
111
+ assert_equal(expected, @generator.call(@module_name, @files, @tests))
112
+ end
113
+ end
@@ -11,7 +11,7 @@ class ParserCustomMethodTests < Test::Unit::TestCase
11
11
  end
12
12
 
13
13
  def test_parse_happy_single_method
14
- input = {"custom_method"=>{"arguments"=>"year", "source"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}}
14
+ input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}}
15
15
  @validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(true)
16
16
 
17
17
  result = @parser.call(input)
@@ -28,7 +28,7 @@ class ParserCustomMethodTests < Test::Unit::TestCase
28
28
  end
29
29
 
30
30
  def test_call_happy_with_multiple_methods
31
- input = {"custom_method"=>{"arguments"=>"year", "source"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}, "second_method"=>{"arguments"=>"month","source"=>"source"}}
31
+ input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}, "second_method"=>{"arguments"=>"month","ruby"=>"source"}}
32
32
  @validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(true)
33
33
  @validator.expects(:valid?).with({:name => "second_method", :arguments => "month", :source => "source"}).returns(true)
34
34
 
@@ -59,21 +59,21 @@ class ParserCustomMethodTests < Test::Unit::TestCase
59
59
  end
60
60
 
61
61
  def test_call_raises_error_if_validator_returns_false_for_single_method
62
- input = {"custom_method"=>{"arguments"=>"year", "source"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}}
62
+ input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}}
63
63
  @validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(false)
64
64
 
65
65
  assert_raises ArgumentError do
66
- result = @parser.call(input)
66
+ @parser.call(input)
67
67
  end
68
68
  end
69
69
 
70
70
  def test_call_raises_error_if_validator_returns_false_for_one_of_multiple_methods
71
- input = {"custom_method"=>{"arguments"=>"year", "source"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}, "second_method"=>{"arguments"=>"month","source"=>"source"}}
71
+ input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}, "second_method"=>{"arguments"=>"month","ruby"=>"source"}}
72
72
  @validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(true)
73
73
  @validator.expects(:valid?).with({:name => "second_method", :arguments => "month", :source => "source"}).returns(false)
74
74
 
75
75
  assert_raises ArgumentError do
76
- result = @parser.call(input)
76
+ @parser.call(input)
77
77
  end
78
78
  end
79
79
  end
@@ -0,0 +1,142 @@
1
+ # Heh at this file name
2
+ require File.expand_path(File.dirname(__FILE__)) + '/../../../test_helper'
3
+
4
+ require 'holidays/definition/parser/test'
5
+ require 'holidays/definition/entity/test'
6
+
7
+ class ParserTestTests < Test::Unit::TestCase
8
+ def setup
9
+ @validator = mock()
10
+
11
+ @parser = Holidays::Definition::Parser::Test.new(@validator)
12
+ end
13
+
14
+ def test_parse_no_tests
15
+ input = nil
16
+ result = @parser.call(input)
17
+
18
+ assert_equal(0, result.size)
19
+ end
20
+
21
+ def test_parse_single_test_happy
22
+ input = [ { "given" => { "date" => "2016-01-01", "regions" => ['us'] }, "expect" => { "name" => "Test Holiday" } } ]
23
+ @validator.expects(:valid?).with({:dates => ["2016-01-01"], :regions=> ['us'], :options => nil, :name => "Test Holiday", :holiday => nil}).returns(true)
24
+
25
+ result = @parser.call(input)
26
+
27
+ assert_equal(1, result.size)
28
+
29
+ test = result.first
30
+ assert(test)
31
+
32
+ assert(test.is_a?(Holidays::Definition::Entity::Test))
33
+ assert_equal([DateTime.parse('2016-01-01')], test.dates)
34
+ assert_equal([:us], test.regions)
35
+ assert_equal("Test Holiday", test.name)
36
+ assert(test.holiday?)
37
+ end
38
+
39
+ def test_parse_single_test_with_options
40
+ input = [ { "given" => { "date" => "2016-01-01", "regions" => ['us'], "options" => ['option1']}, "expect" => { "name" => "Test Holiday" } } ]
41
+ @validator.expects(:valid?).with({:dates => ["2016-01-01"], :regions=> ['us'], :name => "Test Holiday", :options => ['option1'], :holiday => nil}).returns(true)
42
+
43
+ result = @parser.call(input)
44
+
45
+ assert_equal(1, result.size)
46
+
47
+ test = result.first
48
+ assert(test)
49
+
50
+ assert(test.is_a?(Holidays::Definition::Entity::Test))
51
+ assert_equal([DateTime.parse('2016-01-01')], test.dates)
52
+ assert_equal([:us], test.regions)
53
+ assert_equal([:option1], test.options)
54
+ assert_equal("Test Holiday", test.name)
55
+ assert(test.holiday?)
56
+ end
57
+
58
+ def test_parse_single_test_with_single_option_as_string
59
+ input = [ { "given" => { "date" => "2016-01-01", "regions" => ['us'], "options" => 'option1'}, "expect" => { "name" => "Test Holiday" } } ]
60
+ @validator.expects(:valid?).with({:dates => ["2016-01-01"], :regions=> ['us'], :name => "Test Holiday", :options => 'option1', :holiday => nil}).returns(true)
61
+
62
+ result = @parser.call(input)
63
+
64
+ assert_equal(1, result.size)
65
+
66
+ test = result.first
67
+ assert(test)
68
+
69
+ assert(test.is_a?(Holidays::Definition::Entity::Test))
70
+ assert_equal([DateTime.parse('2016-01-01')], test.dates)
71
+ assert_equal([:us], test.regions)
72
+ assert_equal([:option1], test.options)
73
+ assert_equal("Test Holiday", test.name)
74
+ assert(test.holiday?)
75
+ end
76
+
77
+ def test_parse_single_test_no_name_no_holiday
78
+ input = [ { "given" => { "date" => "2016-01-01", "regions" => ['us']}, "expect" => { "holiday" => false } } ]
79
+ @validator.expects(:valid?).with({:dates => ["2016-01-01"], :regions=> ['us'], :name => nil, :options => nil, :holiday => false}).returns(true)
80
+
81
+ result = @parser.call(input)
82
+
83
+ assert_equal(1, result.size)
84
+
85
+ test = result.first
86
+ assert(test)
87
+
88
+ assert(test.is_a?(Holidays::Definition::Entity::Test))
89
+ assert_equal([DateTime.parse('2016-01-01')], test.dates)
90
+ assert_equal([:us], test.regions)
91
+ assert_nil(test.options)
92
+ assert_nil(test.name)
93
+ assert_equal(false, test.holiday?)
94
+ end
95
+
96
+ def test_parse_single_test_with_options_no_name_no_holiday
97
+ input = [ { "given" => { "date" => "2016-01-01", "regions" => ['us'], "options" => ['option1']}, "expect" => { "holiday" => false } } ]
98
+ @validator.expects(:valid?).with({:dates => ["2016-01-01"], :regions=> ['us'], :name => nil, :options => ['option1'], :holiday => false}).returns(true)
99
+
100
+ result = @parser.call(input)
101
+
102
+ assert_equal(1, result.size)
103
+
104
+ test = result.first
105
+ assert(test)
106
+
107
+ assert(test.is_a?(Holidays::Definition::Entity::Test))
108
+ assert_equal([DateTime.parse('2016-01-01')], test.dates)
109
+ assert_equal([:us], test.regions)
110
+ assert_equal([:option1], test.options)
111
+ assert_nil(test.name)
112
+ assert_equal(false, test.holiday?)
113
+ end
114
+
115
+ def test_parse_single_test_multiple_dates
116
+ input = [ { "given" => { "date" => ["2016-01-01", "2017-01-01"], "regions" => ['us']}, "expect" => { "name" => "Test Holiday"} } ]
117
+ @validator.expects(:valid?).with({:dates => ["2016-01-01", "2017-01-01"], :regions=> ['us'], :name => "Test Holiday", :options => nil, :holiday => nil}).returns(true)
118
+
119
+ result = @parser.call(input)
120
+
121
+ assert_equal(1, result.size)
122
+
123
+ test = result.first
124
+ assert(test)
125
+
126
+ assert(test.is_a?(Holidays::Definition::Entity::Test))
127
+ assert_equal([DateTime.parse('2016-01-01'), DateTime.parse('2017-01-01')], test.dates)
128
+ assert_equal([:us], test.regions)
129
+ assert_nil(test.options)
130
+ assert_equal("Test Holiday", test.name)
131
+ assert(test.holiday?)
132
+ end
133
+
134
+ def test_parse_single_test_fail_validation
135
+ input = [ { "given" => { "date" => "2016-01-01", "regions" => ['us']}, "expect" => { "name" => "Test Holiday"} } ]
136
+ @validator.expects(:valid?).with({:dates => ["2016-01-01"], :regions=> ['us'], :name => "Test Holiday", :options => nil, :holiday => nil}).returns(false)
137
+
138
+ assert_raises ArgumentError do
139
+ @parser.call(input)
140
+ end
141
+ end
142
+ end
@@ -7,30 +7,71 @@ class CacheRepoTests < Test::Unit::TestCase
7
7
  @subject = Holidays::Definition::Repository::Cache.new
8
8
  end
9
9
 
10
+ def test_find_supports_overlapping_holidays
11
+ start_date = Date.civil(2015, 1, 1)
12
+ end_date = Date.civil(2015, 7, 1)
13
+ cache_data = [
14
+ {:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day A", :regions=>[:us]},
15
+ {:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day B", :regions=>[:us]}
16
+ ]
17
+ options = :us
18
+
19
+ @subject.cache_between(start_date, end_date, cache_data, options)
20
+
21
+ assert_equal(cache_data, @subject.find(start_date, start_date, options))
22
+ assert_equal(cache_data, @subject.find(start_date, end_date, options))
23
+ end
24
+
25
+ def test_cache_returns_empty_array_no_holidays_are_found
26
+ start_date = Date.civil(2015, 1, 1)
27
+ end_date = Date.civil(2015, 7, 1)
28
+ cache_data = [{:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day", :regions=>[:us]}]
29
+ options = :us
30
+
31
+ @subject.cache_between(start_date, end_date, cache_data, options)
32
+
33
+ assert_empty(@subject.find(Date.civil(2015, 1, 2), Date.civil(2015, 1, 2), options))
34
+ assert_empty(@subject.find(Date.civil(2015, 1, 2), Date.civil(2015, 1, 3), options))
35
+ end
36
+
37
+ def test_cache_returns_empty_array_when_cache_is_empty
38
+ start_date = Date.civil(2015, 1, 1)
39
+ end_date = Date.civil(2015, 7, 1)
40
+ cache_data = []
41
+ options = :us
42
+
43
+ @subject.cache_between(start_date, end_date, cache_data, options)
44
+
45
+ assert_empty(@subject.find(Date.civil(2015, 1, 2), Date.civil(2015, 1, 2), options))
46
+ assert_empty(@subject.find(Date.civil(2015, 1, 2), Date.civil(2015, 1, 3), options))
47
+ end
48
+
10
49
  def test_find_returns_correct_cache_data
11
50
  start_date = Date.civil(2015, 1, 1)
12
- end_date = Date.civil(2015, 1, 1)
13
- cache_data = [{:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day", :regions=>[:us]}]
51
+ end_date = Date.civil(2015, 7, 1)
52
+ cache_data = [{:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day", :regions=>[:us]}]
14
53
  options = :us
15
54
  @subject.cache_between(start_date, end_date, cache_data, options)
16
55
 
56
+ assert_equal(cache_data, @subject.find(start_date, start_date, options))
17
57
  assert_equal(cache_data, @subject.find(start_date, end_date, options))
18
58
  end
19
59
 
20
60
  def test_find_returns_nil_if_no_match_is_found
21
61
  start_date = Date.civil(2015, 1, 1)
22
62
  end_date = Date.civil(2015, 1, 1)
23
- cache_data = [{:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day", :regions=>[:us]}]
63
+ cache_data = [{:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day", :regions=>[:us]}]
24
64
  options = :us
25
65
  @subject.cache_between(start_date, end_date, cache_data, options)
26
66
 
27
67
  assert_nil(@subject.find(Date.civil(2015, 7, 1), Date.civil(2015, 12, 1), options))
68
+ assert_nil(@subject.find(Date.civil(2015, 7, 1), Date.civil(2015, 12, 1), options))
28
69
  end
29
70
 
30
71
  def test_cache_between_returns_error_if_dates_are_missing
31
72
  start_date = Date.civil(2015, 1, 1)
32
73
  end_date = Date.civil(2015, 1, 1)
33
- cache_data = [{:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day", :regions=>[:us]}]
74
+ cache_data = [{:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day", :regions=>[:us]}]
34
75
  options = :us
35
76
 
36
77
  assert_raise ArgumentError do
@@ -45,7 +86,7 @@ class CacheRepoTests < Test::Unit::TestCase
45
86
  def test_cache_between_returns_error_if_dates_are_invalid
46
87
  start_date = Date.civil(2015, 1, 1)
47
88
  end_date = Date.civil(2015, 1, 1)
48
- cache_data = [{:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day", :regions=>[:us]}]
89
+ cache_data = [{:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day", :regions=>[:us]}]
49
90
  options = :us
50
91
 
51
92
  assert_raise ArgumentError do
@@ -70,7 +111,7 @@ class CacheRepoTests < Test::Unit::TestCase
70
111
  def test_reset_clears_cache
71
112
  start_date = Date.civil(2015, 1, 1)
72
113
  end_date = Date.civil(2015, 1, 1)
73
- cache_data = [{:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day", :regions=>[:us]}]
114
+ cache_data = [{:date=>Date.civil(2015, 1, 1), :name=>"New Year's Day", :regions=>[:us]}]
74
115
  options = :us
75
116
  @subject.cache_between(start_date, end_date, cache_data, options)
76
117
 
@@ -109,7 +109,7 @@ class HolidaysByMonthRepoTests < Test::Unit::TestCase
109
109
  assert_equal(expected, @subject.all)
110
110
  end
111
111
 
112
- def test_add_is_successful_and_updates_regions_to_existing_matching_definitions
112
+ def test_add_is_successful_if_only_region_is_different_and_updates_regions_to_existing_matching_definitions
113
113
  target_holidays = {0 => [:mday => 1, :name => "Test", :regions => [:test2]]}
114
114
 
115
115
  @subject.add(@existing_holidays_by_month)
@@ -152,4 +152,124 @@ class HolidaysByMonthRepoTests < Test::Unit::TestCase
152
152
  @subject.find_by_month(-1)
153
153
  end
154
154
  end
155
+
156
+ def test_add_is_successful_if_only_function_is_different
157
+ initial_holidays = {0=> [{:mday => 1, :name=>"Test", :regions=>[:test], :function=>"easter(year)", :function_arguments=>[:year]}]}
158
+
159
+ @subject.add(initial_holidays)
160
+
161
+ second_holidays = {0=> [{:mday => 1, :name=>"Test", :regions=>[:test2], :function=>"orthodox_easter(year)", :function_arguments=>[:year]}]}
162
+ @subject.add(second_holidays)
163
+
164
+ expected = {
165
+ 0 => [
166
+ {
167
+ :function=>"easter(year)",
168
+ :function_arguments=>[:year],
169
+ :mday=>1,
170
+ :name=>"Test",
171
+ :regions=>[:test]
172
+ },
173
+ {
174
+ :function=>"orthodox_easter(year)",
175
+ :function_arguments=>[:year],
176
+ :mday=>1,
177
+ :name=>"Test",
178
+ :regions=>[:test2]
179
+ }
180
+ ]
181
+ }
182
+
183
+ assert_equal(expected, @subject.all)
184
+ end
185
+
186
+ def test_add_is_successful_if_only_function_modifier_is_different
187
+ initial_holidays = {0=> [{:mday => 1, :name=>"Test", :regions=>[:test], :function=>"easter(year)", :function_modifier=>1, :function_arguments=>[:year]}]}
188
+
189
+ @subject.add(initial_holidays)
190
+
191
+ second_holidays = {0=> [{:mday => 1, :name=>"Test", :regions=>[:test2], :function=>"easter(year)", :function_modifier=>2, :function_arguments=>[:year]}]}
192
+ @subject.add(second_holidays)
193
+
194
+ expected = {
195
+ 0 => [
196
+ {
197
+ :function=>"easter(year)",
198
+ :function_arguments=>[:year],
199
+ :function_modifier=>1,
200
+ :mday=>1,
201
+ :name=>"Test",
202
+ :regions=>[:test]
203
+ },
204
+ {
205
+ :function=>"easter(year)",
206
+ :function_arguments=>[:year],
207
+ :function_modifier=>2,
208
+ :mday=>1,
209
+ :name=>"Test",
210
+ :regions=>[:test2]
211
+ }
212
+ ]
213
+ }
214
+
215
+ assert_equal(expected, @subject.all)
216
+ end
217
+
218
+ def test_add_is_successful_if_only_observed_is_different
219
+ initial_holidays = {0=> [{:mday => 1, :name=>"Test", :regions=>[:test], :observed=>"to_weekday_if_weekend(year)", :function_arguments=>[:year]}]}
220
+
221
+ @subject.add(initial_holidays)
222
+
223
+ second_holidays = {0=> [{:mday => 1, :name=>"Test", :regions=>[:test2], :observed =>"to_friday_if_saturday(year)", :function_arguments=>[:year]}]}
224
+ @subject.add(second_holidays)
225
+
226
+ expected = {
227
+ 0 => [
228
+ {
229
+ :observed =>"to_weekday_if_weekend(year)",
230
+ :function_arguments=>[:year],
231
+ :mday=>1,
232
+ :name=>"Test",
233
+ :regions=>[:test]
234
+ },
235
+ {
236
+ :observed =>"to_friday_if_saturday(year)",
237
+ :function_arguments=>[:year],
238
+ :mday=>1,
239
+ :name=>"Test",
240
+ :regions=>[:test2]
241
+ }
242
+ ]
243
+ }
244
+
245
+ assert_equal(expected, @subject.all)
246
+ end
247
+
248
+ def test_add_is_successful_if_only_year_ranges_is_different
249
+ initial_holidays = {0=> [{:mday => 1, :name=>"Test", :regions=>[:test], :year_ranges => {:from => 1990}}]}
250
+
251
+ @subject.add(initial_holidays)
252
+
253
+ second_holidays = {0=> [{:mday => 1, :name=>"Test", :regions=>[:test2], :year_ranges => {:until => 2002}}]}
254
+ @subject.add(second_holidays)
255
+
256
+ expected = {
257
+ 0 => [
258
+ {
259
+ :mday=>1,
260
+ :name=>"Test",
261
+ :regions=>[:test],
262
+ :year_ranges => {:from => 1990}
263
+ },
264
+ {
265
+ :mday=>1,
266
+ :name=>"Test",
267
+ :regions=>[:test2],
268
+ :year_ranges => {:until => 2002}
269
+ }
270
+ ]
271
+ }
272
+
273
+ assert_equal(expected, @subject.all)
274
+ end
155
275
  end
@@ -40,6 +40,13 @@ class ProcResultCacheRepoTests < Test::Unit::TestCase
40
40
  assert_equal(Date.civil(2015, 1, 31), @subject.lookup(function, function_argument))
41
41
  end
42
42
 
43
+ def test_lookup_accepts_symbol_as_function_argument
44
+ function = lambda { |symbol| symbol }
45
+ function_argument = :test
46
+
47
+ assert_equal(:test, @subject.lookup(function, function_argument))
48
+ end
49
+
43
50
  def test_accepts_multiple_arguments_for_functions
44
51
  function = lambda { |year, month, day| Date.civil(year, month, day) + 1 }
45
52
  year = 2016
@@ -76,7 +83,7 @@ class ProcResultCacheRepoTests < Test::Unit::TestCase
76
83
  @subject.lookup(function, function_argument)
77
84
  end
78
85
 
79
- funtion_argument = Proc.new { |arg1| "arg1" + "something"}
86
+ function_argument = Proc.new { |arg1| "arg1" + "something"}
80
87
  assert_raise ArgumentError do
81
88
  @subject.lookup(function, function_argument)
82
89
  end