holidays 9.2.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +38 -2
  4. data/lib/generated_definitions/au.rb +16 -42
  5. data/lib/generated_definitions/europe.rb +2 -10
  6. data/lib/generated_definitions/lu.rb +1 -1
  7. data/lib/generated_definitions/nz.rb +9 -1
  8. data/lib/generated_definitions/pl.rb +3 -11
  9. data/lib/holidays/definition/context/function_processor.rb +4 -5
  10. data/lib/holidays/definition/context/generator.rb +3 -1
  11. data/lib/holidays/version.rb +1 -1
  12. metadata +3 -313
  13. data/.github/workflows/changelog-check.yml +0 -47
  14. data/.github/workflows/release.yml +0 -46
  15. data/.github/workflows/ruby.yml +0 -26
  16. data/.gitmodules +0 -3
  17. data/CODE_OF_CONDUCT.md +0 -74
  18. data/Gemfile +0 -8
  19. data/Makefile +0 -60
  20. data/Rakefile +0 -137
  21. data/bin/console +0 -7
  22. data/bin/setup +0 -6
  23. data/doc/CONTRIBUTING.md +0 -72
  24. data/doc/MAINTAINERS.md +0 -79
  25. data/doc/REFERENCES +0 -19
  26. data/holidays.gemspec +0 -31
  27. data/test/coverage_report.rb +0 -24
  28. data/test/data/test_custom_year_range_holiday_defs.yaml +0 -31
  29. data/test/data/test_date_transform_conflict_region_1.yaml +0 -14
  30. data/test/data/test_date_transform_conflict_region_2.yaml +0 -14
  31. data/test/data/test_invalid_region.rb +0 -15
  32. data/test/data/test_region.rb +0 -15
  33. data/test/data/test_single_custom_holiday_defs.yaml +0 -12
  34. data/test/data/test_single_custom_holiday_with_custom_procs.yaml +0 -28
  35. data/test/defs/test_defs_ar.rb +0 -69
  36. data/test/defs/test_defs_at.rb +0 -31
  37. data/test/defs/test_defs_au.rb +0 -233
  38. data/test/defs/test_defs_be_fr.rb +0 -45
  39. data/test/defs/test_defs_be_nl.rb +0 -45
  40. data/test/defs/test_defs_bg.rb +0 -41
  41. data/test/defs/test_defs_br.rb +0 -49
  42. data/test/defs/test_defs_ca.rb +0 -289
  43. data/test/defs/test_defs_ch.rb +0 -51
  44. data/test/defs/test_defs_cl.rb +0 -69
  45. data/test/defs/test_defs_co.rb +0 -113
  46. data/test/defs/test_defs_cr.rb +0 -29
  47. data/test/defs/test_defs_cy.rb +0 -41
  48. data/test/defs/test_defs_cz.rb +0 -37
  49. data/test/defs/test_defs_de.rb +0 -91
  50. data/test/defs/test_defs_dk.rb +0 -47
  51. data/test/defs/test_defs_ecbtarget.rb +0 -27
  52. data/test/defs/test_defs_ee.rb +0 -41
  53. data/test/defs/test_defs_es.rb +0 -137
  54. data/test/defs/test_defs_europe.rb +0 -1530
  55. data/test/defs/test_defs_fed_ex.rb +0 -24
  56. data/test/defs/test_defs_federalreserve.rb +0 -119
  57. data/test/defs/test_defs_federalreservebanks.rb +0 -251
  58. data/test/defs/test_defs_fedex.rb +0 -31
  59. data/test/defs/test_defs_fi.rb +0 -59
  60. data/test/defs/test_defs_fr.rb +0 -43
  61. data/test/defs/test_defs_gb.rb +0 -163
  62. data/test/defs/test_defs_ge.rb +0 -53
  63. data/test/defs/test_defs_gr.rb +0 -41
  64. data/test/defs/test_defs_hk.rb +0 -93
  65. data/test/defs/test_defs_hr.rb +0 -45
  66. data/test/defs/test_defs_hu.rb +0 -47
  67. data/test/defs/test_defs_ie.rb +0 -53
  68. data/test/defs/test_defs_il.rb +0 -35
  69. data/test/defs/test_defs_in.rb +0 -94
  70. data/test/defs/test_defs_is.rb +0 -51
  71. data/test/defs/test_defs_it.rb +0 -57
  72. data/test/defs/test_defs_jp.rb +0 -159
  73. data/test/defs/test_defs_ke.rb +0 -31
  74. data/test/defs/test_defs_kr.rb +0 -37
  75. data/test/defs/test_defs_kz.rb +0 -39
  76. data/test/defs/test_defs_li.rb +0 -35
  77. data/test/defs/test_defs_lt.rb +0 -65
  78. data/test/defs/test_defs_lu.rb +0 -35
  79. data/test/defs/test_defs_lv.rb +0 -98
  80. data/test/defs/test_defs_ma.rb +0 -29
  81. data/test/defs/test_defs_mc.rb +0 -43
  82. data/test/defs/test_defs_mt_en.rb +0 -41
  83. data/test/defs/test_defs_mt_mt.rb +0 -41
  84. data/test/defs/test_defs_mx.rb +0 -49
  85. data/test/defs/test_defs_my.rb +0 -23
  86. data/test/defs/test_defs_nerc.rb +0 -29
  87. data/test/defs/test_defs_ng.rb +0 -29
  88. data/test/defs/test_defs_nl.rb +0 -33
  89. data/test/defs/test_defs_no.rb +0 -43
  90. data/test/defs/test_defs_northamerica.rb +0 -679
  91. data/test/defs/test_defs_nyse.rb +0 -46
  92. data/test/defs/test_defs_nz.rb +0 -67
  93. data/test/defs/test_defs_pe.rb +0 -47
  94. data/test/defs/test_defs_ph.rb +0 -29
  95. data/test/defs/test_defs_pl.rb +0 -229
  96. data/test/defs/test_defs_pt.rb +0 -47
  97. data/test/defs/test_defs_ro.rb +0 -69
  98. data/test/defs/test_defs_rs_cyrl.rb +0 -46
  99. data/test/defs/test_defs_rs_la.rb +0 -46
  100. data/test/defs/test_defs_ru.rb +0 -34
  101. data/test/defs/test_defs_scandinavia.rb +0 -215
  102. data/test/defs/test_defs_se.rb +0 -59
  103. data/test/defs/test_defs_sg.rb +0 -25
  104. data/test/defs/test_defs_si.rb +0 -105
  105. data/test/defs/test_defs_sk.rb +0 -37
  106. data/test/defs/test_defs_southamerica.rb +0 -327
  107. data/test/defs/test_defs_th.rb +0 -33
  108. data/test/defs/test_defs_tn.rb +0 -27
  109. data/test/defs/test_defs_tr.rb +0 -60
  110. data/test/defs/test_defs_tsx.rb +0 -70
  111. data/test/defs/test_defs_ua.rb +0 -41
  112. data/test/defs/test_defs_unitednations.rb +0 -11
  113. data/test/defs/test_defs_ups.rb +0 -31
  114. data/test/defs/test_defs_us.rb +0 -399
  115. data/test/defs/test_defs_ve.rb +0 -35
  116. data/test/defs/test_defs_vi.rb +0 -22
  117. data/test/defs/test_defs_za.rb +0 -35
  118. data/test/e2e/README.md +0 -52
  119. data/test/e2e/data/test_multiple_regions_with_conflicts_region_1.yaml +0 -38
  120. data/test/e2e/data/test_multiple_regions_with_conflicts_region_2.yaml +0 -38
  121. data/test/e2e/data/test_multiple_regions_with_conflicts_region_3.yaml +0 -38
  122. data/test/e2e/test_all_regions.rb +0 -49
  123. data/test/e2e/test_any_holidays_during_work_week.rb +0 -90
  124. data/test/e2e/test_holidays.rb +0 -244
  125. data/test/e2e/test_holidays_between.rb +0 -87
  126. data/test/e2e/test_multiple_regions.rb +0 -71
  127. data/test/e2e/test_multiple_regions_with_conflict.rb +0 -228
  128. data/test/e2e/test_nonstandard_regions.rb +0 -25
  129. data/test/holidays/core_extensions/test_date.rb +0 -122
  130. data/test/holidays/core_extensions/test_date_time.rb +0 -60
  131. data/test/holidays/date_calculator/test_day_of_month.rb +0 -27
  132. data/test/holidays/date_calculator/test_easter_gregorian.rb +0 -30
  133. data/test/holidays/date_calculator/test_easter_julian.rb +0 -36
  134. data/test/holidays/date_calculator/test_lunar_date.rb +0 -89
  135. data/test/holidays/date_calculator/test_weekend_modifier.rb +0 -54
  136. data/test/holidays/definition/context/test_function_processor.rb +0 -199
  137. data/test/holidays/definition/context/test_generator.rb +0 -226
  138. data/test/holidays/definition/context/test_load.rb +0 -37
  139. data/test/holidays/definition/context/test_merger.rb +0 -25
  140. data/test/holidays/definition/decorator/test_custom_method_proc.rb +0 -113
  141. data/test/holidays/definition/decorator/test_custom_method_source.rb +0 -96
  142. data/test/holidays/definition/decorator/test_test.rb +0 -123
  143. data/test/holidays/definition/generator/test_module.rb +0 -268
  144. data/test/holidays/definition/generator/test_regions.rb +0 -97
  145. data/test/holidays/definition/generator/test_test.rb +0 -113
  146. data/test/holidays/definition/parser/test_custom_method.rb +0 -79
  147. data/test/holidays/definition/parser/test_test.rb +0 -142
  148. data/test/holidays/definition/repository/test_cache.rb +0 -123
  149. data/test/holidays/definition/repository/test_custom_methods.rb +0 -43
  150. data/test/holidays/definition/repository/test_holidays_by_month.rb +0 -275
  151. data/test/holidays/definition/repository/test_proc_result_cache.rb +0 -91
  152. data/test/holidays/definition/repository/test_regions.rb +0 -104
  153. data/test/holidays/definition/validator/test_custom_method.rb +0 -94
  154. data/test/holidays/definition/validator/test_region.rb +0 -54
  155. data/test/holidays/definition/validator/test_test.rb +0 -60
  156. data/test/holidays/finder/context/test_between.rb +0 -172
  157. data/test/holidays/finder/context/test_dates_driver_builder.rb +0 -91
  158. data/test/holidays/finder/context/test_next_holiday.rb +0 -156
  159. data/test/holidays/finder/context/test_parse_options.rb +0 -141
  160. data/test/holidays/finder/context/test_search.rb +0 -290
  161. data/test/holidays/finder/context/test_year_holiday.rb +0 -202
  162. data/test/holidays/finder/rules/test_in_region.rb +0 -42
  163. data/test/holidays/finder/rules/test_year_range.rb +0 -166
  164. data/test/integration/README.md +0 -48
  165. data/test/integration/data/test_custom_govt_holiday_defs.yaml +0 -5
  166. data/test/integration/data/test_custom_informal_holidays_defs.yaml +0 -11
  167. data/test/integration/data/test_multiple_custom_holiday_defs.yaml +0 -12
  168. data/test/integration/test_custom_holidays.rb +0 -41
  169. data/test/integration/test_custom_informal_holidays.rb +0 -15
  170. data/test/integration/test_custom_year_range_holidays.rb +0 -35
  171. data/test/smoke/README.md +0 -31
  172. data/test/smoke/test_available_regions.rb +0 -18
  173. data/test/smoke/test_smoke.rb +0 -74
  174. data/test/test_helper.rb +0 -37
