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,202 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../../../test_helper'
2
-
3
- require 'holidays/finder/context/year_holiday'
4
-
5
- class YearHolidayTests < Test::Unit::TestCase
6
- def setup
7
- @regions = [:us]
8
- @observed = false
9
- @informal = false
10
-
11
- @definition_search = mock()
12
- @dates_driver_builder = mock()
13
- @options_parser = mock()
14
-
15
- @subject = Holidays::Finder::Context::YearHoliday.new(
16
- @definition_search,
17
- @dates_driver_builder,
18
- @options_parser,
19
- )
20
-
21
- @from_date= Date.civil(2015, 1, 1)
22
- @dates_driver = {2015 => [0, 1, 2], 2014 => [0, 12]}
23
- @options = [@regions, @observed, @informal]
24
-
25
- @definition_search.expects(:call).at_most_once.with(
26
- @dates_driver,
27
- @regions,
28
- [],
29
- ).returns([{
30
- :date => Date.civil(2015, 1, 1),
31
- :name => "Test",
32
- :regions => [:us],
33
- }])
34
-
35
- @dates_driver_builder.expects(:call).at_most_once.with(
36
- @from_date, @from_date >> 12,
37
- ).returns(
38
- @dates_driver,
39
- )
40
-
41
- @options_parser.expects(:call).at_most_once.with(@options).returns(@options)
42
- end
43
-
44
- def test_returns_error_if_from_date_is_missing
45
- assert_raise ArgumentError do
46
- @subject.call(nil, @options)
47
- end
48
- end
49
-
50
- def test_returns_error_if_from_date_is_not_a_date
51
- assert_raise ArgumentError do
52
- @subject.call("2015-1-1", @options)
53
- end
54
- end
55
-
56
- def test_returns_single_holiday
57
- assert_equal(
58
- [
59
- {
60
- :date => Date.civil(2015, 1, 1),
61
- :name => "Test",
62
- :regions => [:us],
63
- }
64
- ],
65
- @subject.call(@from_date, @options)
66
- )
67
- end
68
-
69
- def test_returns_multiple_holidays_in_a_year
70
- @definition_search.expects(:call).at_most_once.with(
71
- @dates_driver,
72
- @regions,
73
- [],
74
- ).returns([
75
- {
76
- :date => Date.civil(2015, 1, 1),
77
- :name => "Test",
78
- :regions => [:us],
79
- },
80
- {
81
- :date => Date.civil(2015, 2, 1),
82
- :name => "Test",
83
- :regions => [:us],
84
- },
85
- {
86
- :date => Date.civil(2015, 12, 1),
87
- :name => "Test",
88
- :regions => [:us],
89
- },
90
- ]
91
- )
92
-
93
- assert_equal(
94
- [
95
- {
96
- :date => Date.civil(2015, 1, 1),
97
- :name => "Test",
98
- :regions => [:us],
99
- },
100
- {
101
- :date => Date.civil(2015, 2, 1),
102
- :name => "Test",
103
- :regions => [:us],
104
- },
105
- {
106
- :date => Date.civil(2015, 12, 1),
107
- :name => "Test",
108
- :regions => [:us],
109
- }
110
- ],
111
- @subject.call(@from_date, @options)
112
- )
113
- end
114
-
115
- def test_returns_multiple_holidays_filters_dates_outside_of_year
116
- @definition_search.expects(:call).at_most_once.with(
117
- @dates_driver,
118
- @regions,
119
- [],
120
- ).returns([
121
- {
122
- :date => Date.civil(2015, 1, 1),
123
- :name => "Test",
124
- :regions => [:us],
125
- },
126
- {
127
- :date => Date.civil(2015, 2, 1),
128
- :name => "Test",
129
- :regions => [:us],
130
- },
131
- {
132
- :date => Date.civil(2016, 12, 1),
133
- :name => "Test",
134
- :regions => [:us],
135
- },
136
- ]
137
- )
138
-
139
- assert_equal(
140
- [
141
- {
142
- :date => Date.civil(2015, 1, 1),
143
- :name => "Test",
144
- :regions => [:us],
145
- },
146
- {
147
- :date => Date.civil(2015, 2, 1),
148
- :name => "Test",
149
- :regions => [:us],
150
- },
151
- ],
152
- @subject.call(@from_date, @options)
153
- )
154
- end
155
-
156
- def test_returns_sorted_multiple_holidays
157
- @definition_search.expects(:call).at_most_once.with(
158
- @dates_driver,
159
- @regions,
160
- [],
161
- ).returns(
162
- [
163
- {
164
- :date => Date.civil(2015, 1, 1),
165
- :name => "Test",
166
- :regions => [:us],
167
- },
168
- {
169
- :date => Date.civil(2015, 12, 1),
170
- :name => "Test",
171
- :regions => [:us],
172
- },
173
- {
174
- :date => Date.civil(2015, 2, 1),
175
- :name => "Test",
176
- :regions => [:us],
177
- },
178
- ]
179
- )
180
-
181
- assert_equal(
182
- [
183
- {
184
- :date => Date.civil(2015, 1, 1),
185
- :name => "Test",
186
- :regions => [:us],
187
- },
188
- {
189
- :date => Date.civil(2015, 2, 1),
190
- :name => "Test",
191
- :regions => [:us],
192
- },
193
- {
194
- :date => Date.civil(2015, 12, 1),
195
- :name => "Test",
196
- :regions => [:us],
197
- }
198
- ],
199
- @subject.call(@from_date, @options)
200
- )
201
- end
202
- end
@@ -1,42 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../../../test_helper'
2
-
3
- require 'holidays/finder/rules/in_region'
4
-
5
- class FinderRulesInRegionTests < Test::Unit::TestCase
6
- def setup
7
- @available = [:test]
8
- @subject = Holidays::Finder::Rules::InRegion
9
- end
10
-
11
- def test_returns_true_if_any_specified
12
- assert_equal(true, @subject.call([:any], @available))
13
- end
14
-
15
- def test_returns_true_if_exact_match_found
16
- assert_equal(true, @subject.call([:test], @available))
17
- end
18
-
19
- def test_returns_true_if_subregion_matches_parent
20
- assert_equal(true, @subject.call([:test_sub], @available))
21
- end
22
-
23
- def test_returns_true_if_subregion_matches_grandparent
24
- assert_equal(true, @subject.call([:test_sub_sub], @available))
25
- end
26
-
27
- def test_returns_true_if_subregion_is_in_available
28
- assert_equal(true, @subject.call([:test_sub], [:test, :test_sub]))
29
- end
30
-
31
- def test_returns_false_if_match_not_found
32
- assert_equal(false, @subject.call([:other], @available))
33
- end
34
-
35
- def test_returns_false_if_match_not_found_for_subregion
36
- assert_equal(false, @subject.call([:other_sub], @available))
37
- end
38
-
39
- def test_returns_true_if_request_includes_nonmatching_but_also_any
40
- assert_equal(true, @subject.call([:other_sub, :other, :any], @available))
41
- end
42
- end
@@ -1,166 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../../../test_helper'
2
-
3
- require 'holidays/finder/rules/year_range'
4
-
5
- class FinderRulesYearRangeTests < Test::Unit::TestCase
6
- def setup
7
- @year = 2015
8
- @year_ranges = {between: 1996..2002}
9
- @subject = Holidays::Finder::Rules::YearRange
10
- end
11
-
12
- def test_returns_error_if_target_year_is_missing
13
- assert_raises ArgumentError do
14
- @subject.call(nil, @year_ranges)
15
- end
16
- end
17
-
18
- def test_returns_error_if_target_year_is_not_a_number
19
- assert_raises ArgumentError do
20
- @subject.call("test", @year_ranges)
21
- end
22
- end
23
-
24
- def test_returns_error_if_year_ranges_if_nil
25
- @year_ranges = []
26
- assert_raises ArgumentError do
27
- @subject.call(@year, nil)
28
- end
29
- end
30
-
31
- def test_returns_error_if_year_ranges_contains_only_non_hash
32
- @year_ranges = :test
33
- assert_raises ArgumentError do
34
- @subject.call(@year, @year_ranges)
35
- end
36
- end
37
-
38
- def test_returns_error_if_year_ranges_is_empty
39
- @year_ranges = [{}, {}]
40
- assert_raises ArgumentError do
41
- @subject.call(@year, @year_ranges)
42
- end
43
- end
44
-
45
- def test_returns_error_if_year_range_contains_a_hash_with_multiple_entries
46
- @year_ranges = {:between => 1996..2002, :after => 2002}
47
- assert_raises ArgumentError do
48
- @subject.call(@year, @year_ranges)
49
- end
50
- end
51
-
52
- def test_returns_error_if_year_range_contains_unrecognized_operator
53
- @year_ranges = {:what => 2002}
54
- assert_raises ArgumentError do
55
- @subject.call(@year, @year_ranges)
56
- end
57
- end
58
-
59
- def test_returns_error_if_until_operator_and_value_is_not_a_number
60
- @year_ranges = {until: "bad"}
61
- assert_raises ArgumentError do
62
- @subject.call(@year, @year_ranges)
63
- end
64
- end
65
-
66
- def test_returns_true_if_until_operator_and_target_is_until
67
- @year_ranges = {until: 2000}
68
- assert_equal(true, @subject.call(1999, @year_ranges))
69
- end
70
-
71
- def test_returns_true_if_until_operator_and_target_is_equal
72
- @year_ranges = {until: 2000}
73
- assert_equal(true, @subject.call(2000, @year_ranges))
74
- end
75
-
76
- def test_returns_false_if_until_operator_and_target_is_after
77
- @year_ranges = {until: 2000}
78
- assert_equal(false, @subject.call(2001, @year_ranges))
79
- end
80
-
81
- def test_returns_error_if_from_operator_with_bad_value
82
- @year_ranges = {from: "bad"}
83
- assert_raises ArgumentError do
84
- @subject.call(@year, @year_ranges)
85
- end
86
- end
87
-
88
- def test_returns_false_if_from_operator_and_target_is_before
89
- @year_ranges = {from: 2000}
90
- assert_equal(false, @subject.call(1999, @year_ranges))
91
- end
92
-
93
- def test_returns_true_if_from_operator_and_target_is_equal
94
- @year_ranges = {from: 2000}
95
- assert_equal(true, @subject.call(2000, @year_ranges))
96
- end
97
-
98
- def test_returns_true_if_from_operator_and_target_is_after
99
- @year_ranges = {from: 2000}
100
- assert_equal(true, @subject.call(2001, @year_ranges))
101
- end
102
-
103
- def test_returns_error_if_limited_operator_and_bad_value
104
- @year_ranges = {limited: "bad"}
105
- assert_raises ArgumentError do
106
- @subject.call(@year, @year_ranges)
107
- end
108
- end
109
-
110
- def test_returns_error_if_limited_operator_with_empty_array
111
- @year_ranges = {limited: []}
112
- assert_raises ArgumentError do
113
- @subject.call(@year, @year_ranges)
114
- end
115
- end
116
-
117
- def test_returns_error_if_limited_operator_with_array_containing_non_integer_value
118
- @year_ranges = {limited: ["bad"]}
119
- assert_raises ArgumentError do
120
- @subject.call(@year, @year_ranges)
121
- end
122
- end
123
-
124
- def test_returns_true_if_limited_operator_and_value_is_number_that_matches_target
125
- @year_ranges = {limited: [2002]}
126
- assert_equal(true, @subject.call(2002, @year_ranges))
127
- end
128
-
129
- def test_returns_false_if_limited_operator_and_target_is_not_included
130
- @year_ranges = {limited: [1998,2000]}
131
- assert_equal(false, @subject.call(1997, @year_ranges))
132
- assert_equal(false, @subject.call(1999, @year_ranges))
133
- assert_equal(false, @subject.call(2002, @year_ranges))
134
- end
135
-
136
- def test_returns_true_if_limited_operator_and_target_is_included
137
- @year_ranges = {limited: [1998, 2000, 2002]}
138
- assert_equal(true, @subject.call(1998, @year_ranges))
139
- assert_equal(true, @subject.call(2000, @year_ranges))
140
- assert_equal(true, @subject.call(2002, @year_ranges))
141
- end
142
-
143
- def test_returns_error_if_between_operator_and_value_not_a_range
144
- @year_ranges = {between: 2000}
145
- assert_raises ArgumentError do
146
- @subject.call(2003, @year_ranges)
147
- end
148
- end
149
-
150
- def test_returns_false_if_between_operator_and_target_is_before
151
- @year_ranges = {between: 1998..2002}
152
- assert_equal(false, @subject.call(1997, @year_ranges))
153
- end
154
-
155
- def test_returns_true_if_between_operator_and_target_is_covered
156
- @year_ranges = {between: 1998..2002}
157
- assert_equal(true, @subject.call(1998, @year_ranges))
158
- assert_equal(true, @subject.call(2000, @year_ranges))
159
- assert_equal(true, @subject.call(2002, @year_ranges))
160
- end
161
-
162
- def test_returns_false_if_between_operator_and_target_is_after
163
- @year_ranges = {between: 1998..2002}
164
- assert_equal(false, @subject.call(2003, @year_ranges))
165
- end
166
- end
@@ -1,48 +0,0 @@
1
- # Integration tests
2
-
3
- True gem integration tests that verify how the gem's components work together
4
- (loader, calculator, observed-date logic, sub-region inheritance, caching, etc.)
5
- using **local fixture YAMLs**. Integration-only fixtures live in
6
- `test/integration/data/`. Fixtures shared with other test categories live in
7
- `test/data/`.
8
-
9
- ## Purpose
10
-
11
- These tests pin specific inputs (the fixture YAMLs) and assert specific outputs,
12
- so they verify gem behavior independently of whatever the upstream definitions
13
- repo currently ships. They do not break when upstream definitions change.
14
-
15
- ## Integration tests vs. unit tests
16
-
17
- Unit tests live alongside the code they cover and verify a single file or
18
- class in isolation. They are the right place for testing the internals of one
19
- specific component (e.g. a date calculator, a custom method validator) with
20
- mocks and minimal setup.
21
-
22
- Integration tests in this directory are the opposite: they wire multiple gem
23
- components together and verify that they cooperate correctly across the full
24
- parse → calculate → return pipeline. If you are testing one file's internal
25
- behavior, write a unit test. If you are testing how several pieces of the gem
26
- behave together against a known input, write an integration test here.
27
-
28
- ## What belongs here
29
-
30
- - Tests that exercise gem internals end-to-end (parsing, calculation, output)
31
- using controlled inputs from `test/integration/data/` (or `test/data/` for
32
- fixtures shared with other test categories).
33
- - Tests for custom-method evaluation, year-range handling, informal flag
34
- filtering, observed-date shifting, sub-region inheritance, etc., using fixtures.
35
-
36
- ## What does NOT belong here
37
-
38
- - Any test that loads or asserts against real definitions in `/definitions`.
39
- Those belong in `e2e/`.
40
- - Pure structural checks that don't assert specific behavior. Those belong in
41
- `smoke/`.
42
- - Tests of a single file or class in isolation. Those are unit tests and belong
43
- next to the code they cover.
44
-
45
- The advantage of fixture-based tests: a definitions change cannot break them.
46
- If you find yourself writing a test that needs to load `:ca` or `:us` directly,
47
- ask whether the same behavior could be tested with a small fixture YAML, and
48
- if so, write the fixture instead.
@@ -1,5 +0,0 @@
1
- months:
2
- 3:
3
- - name: Yaaay Government Day
4
- regions: [custom_multiple_files, custom_multiple_files_govt]
5
- mday: 1
@@ -1,11 +0,0 @@
1
- ---
2
- months:
3
- 1:
4
- - name: informal day with type as string
5
- regions: [custom_informal]
6
- mday: 1
7
- type: informal
8
- - name: informal day with type as symbol
9
- regions: [custom_informal]
10
- mday: 5
11
- type: :informal
@@ -1,12 +0,0 @@
1
- months:
2
- 10:
3
- - name: Company Founding!
4
- regions: [custom_multiple_files]
5
- mday: 5
6
-
7
- tests:
8
- - given:
9
- date: "2013-10-5"
10
- regions: ["custom_multiple_files"]
11
- expect:
12
- name: "Company Founding!"
@@ -1,41 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
-
3
- class CustomHolidaysTest < Test::Unit::TestCase
4
-
5
- def test_custom_region_present_after_single_file_parsing
6
- assert_raises Holidays::InvalidRegion do
7
- Holidays.on(Date.civil(2013,6,20), :custom_single_file)
8
- end
9
-
10
- Holidays.load_custom('test/data/test_single_custom_holiday_defs.yaml')
11
-
12
- assert_not_equal [], Holidays.on(Date.civil(2013,6,20), :custom_single_file)
13
- end
14
-
15
- def test_load_custom_returns_loaded_holidays
16
- expected_loaded_holidays = {6=>[{:mday=>20, :name=>"Company Founding", :regions=>[:custom_single_file]}]}
17
-
18
- assert_equal expected_loaded_holidays, Holidays.load_custom('test/data/test_single_custom_holiday_defs.yaml')
19
- end
20
-
21
- def test_custom_holidays_present_after_multiple_file_parsing
22
- assert_raises Holidays::InvalidRegion do
23
- Holidays.on(Date.civil(2013, 10,5), :custom_multiple_files)
24
- end
25
-
26
- assert_raises Holidays::InvalidRegion do
27
- Holidays.on(Date.civil(2013,3,1), :custom_multiple_files)
28
- end
29
-
30
- assert_raises Holidays::InvalidRegion do
31
- Holidays.on(Date.civil(2013,3,1), :custom_multiple_files_govt)
32
- end
33
-
34
- Holidays.load_custom('test/integration/data/test_multiple_custom_holiday_defs.yaml', 'test/integration/data/test_custom_govt_holiday_defs.yaml')
35
-
36
- assert_not_equal [], Holidays.on(Date.civil(2013,10,5), :custom_multiple_files)
37
- assert_not_equal [], Holidays.on(Date.civil(2013,3,1), :custom_multiple_files)
38
- assert_not_equal [], Holidays.on(Date.civil(2013,3,1), :custom_multiple_files_govt)
39
- end
40
-
41
- end
@@ -1,15 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
-
3
- class CustomHolidaysTest < Test::Unit::TestCase
4
-
5
- def test_custom_region_informal_day_parsing
6
- Holidays.load_custom('test/integration/data/test_custom_informal_holidays_defs.yaml')
7
-
8
- assert_not_equal [], Holidays.on(Date.new(2018,1,1), :custom_informal, :informal)
9
- assert_equal [], Holidays.on(Date.new(2018,1,1), :custom_informal, :observed)
10
-
11
- assert_not_equal [], Holidays.on(Date.new(2018,1,5), :custom_informal, :informal)
12
- assert_equal [], Holidays.on(Date.new(2018,1,5), :custom_informal, :observed)
13
- end
14
-
15
- end
@@ -1,35 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
-
3
- class CustomYearRangeHolidaysTest < Test::Unit::TestCase
4
-
5
- def test_after_year_feature
6
- Holidays.load_custom('test/data/test_custom_year_range_holiday_defs.yaml')
7
- assert_equal [], Holidays.on(Date.civil(2015,6,1), :custom_year_range_file)
8
- assert_not_equal [], Holidays.on(Date.civil(2016,6,1), :custom_year_range_file)
9
- end
10
-
11
- def test_before_year_feature
12
- Holidays.load_custom('test/data/test_custom_year_range_holiday_defs.yaml')
13
- assert_not_equal [], Holidays.on(Date.civil(2017,6,2), :custom_year_range_file)
14
- assert_equal [], Holidays.on(Date.civil(2018,6,2), :custom_year_range_file)
15
- end
16
-
17
- def test_between_year_feature
18
- Holidays.load_custom('test/data/test_custom_year_range_holiday_defs.yaml')
19
- assert_equal [], Holidays.on(Date.civil(2015,6,3), :custom_year_range_file)
20
- assert_not_equal [], Holidays.on(Date.civil(2016,6,3), :custom_year_range_file)
21
- assert_not_equal [], Holidays.on(Date.civil(2017,6,3), :custom_year_range_file)
22
- assert_not_equal [], Holidays.on(Date.civil(2018,6,3), :custom_year_range_file)
23
- assert_equal [], Holidays.on(Date.civil(2019,6,3), :custom_year_range_file)
24
- end
25
-
26
- def test_limited_year_feature
27
- Holidays.load_custom('test/data/test_custom_year_range_holiday_defs.yaml')
28
- assert_equal [], Holidays.on(Date.civil(2015,6,4), :custom_year_range_file)
29
- assert_not_equal [], Holidays.on(Date.civil(2016,6,4), :custom_year_range_file)
30
- assert_equal [], Holidays.on(Date.civil(2017,6,4), :custom_year_range_file)
31
- assert_not_equal [], Holidays.on(Date.civil(2018,6,4), :custom_year_range_file)
32
- assert_not_equal [], Holidays.on(Date.civil(2019,6,4), :custom_year_range_file)
33
- assert_equal [], Holidays.on(Date.civil(2020,6,4), :custom_year_range_file)
34
- end
35
- end
data/test/smoke/README.md DELETED
@@ -1,31 +0,0 @@
1
- # Smoke tests
2
-
3
- Structural-only checks across every region loaded from `/definitions`. These tests
4
- verify that the gem can load and process all definitions without raising errors.
5
- They make no assertions about specific holiday names, dates, or counts.
6
-
7
- ## Purpose
8
-
9
- These tests are run from the upstream `holidays/definitions` repo's CI as the
10
- downstream check. The contract is narrow on purpose: a definitions change should
11
- only fail this suite if it actually breaks the gem's ability to load or process
12
- definitions, never because of intentional content changes (renaming a holiday,
13
- adding a region, shifting a date, etc.).
14
-
15
- ## What belongs here
16
-
17
- - Tests that exercise the gem's API surface (`Holidays.on`, `Holidays.between`,
18
- flags like `:observed` and `:informal`) across all regions and assert only
19
- that nothing raises.
20
- - Tests that verify the *shape* of return values (e.g. `available_regions` is
21
- an Array of Symbols).
22
- - Cross-region invariants that hold regardless of content (e.g. `:any` count is
23
- ≥ each individual region's count).
24
-
25
- ## What does NOT belong here
26
-
27
- - Any assertion about a specific holiday name, date, or count.
28
- - Any check that depends on the contents of a particular region's YAML.
29
-
30
- If a check would fail when someone legitimately renames "Labour Day" to
31
- "Labor Day" in `ca.yaml`, it does not belong in `smoke/`. It belongs in `e2e/`.
@@ -1,18 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
-
3
- class AvailableRegionsTests < Test::Unit::TestCase
4
- def setup
5
- @date = Date.civil(2008,1,1)
6
- end
7
-
8
- def test_available_regions_returns_array
9
- assert Holidays.available_regions.is_a?(Array)
10
- end
11
-
12
- def test_available_regions_returns_array_of_symbols
13
- Holidays.available_regions.each do |r|
14
- assert r.is_a?(Symbol)
15
- end
16
- end
17
-
18
- end