@@ -1,228 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
-
3
- # See https://github.com/holidays/holidays/issues/344 for more info on why
4
- # these specific integration tests exist.
5
- class MultipleRegionsWithConflictsTests < Test::Unit::TestCase
6
- def test_corpus_christi_returns_correctly_for_co_even_if_br_is_loaded_first
7
- result = Holidays.on(Date.new(2014, 6, 19), :br)
8
- assert_equal 1, result.count
9
- assert_equal 'Corpus Christi', result.first[:name]
10
-
11
- result = Holidays.on(Date.new(2014, 6, 23), :co)
12
- assert_equal 1, result.count
13
- assert_equal 'Corpus Christi', result.first[:name]
14
- end
15
-
16
- def test_custom_loaded_region_returns_correct_value_with_function_modifier_conflict_even_if_conflict_definition_is_loaded_first
17
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_1.yaml')
18
- result = Holidays.on(Date.new(2019, 6, 20), :multiple_with_conflict_1)
19
- assert_equal 1, result.count
20
- assert_equal 'With Function Modifier', result.first[:name]
21
-
22
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_2.yaml')
23
- result = Holidays.on(Date.new(2019, 6, 24), :multiple_with_conflict_2)
24
- assert_equal 1, result.count
25
- assert_equal 'With Function Modifier', result.first[:name]
26
-
27
- # Region 1 must still return the correct date even though region 2 was
28
- # loaded afterwards with a different function modifier.
29
- result = Holidays.on(Date.new(2019, 6, 20), :multiple_with_conflict_1)
30
- assert_equal 1, result.count
31
- assert_equal 'With Function Modifier', result.first[:name]
32
- end
33
-
34
- def test_custom_loaded_region_returns_correct_value_when_two_regions_share_function_name_but_have_different_logic
35
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_1.yaml')
36
-
37
- result = Holidays.on(Date.new(2019, 9, 1), :multiple_with_conflict_1)
38
- assert_equal 1, result.count
39
- assert_equal 'With Function Only Same Function Name', result.first[:name]
40
-
41
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_2.yaml')
42
-
43
- result = Holidays.on(Date.new(2019, 11, 1), :multiple_with_conflict_2)
44
- assert_equal 1, result.count
45
- assert_equal 'With Function Only Same Function Name', result.first[:name]
46
-
47
- # Region 1 must still return the correct date even though region 2 was
48
- # loaded afterwards with the same function name but different logic.
49
- result = Holidays.on(Date.new(2019, 9, 1), :multiple_with_conflict_1)
50
- assert_equal 1, result.count
51
- assert_equal 'With Function Only Same Function Name', result.first[:name]
52
- end
53
-
54
- # Load region 2 first, then region 1, which is the opposite of the test above.
55
- # The first-loaded method lands in @custom_methods; the second goes into
56
- # @regional_overrides. This reversal exercises the fallback path for the
57
- # first-loaded region rather than the override path.
58
- def test_custom_loaded_region_returns_correct_value_when_load_order_is_reversed
59
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_2.yaml')
60
-
61
- result = Holidays.on(Date.new(2019, 11, 1), :multiple_with_conflict_2)
62
- assert_equal 1, result.count
63
- assert_equal 'With Function Only Same Function Name', result.first[:name]
64
-
65
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_1.yaml')
66
-
67
- result = Holidays.on(Date.new(2019, 9, 1), :multiple_with_conflict_1)
68
- assert_equal 1, result.count
69
- assert_equal 'With Function Only Same Function Name', result.first[:name]
70
-
71
- # Region 2 must still return the correct date even though region 1 was
72
- # loaded afterwards with the same function name but different logic.
73
- result = Holidays.on(Date.new(2019, 11, 1), :multiple_with_conflict_2)
74
- assert_equal 1, result.count
75
- assert_equal 'With Function Only Same Function Name', result.first[:name]
76
- end
77
-
78
- # Both regions define holidays with the same custom function name but
79
- # different Ruby logic and different holiday names. Because the names differ,
80
- # holidays_by_month keeps them as separate entries (no region merge). Conflict
81
- # resolution must still route each holiday to its own function implementation.
82
- def test_custom_loaded_region_returns_correct_value_when_function_name_is_shared_but_holiday_names_differ
83
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_1.yaml')
84
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_2.yaml')
85
-
86
- result = Holidays.on(Date.new(2019, 9, 15), :multiple_with_conflict_1)
87
- assert_equal 1, result.count
88
- assert_equal 'With Function Only Same Function Name - Region 1', result.first[:name]
89
-
90
- result = Holidays.on(Date.new(2019, 11, 15), :multiple_with_conflict_2)
91
- assert_equal 1, result.count
92
- assert_equal 'With Function Only Same Function Name - Region 2', result.first[:name]
93
- end
94
-
95
- # When two regions are queried together and both have a holiday that uses the
96
- # same function name but different logic, the search must evaluate the function
97
- # independently for each queried region and return the union of all matches.
98
- def test_simultaneous_multi_region_query_evaluates_each_region_function_independently
99
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_1.yaml')
100
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_2.yaml')
101
-
102
- result = Holidays.on(Date.new(2019, 11, 1), :multiple_with_conflict_1, :multiple_with_conflict_2)
103
- assert_equal 1, result.count
104
- assert_equal 'With Function Only Same Function Name', result.first[:name]
105
-
106
- result = Holidays.on(Date.new(2019, 9, 1), :multiple_with_conflict_1, :multiple_with_conflict_2)
107
- assert_equal 1, result.count
108
- assert_equal 'With Function Only Same Function Name', result.first[:name]
109
- end
110
-
111
- # https://www.github.com/holidays/holidays/issues/344 scenario: two regions
112
- # share a function name but each implements it differently, so a single between() call
113
- # spanning both result dates must return one holiday entry per region.
114
- #
115
- # Region 1's function returns Sept 1; region 2's function returns Nov 1.
116
- # Querying Sept 1 to Nov 1 with both regions should produce two separate
117
- # 'With Function Only Same Function Name' entries, one per region.
118
- def test_simultaneous_multi_region_query_returns_one_result_per_region_in_a_single_call
119
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_1.yaml')
120
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_2.yaml')
121
-
122
- result = Holidays.between(
123
- Date.new(2019, 9, 1),
124
- Date.new(2019, 11, 1),
125
- :multiple_with_conflict_1,
126
- :multiple_with_conflict_2,
127
- )
128
-
129
- matching = result.select { |h| h[:name] == 'With Function Only Same Function Name' }
130
- assert_equal 2, matching.count
131
- assert matching.any? { |h| h[:date] == Date.new(2019, 9, 1) }, 'expected region 1 result on Sept 1'
132
- assert matching.any? { |h| h[:date] == Date.new(2019, 11, 1) }, 'expected region 2 result on Nov 1'
133
- end
134
-
135
- # Tests the conflict resolution path for functions that take a date argument
136
- # and return a shifted date, as opposed to functions that return a fixed date
137
- # for a given year. This is the canonical scenario from https://www.github.com/holidays/holidays/issues/344:
138
- # two regions define the same function name with different shift logic.
139
- #
140
- # Region 1: shifts Jan 1 to the nearest upcoming Saturday.
141
- # Region 2: shifts Jan 1 to the nearest upcoming Sunday.
142
- #
143
- # Jan 1, 2025 is a Wednesday, so:
144
- # Region 1 -> Jan 4, 2025 (Saturday, +3 days)
145
- # Region 2 -> Jan 5, 2025 (Sunday, +4 days)
146
- def test_date_transforming_functions_with_conflicting_logic_are_each_evaluated_independently
147
- Holidays.load_custom('test/data/test_date_transform_conflict_region_1.yaml')
148
- Holidays.load_custom('test/data/test_date_transform_conflict_region_2.yaml')
149
-
150
- # Single-region: each region resolves to its own shifted date.
151
- result = Holidays.on(Date.new(2025, 1, 4), :date_transform_conflict_1)
152
- assert_equal 1, result.count
153
- assert_equal 'Weekend Holiday', result.first[:name]
154
-
155
- result = Holidays.on(Date.new(2025, 1, 5), :date_transform_conflict_2)
156
- assert_equal 1, result.count
157
- assert_equal 'Weekend Holiday', result.first[:name]
158
-
159
- # Multi-region: a single call spanning both shifted dates must return one
160
- # result per region, each evaluated with its own function logic.
161
- result = Holidays.between(
162
- Date.new(2025, 1, 4),
163
- Date.new(2025, 1, 5),
164
- :date_transform_conflict_1,
165
- :date_transform_conflict_2,
166
- )
167
-
168
- matching = result.select { |h| h[:name] == 'Weekend Holiday' }
169
- assert_equal 2, matching.count
170
- assert matching.any? { |h| h[:date] == Date.new(2025, 1, 4) }, 'expected region 1 result on Jan 4 (Saturday)'
171
- assert matching.any? { |h| h[:date] == Date.new(2025, 1, 5) }, 'expected region 2 result on Jan 5 (Sunday)'
172
- end
173
-
174
- # Three regions all share the same function name but each implements it with
175
- # different logic (region 1 -> Sept 1, region 2 -> Nov 1, region 3 -> Mar 1).
176
- # After all three are loaded, every region must still resolve to its own date.
177
- def test_three_regions_with_same_function_name_each_return_correct_result
178
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_1.yaml')
179
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_2.yaml')
180
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_3.yaml')
181
-
182
- result = Holidays.on(Date.new(2019, 9, 1), :multiple_with_conflict_1)
183
- assert_equal 1, result.count
184
- assert_equal 'With Function Only Same Function Name', result.first[:name]
185
-
186
- result = Holidays.on(Date.new(2019, 11, 1), :multiple_with_conflict_2)
187
- assert_equal 1, result.count
188
- assert_equal 'With Function Only Same Function Name', result.first[:name]
189
-
190
- result = Holidays.on(Date.new(2019, 3, 1), :multiple_with_conflict_3)
191
- assert_equal 1, result.count
192
- assert_equal 'With Function Only Same Function Name', result.first[:name]
193
- end
194
-
195
- # A single between() call across all three regions must return one result per
196
- # region, each evaluated with its own function implementation.
197
- def test_simultaneous_three_region_query_returns_one_result_per_region
198
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_1.yaml')
199
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_2.yaml')
200
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_3.yaml')
201
-
202
- result = Holidays.between(
203
- Date.new(2019, 3, 1),
204
- Date.new(2019, 11, 1),
205
- :multiple_with_conflict_1,
206
- :multiple_with_conflict_2,
207
- :multiple_with_conflict_3,
208
- )
209
-
210
- matching = result.select { |h| h[:name] == 'With Function Only Same Function Name' }
211
- assert_equal 3, matching.count
212
- assert matching.any? { |h| h[:date] == Date.new(2019, 3, 1) }, 'expected region 3 result on Mar 1'
213
- assert matching.any? { |h| h[:date] == Date.new(2019, 9, 1) }, 'expected region 1 result on Sept 1'
214
- assert matching.any? { |h| h[:date] == Date.new(2019, 11, 1) }, 'expected region 2 result on Nov 1'
215
- end
216
-
217
- # Verifies the safe-overwrite path in CustomMethods#add: when the same
218
- # source is added again the method is simply overwritten and the holiday
219
- # definition repo de-duplicates via uniq!, so exactly one result is returned.
220
- def test_loading_the_same_custom_file_twice_does_not_duplicate_or_break_results
221
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_1.yaml')
222
- Holidays.load_custom('test/e2e/data/test_multiple_regions_with_conflicts_region_1.yaml')
223
-
224
- result = Holidays.on(Date.new(2019, 9, 1), :multiple_with_conflict_1)
225
- assert_equal 1, result.count
226
- assert_equal 'With Function Only Same Function Name', result.first[:name]
227
- end
228
- end
@@ -1,25 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
3
-
4
- class NonstandardRegionsHolidaysTests < Test::Unit::TestCase
5
- def test_ecbtarget_christmas_day
6
- h = Holidays.on(Date.new(2018,12,25), :ecbtarget)
7
- assert_equal 'Christmas Day', h[0][:name]
8
- end
9
-
10
- def test_federalreserve_memorial_day
11
- h = Holidays.on(Date.new(2018,5,28), :federalreserve)
12
- assert_equal 'Memorial Day', h[0][:name]
13
-
14
- end
15
-
16
- def test_federalreservebanks_independence_day
17
- h = Holidays.on(Date.new(2019,7,4), :federalreservebanks, :observed)
18
- assert_equal 'Independence Day', h[0][:name]
19
- end
20
-
21
- def test_unitednations_international_day_of_families
22
- h = Holidays.on(Date.new(2021,5,15), :unitednations)
23
- assert_equal 'International Day of Families', h[0][:name]
24
- end
25
- end
@@ -1,122 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../../test_helper'
2
-
3
- require 'date'
4
- require 'holidays/core_extensions/date'
5
-
6
- class Date
7
- include Holidays::CoreExtensions::Date
8
- end
9
-
10
- class CoreExtensionDateTests < Test::Unit::TestCase
11
- def setup
12
- @date = Date.civil(2008,1,1)
13
- end
14
-
15
- def test_extending_date_class
16
- assert @date.respond_to?('holidays')
17
- assert @date.respond_to?('holiday?')
18
- end
19
-
20
- def test_extending_datetime_class
21
- dt = DateTime.civil(2008,1,1)
22
- assert dt.respond_to?('holidays')
23
- assert dt.respond_to?('holiday?')
24
- end
25
-
26
- def test_calculating_mdays
27
- # US Memorial day
28
- assert_equal 29, Date.calculate_mday(2006, 5, :last, 1)
29
- assert_equal 28, Date.calculate_mday(2007, 5, :last, 1)
30
- assert_equal 26, Date.calculate_mday(2008, 5, :last, 1)
31
- assert_equal 25, Date.calculate_mday(2009, 5, :last, 1)
32
- assert_equal 31, Date.calculate_mday(2010, 5, :last, 1)
33
- assert_equal 30, Date.calculate_mday(2011, 5, :last, 1)
34
-
35
- # Labour day
36
- assert_equal 3, Date.calculate_mday(2007, 9, :first, 1)
37
- assert_equal 1, Date.calculate_mday(2008, 9, :first, :monday)
38
- assert_equal 7, Date.calculate_mday(2009, 9, :first, 1)
39
- assert_equal 5, Date.calculate_mday(2011, 9, :first, 1)
40
- assert_equal 5, Date.calculate_mday(2050, 9, :first, 1)
41
- assert_equal 4, Date.calculate_mday(2051, 9, :first, 1)
42
-
43
- # Canadian thanksgiving
44
- assert_equal 8, Date.calculate_mday(2007, 10, :second, 1)
45
- assert_equal 13, Date.calculate_mday(2008, 10, :second, :monday)
46
- assert_equal 12, Date.calculate_mday(2009, 10, :second, 1)
47
- assert_equal 11, Date.calculate_mday(2010, 10, :second, 1)
48
-
49
- # Misc
50
- assert_equal 21, Date.calculate_mday(2008, 1, :third, 1)
51
- assert_equal 1, Date.calculate_mday(2007, 1, :first, 1)
52
- assert_equal 2, Date.calculate_mday(2007, 3, :first, :friday)
53
- assert_equal 30, Date.calculate_mday(2012, 1, :last, 1)
54
- assert_equal 29, Date.calculate_mday(2016, 2, :last, 1)
55
-
56
- # From end of month
57
- assert_equal 26, Date.calculate_mday(2009, 8, -1, :wednesday)
58
- assert_equal 19, Date.calculate_mday(2009, 8, -2, :wednesday)
59
- assert_equal 12, Date.calculate_mday(2009, 8, -3, :wednesday)
60
-
61
- assert_equal 13, Date.calculate_mday(2008, 8, -3, :wednesday)
62
- assert_equal 12, Date.calculate_mday(2009, 8, -3, :wednesday)
63
- assert_equal 11, Date.calculate_mday(2010, 8, -3, :wednesday)
64
- assert_equal 17, Date.calculate_mday(2011, 8, -3, :wednesday)
65
- assert_equal 15, Date.calculate_mday(2012, 8, -3, :wednesday)
66
- assert_equal 14, Date.calculate_mday(2013, 8, -3, :wednesday)
67
- end
68
-
69
- def test_mday_allows_integers_or_symbols
70
- assert_nothing_raised do
71
- Date.calculate_mday(2008, 1, 1, 1)
72
- end
73
-
74
- assert_nothing_raised do
75
- Date.calculate_mday(2008, 1, -1, 1)
76
- end
77
-
78
- assert_nothing_raised do
79
- Date.calculate_mday(2008, 1, :last, 1)
80
- end
81
- end
82
-
83
- def test_mday_requires_valid_week
84
- assert_raises ArgumentError do
85
- Date.calculate_mday(2008, 1, :none, 1)
86
- end
87
-
88
- assert_raises ArgumentError do
89
- Date.calculate_mday(2008, 1, nil, 1)
90
- end
91
-
92
- assert_raises ArgumentError do
93
- Date.calculate_mday(2008, 1, 0, 1)
94
- end
95
- end
96
-
97
- def test_mday_requires_valid_day
98
- assert_raises ArgumentError do
99
- Date.calculate_mday(2008, 1, 1, :october)
100
- end
101
-
102
- assert_raises ArgumentError do
103
- Date.calculate_mday(2008, 1, 1, nil)
104
- end
105
-
106
- assert_raises ArgumentError do
107
- Date.calculate_mday(2008, 1, 1, 7)
108
- end
109
- end
110
-
111
- def test_date_holiday?
112
- assert Date.civil(2008,1,1).holiday?('ca')
113
- assert Date.today.holiday?('test')
114
- end
115
-
116
- def test_datetime_holiday?
117
- # in situations with activesupport
118
- assert DateTime.civil(2008, 1, 1).to_date.holiday?('ca')
119
- assert DateTime.civil(2008, 1, 1).holiday?('ca')
120
- end
121
-
122
- end
@@ -1,60 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../../test_helper'
2
-
3
- require 'holidays/core_extensions/date'
4
- require 'holidays/core_extensions/time'
5
-
6
- class Date
7
- include Holidays::CoreExtensions::Date
8
- end
9
-
10
- class Time
11
- include Holidays::CoreExtensions::Time
12
- end
13
-
14
- class CoreExtensionDateTimeTests < Test::Unit::TestCase
15
- def setup
16
- @date = Date.civil(2008,1,1)
17
- end
18
-
19
- def test_change_method
20
- actual = @date.change(day: 5)
21
- assert_equal Date.civil(2008,1,5), actual
22
-
23
- actual = @date.change(year: 2016)
24
- assert_equal Date.civil(2016,1,1), actual
25
-
26
- actual = @date.change(month: 5)
27
- assert_equal Date.civil(2008,5,1), actual
28
-
29
- actual = @date.change(year: 2015, month: 5, day: 3)
30
- assert_equal Date.civil(2015,5,3), actual
31
- end
32
-
33
- def test_end_of_month_method
34
- # Works for month with 31 days
35
- actual = @date.end_of_month
36
- assert_equal Date.civil(2008,1,31), actual
37
-
38
- # Works for month with 30 days
39
- actual = Date.civil(2008,9,5).end_of_month
40
- assert_equal Date.civil(2008,9,30), actual
41
-
42
- # Works for leap year
43
- actual = Date.civil(2016,2,1).end_of_month
44
- assert_equal Date.civil(2016,2,29), actual
45
- end
46
-
47
- def test_days_in_month_method
48
- # Works for month with 31 days
49
- actual = Time.days_in_month(1, 2008)
50
- assert_equal 31, actual
51
-
52
- # Works for month with 30 days
53
- actual = Time.days_in_month(9, 2008)
54
- assert_equal 30, actual
55
-
56
- # Works for leap year
57
- actual = Time.days_in_month(2, 2016)
58
- assert_equal 29, actual
59
- end
60
- end
@@ -1,27 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../../test_helper'
2
-
3
- require 'holidays/date_calculator/day_of_month'
4
-
5
- class DayOfMonthDateCalculatorTests < Test::Unit::TestCase
6
- def setup
7
- @subject = Holidays::DateCalculator::DayOfMonth.new
8
- end
9
-
10
- def test_call_returns_expected_results
11
- assert_equal 7, @subject.call(2008, 1, :first, :monday)
12
- assert_equal 18, @subject.call(2008, 12, :third, :thursday)
13
- assert_equal 28, @subject.call(2008, 1, :last, 1)
14
- end
15
-
16
- def test_returns_argument_error_with_invalid_week_parameter
17
- assert_raises ArgumentError do
18
- @subject.call(2008, 1, :wrong_week_argument, :monday)
19
- end
20
- end
21
-
22
- def test_returns_argument_error_with_invalid_day_parameter
23
- assert_raises ArgumentError do
24
- @subject.call(2008, 1, :first, :bad_wday)
25
- end
26
- end
27
- end
@@ -1,30 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../../test_helper'
2
-
3
- require 'holidays/date_calculator/easter'
4
-
5
- class GregorianEasterDateCalculatorTests < Test::Unit::TestCase
6
- def setup
7
- @subject = Holidays::DateCalculator::Easter::Gregorian.new
8
- end
9
-
10
- def test_calculate_easter_for_returns_expected_results
11
- assert_equal '0960-04-20', @subject.calculate_easter_for(960).to_s
12
- assert_equal '1800-04-13', @subject.calculate_easter_for(1800).to_s
13
- assert_equal '1899-04-02', @subject.calculate_easter_for(1899).to_s
14
- assert_equal '1900-04-15', @subject.calculate_easter_for(1900).to_s
15
- assert_equal '1999-04-04', @subject.calculate_easter_for(1999).to_s
16
- assert_equal '2000-04-23', @subject.calculate_easter_for(2000).to_s
17
- assert_equal '2025-04-20', @subject.calculate_easter_for(2025).to_s
18
- assert_equal '2035-03-25', @subject.calculate_easter_for(2035).to_s
19
- assert_equal '2067-04-03', @subject.calculate_easter_for(2067).to_s
20
- assert_equal '2099-04-12', @subject.calculate_easter_for(2099).to_s
21
- end
22
-
23
- def test_calculate_orthodox_easter_for_returns_expects_results
24
- assert_equal '2000-04-30', @subject.calculate_orthodox_easter_for(2000).to_s
25
- assert_equal '2008-04-27', @subject.calculate_orthodox_easter_for(2008).to_s
26
- assert_equal '2009-04-19', @subject.calculate_orthodox_easter_for(2009).to_s
27
- assert_equal '2011-04-24', @subject.calculate_orthodox_easter_for(2011).to_s
28
- assert_equal '2020-04-19', @subject.calculate_orthodox_easter_for(2020).to_s
29
- end
30
- end
@@ -1,36 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../../test_helper'
2
-
3
- require 'holidays/date_calculator/easter'
4
-
5
- class JulianEasterDateCalculatorTests < Test::Unit::TestCase
6
- def setup
7
- @subject = Holidays::DateCalculator::Easter::Julian.new
8
- end
9
-
10
- def test_calculate_easter_for_returns_expected_results
11
- assert_equal '0960-04-20', @subject.calculate_easter_for(960).to_s
12
- assert_equal '1800-04-13', @subject.calculate_easter_for(1800).to_s
13
- assert_equal '1899-04-02', @subject.calculate_easter_for(1899).to_s
14
- assert_equal '1900-04-15', @subject.calculate_easter_for(1900).to_s
15
- assert_equal '1999-04-04', @subject.calculate_easter_for(1999).to_s
16
- assert_equal '2000-04-23', @subject.calculate_easter_for(2000).to_s
17
- assert_equal '2025-04-20', @subject.calculate_easter_for(2025).to_s
18
- assert_equal '2035-03-25', @subject.calculate_easter_for(2035).to_s
19
- assert_equal '2067-04-03', @subject.calculate_easter_for(2067).to_s
20
- assert_equal '2099-04-12', @subject.calculate_easter_for(2099).to_s
21
- end
22
-
23
- def test_calculate_orthodox_easter_for_returns_expects_results
24
- assert_equal '0960-04-22', @subject.calculate_orthodox_easter_for(960).to_s
25
- assert_equal '1500-04-19', @subject.calculate_orthodox_easter_for(1500).to_s
26
- assert_equal '2000-04-17', @subject.calculate_orthodox_easter_for(2000).to_s
27
- assert_equal '2001-04-02', @subject.calculate_orthodox_easter_for(2001).to_s
28
- assert_equal '2015-03-30', @subject.calculate_orthodox_easter_for(2015).to_s
29
- assert_equal '2016-04-18', @subject.calculate_orthodox_easter_for(2016).to_s
30
- assert_equal '2017-04-03', @subject.calculate_orthodox_easter_for(2017).to_s
31
- assert_equal '2020-04-06', @subject.calculate_orthodox_easter_for(2020).to_s
32
- assert_equal '2050-04-04', @subject.calculate_orthodox_easter_for(2050).to_s
33
- assert_equal '2100-04-18', @subject.calculate_orthodox_easter_for(2100).to_s
34
- assert_equal '2500-04-08', @subject.calculate_orthodox_easter_for(2500).to_s
35
- end
36
- end
@@ -1,89 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../../test_helper'
2
-
3
- require 'holidays/date_calculator/lunar_date.rb'
4
-
5
- class LunarHolidaysCalculatorTests < Test::Unit::TestCase
6
- def setup
7
- @subject = Holidays::DateCalculator::LunarDate.new
8
- end
9
-
10
- def test_korean_new_year_returns_expected_results
11
- assert_equal '1994-02-10', @subject.to_solar(1994,1,1, :kr).to_s
12
- assert_equal '1995-01-31', @subject.to_solar(1995,1,1, :kr).to_s
13
- assert_equal '1999-02-16', @subject.to_solar(1999,1,1, :kr).to_s
14
- assert_equal '2000-02-05', @subject.to_solar(2000,1,1, :kr).to_s
15
- assert_equal '2001-01-24', @subject.to_solar(2001,1,1, :kr).to_s
16
- assert_equal '2002-02-12', @subject.to_solar(2002,1,1, :kr).to_s
17
- assert_equal '2008-02-07', @subject.to_solar(2008,1,1, :kr).to_s
18
- assert_equal '2009-01-26', @subject.to_solar(2009,1,1, :kr).to_s
19
- assert_equal '2010-02-14', @subject.to_solar(2010,1,1, :kr).to_s
20
- assert_equal '2011-02-03', @subject.to_solar(2011,1,1, :kr).to_s
21
- assert_equal '2012-01-23', @subject.to_solar(2012,1,1, :kr).to_s
22
- assert_equal '2013-02-10', @subject.to_solar(2013,1,1, :kr).to_s
23
- assert_equal '2014-01-31', @subject.to_solar(2014,1,1, :kr).to_s
24
- assert_equal '2015-02-19', @subject.to_solar(2015,1,1, :kr).to_s
25
- assert_equal '2016-02-08', @subject.to_solar(2016,1,1, :kr).to_s
26
- assert_equal '2017-01-28', @subject.to_solar(2017,1,1, :kr).to_s
27
- assert_equal '2018-02-16', @subject.to_solar(2018,1,1, :kr).to_s
28
- assert_equal '2019-02-05', @subject.to_solar(2019,1,1, :kr).to_s
29
- assert_equal '2020-01-25', @subject.to_solar(2020,1,1, :kr).to_s
30
- assert_equal '2022-02-01', @subject.to_solar(2022,1,1, :kr).to_s
31
- assert_equal '2025-01-29', @subject.to_solar(2025,1,1, :kr).to_s
32
- end
33
-
34
- def test_buddahs_birthday_returns_expected_results
35
- assert_equal '1994-05-18', @subject.to_solar(1994,4,8, :kr).to_s
36
- assert_equal '1995-05-07', @subject.to_solar(1995,4,8, :kr).to_s
37
- assert_equal '1999-05-22', @subject.to_solar(1999,4,8, :kr).to_s
38
- assert_equal '2000-05-11', @subject.to_solar(2000,4,8, :kr).to_s
39
- assert_equal '2001-05-01', @subject.to_solar(2001,4,8, :kr).to_s
40
- assert_equal '2002-05-19', @subject.to_solar(2002,4,8, :kr).to_s
41
- assert_equal '2008-05-12', @subject.to_solar(2008,4,8, :kr).to_s
42
- assert_equal '2009-05-02', @subject.to_solar(2009,4,8, :kr).to_s
43
- assert_equal '2010-05-21', @subject.to_solar(2010,4,8, :kr).to_s
44
- assert_equal '2011-05-10', @subject.to_solar(2011,4,8, :kr).to_s
45
- assert_equal '2012-05-28', @subject.to_solar(2012,4,8, :kr).to_s
46
- assert_equal '2013-05-17', @subject.to_solar(2013,4,8, :kr).to_s
47
- assert_equal '2014-05-06', @subject.to_solar(2014,4,8, :kr).to_s
48
- assert_equal '2015-05-25', @subject.to_solar(2015,4,8, :kr).to_s
49
- assert_equal '2016-05-14', @subject.to_solar(2016,4,8, :kr).to_s
50
- assert_equal '2017-05-03', @subject.to_solar(2017,4,8, :kr).to_s
51
- assert_equal '2018-05-22', @subject.to_solar(2018,4,8, :kr).to_s
52
- assert_equal '2019-05-12', @subject.to_solar(2019,4,8, :kr).to_s
53
- assert_equal '2020-04-30', @subject.to_solar(2020,4,8, :kr).to_s
54
- assert_equal '2022-05-08', @subject.to_solar(2022,4,8, :kr).to_s
55
- assert_equal '2025-05-05', @subject.to_solar(2025,4,8, :kr).to_s
56
- end
57
-
58
- def test_korean_thanksgiving_returns_expected_results
59
- assert_equal '1994-09-20', @subject.to_solar(1994,8,15, :kr).to_s
60
- assert_equal '1995-09-09', @subject.to_solar(1995,8,15, :kr).to_s
61
- assert_equal '1999-09-24', @subject.to_solar(1999,8,15, :kr).to_s
62
- assert_equal '2000-09-12', @subject.to_solar(2000,8,15, :kr).to_s
63
- assert_equal '2001-10-01', @subject.to_solar(2001,8,15, :kr).to_s
64
- assert_equal '2002-09-21', @subject.to_solar(2002,8,15, :kr).to_s
65
- assert_equal '2008-09-14', @subject.to_solar(2008,8,15, :kr).to_s
66
- assert_equal '2009-10-03', @subject.to_solar(2009,8,15, :kr).to_s
67
- assert_equal '2010-09-22', @subject.to_solar(2010,8,15, :kr).to_s
68
- assert_equal '2011-09-12', @subject.to_solar(2011,8,15, :kr).to_s
69
- assert_equal '2012-09-30', @subject.to_solar(2012,8,15, :kr).to_s
70
- assert_equal '2013-09-19', @subject.to_solar(2013,8,15, :kr).to_s
71
- assert_equal '2014-09-08', @subject.to_solar(2014,8,15, :kr).to_s
72
- assert_equal '2015-09-27', @subject.to_solar(2015,8,15, :kr).to_s
73
- assert_equal '2016-09-15', @subject.to_solar(2016,8,15, :kr).to_s
74
- assert_equal '2017-10-04', @subject.to_solar(2017,8,15, :kr).to_s
75
- assert_equal '2018-09-24', @subject.to_solar(2018,8,15, :kr).to_s
76
- assert_equal '2019-09-13', @subject.to_solar(2019,8,15, :kr).to_s
77
- assert_equal '2020-10-01', @subject.to_solar(2020,8,15, :kr).to_s
78
- assert_equal '2022-09-10', @subject.to_solar(2022,8,15, :kr).to_s
79
- assert_equal '2025-10-06', @subject.to_solar(2025,8,15, :kr).to_s
80
- end
81
-
82
- def test_hung_kings_festival_returns_expected_results
83
- assert_equal '2014-04-09', @subject.to_solar(2014,3,10, :vi).to_s
84
- assert_equal '2015-04-28', @subject.to_solar(2015,3,10, :vi).to_s
85
- assert_equal '2016-04-16', @subject.to_solar(2016,3,10, :vi).to_s
86
- assert_equal '2017-04-06', @subject.to_solar(2017,3,10, :vi).to_s
87
- assert_equal '2018-03-27', @subject.to_solar(2018,3,10, :vi).to_s
88
- end
89
- end