holidays 4.6.0 → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/CONTRIBUTING.md +5 -5
  4. data/Makefile +29 -0
  5. data/README.md +13 -1
  6. data/Rakefile +2 -2
  7. data/definitions/au.yaml +12 -9
  8. data/definitions/ca.yaml +17 -2
  9. data/definitions/ch.yaml +1 -1
  10. data/definitions/index.yaml +3 -0
  11. data/definitions/is.yaml +1 -1
  12. data/definitions/jp.yaml +19 -14
  13. data/definitions/kr.yaml +282 -0
  14. data/definitions/lu.yaml +56 -0
  15. data/definitions/my.yaml +51 -0
  16. data/definitions/ups.yaml +1 -1
  17. data/definitions/us.yaml +1 -1
  18. data/lib/generated_definitions/MANIFEST +3 -0
  19. data/lib/generated_definitions/REGIONS.rb +1 -1
  20. data/lib/generated_definitions/au.rb +11 -8
  21. data/lib/generated_definitions/ca.rb +1 -1
  22. data/lib/generated_definitions/ch.rb +1 -1
  23. data/lib/generated_definitions/europe.rb +2 -2
  24. data/lib/generated_definitions/is.rb +1 -1
  25. data/lib/generated_definitions/jp.rb +13 -15
  26. data/lib/generated_definitions/kr.rb +248 -0
  27. data/lib/generated_definitions/lu.rb +39 -0
  28. data/lib/generated_definitions/my.rb +36 -0
  29. data/lib/generated_definitions/north_america.rb +2 -2
  30. data/lib/generated_definitions/scandinavia.rb +1 -1
  31. data/lib/generated_definitions/ups.rb +1 -1
  32. data/lib/generated_definitions/us.rb +1 -1
  33. data/lib/holidays.rb +29 -51
  34. data/lib/holidays/core_extensions/date.rb +1 -1
  35. data/lib/holidays/definition/context/function_processor.rb +86 -0
  36. data/lib/holidays/definition/context/generator.rb +31 -6
  37. data/lib/holidays/definition/parser/custom_method.rb +1 -3
  38. data/lib/holidays/definition/repository/holidays_by_month.rb +1 -1
  39. data/lib/holidays/definition/validator/region.rb +1 -3
  40. data/lib/holidays/errors.rb +1 -0
  41. data/lib/holidays/factory/date_calculator.rb +37 -0
  42. data/lib/holidays/factory/definition.rb +96 -0
  43. data/lib/holidays/factory/finder.rb +70 -0
  44. data/lib/holidays/finder/context/between.rb +43 -0
  45. data/lib/holidays/{use_case → finder}/context/dates_driver_builder.rb +6 -4
  46. data/lib/holidays/finder/context/next_holiday.rb +57 -0
  47. data/lib/holidays/{option → finder}/context/parse_options.rb +6 -8
  48. data/lib/holidays/finder/context/search.rb +86 -0
  49. data/lib/holidays/finder/context/year_holiday.rb +57 -0
  50. data/lib/holidays/finder/rules/in_region.rb +23 -0
  51. data/lib/holidays/finder/rules/year_range.rb +82 -0
  52. data/lib/holidays/load_all_definitions.rb +7 -5
  53. data/lib/holidays/version.rb +1 -1
  54. data/test/coverage_report.rb +7 -0
  55. data/test/defs/test_defs_au.rb +1 -1
  56. data/test/defs/test_defs_ca.rb +16 -1
  57. data/test/defs/test_defs_jp.rb +4 -0
  58. data/test/defs/test_defs_kr.rb +26 -0
  59. data/test/defs/test_defs_lu.rb +24 -0
  60. data/test/defs/test_defs_my.rb +20 -0
  61. data/test/defs/test_defs_north_america.rb +16 -1
  62. data/test/holidays/core_extensions/test_date_time.rb +7 -7
  63. data/test/holidays/definition/context/test_function_processor.rb +175 -0
  64. data/test/holidays/definition/context/test_generator.rb +18 -11
  65. data/test/holidays/definition/parser/test_custom_method.rb +2 -2
  66. data/test/holidays/definition/repository/test_proc_result_cache.rb +1 -1
  67. data/test/holidays/{test_date_calculator_factory.rb → factory/test_date_calculator.rb} +3 -3
  68. data/test/holidays/factory/test_definition.rb +53 -0
  69. data/test/holidays/factory/test_finder.rb +25 -0
  70. data/test/holidays/finder/context/test_between.rb +172 -0
  71. data/test/holidays/{use_case → finder}/context/test_dates_driver_builder.rb +2 -2
  72. data/test/holidays/finder/context/test_next_holiday.rb +156 -0
  73. data/test/holidays/{option → finder}/context/test_parse_options.rb +9 -9
  74. data/test/holidays/finder/context/test_search.rb +203 -0
  75. data/test/holidays/finder/context/test_year_holiday.rb +202 -0
  76. data/test/holidays/finder/rules/test_in_region.rb +38 -0
  77. data/test/holidays/finder/rules/test_year_range.rb +170 -0
  78. data/test/integration/README.md +9 -0
  79. data/test/{test_all_regions.rb → integration/test_all_regions.rb} +16 -2
  80. data/test/{test_custom_holidays.rb → integration/test_custom_holidays.rb} +2 -2
  81. data/test/{test_custom_year_range_holidays.rb → integration/test_custom_year_range_holidays.rb} +1 -1
  82. data/test/{test_holidays.rb → integration/test_holidays.rb} +43 -32
  83. data/test/{test_holidays_between.rb → integration/test_holidays_between.rb} +8 -16
  84. data/test/{test_multiple_regions.rb → integration/test_multiple_regions.rb} +1 -1
  85. data/test/test_helper.rb +3 -4
  86. metadata +67 -39
  87. data/benchmark.rb +0 -8
  88. data/lib/holidays/date_calculator_factory.rb +0 -35
  89. data/lib/holidays/definition_factory.rb +0 -86
  90. data/lib/holidays/option_factory.rb +0 -15
  91. data/lib/holidays/use_case/context/between.rb +0 -45
  92. data/lib/holidays/use_case/context/context_common.rb +0 -123
  93. data/lib/holidays/use_case/context/next_holiday.rb +0 -54
  94. data/lib/holidays/use_case/context/year_holiday.rb +0 -51
  95. data/lib/holidays/use_case_factory.rb +0 -41
  96. data/test/holidays/test_definition_factory.rb +0 -49
  97. data/test/holidays/test_option_factory.rb +0 -9
  98. data/test/holidays/test_use_case_factory.rb +0 -13
  99. data/test/holidays/use_case/context/test_between.rb +0 -77
@@ -0,0 +1,38 @@
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_is_in_available
24
+ assert_equal(true, @subject.call([:test_sub], [:test, :test_sub]))
25
+ end
26
+
27
+ def test_returns_false_if_match_not_found
28
+ assert_equal(false, @subject.call([:other], @available))
29
+ end
30
+
31
+ def test_returns_false_if_match_not_found_for_subregion
32
+ assert_equal(false, @subject.call([:other_sub], @available))
33
+ end
34
+
35
+ def test_returns_true_if_request_includes_nonmatching_but_also_any
36
+ assert_equal(true, @subject.call([:other_sub, :other, :any], @available))
37
+ end
38
+ end
@@ -0,0 +1,170 @@
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_contains_only_empty_hashes
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_before_operator_and_value_is_not_a_number
60
+ @year_ranges = [{before: "bad"}]
61
+ assert_raises ArgumentError do
62
+ @subject.call(@year, @year_ranges)
63
+ end
64
+ end
65
+
66
+ def test_returns_true_if_before_operator_and_target_is_before
67
+ @year_ranges = [{before: 2000}]
68
+ assert_equal(true, @subject.call(1999, @year_ranges))
69
+ end
70
+
71
+ def test_returns_true_if_before_operator_and_target_is_equal
72
+ @year_ranges = [{before: 2000}]
73
+ assert_equal(true, @subject.call(2000, @year_ranges))
74
+ end
75
+
76
+ def test_returns_false_if_before_operator_and_target_is_after
77
+ @year_ranges = [{before: 2000}]
78
+ assert_equal(false, @subject.call(2001, @year_ranges))
79
+ end
80
+
81
+ def test_returns_error_if_after_operator_with_bad_value
82
+ @year_ranges = [{after: "bad"}]
83
+ assert_raises ArgumentError do
84
+ @subject.call(@year, @year_ranges)
85
+ end
86
+ end
87
+
88
+ def test_returns_false_if_after_operator_and_target_is_before
89
+ @year_ranges = [{after: 2000}]
90
+ assert_equal(false, @subject.call(1999, @year_ranges))
91
+ end
92
+
93
+ def test_returns_true_if_after_operator_and_target_is_equal
94
+ @year_ranges = [{after: 2000}]
95
+ assert_equal(true, @subject.call(2000, @year_ranges))
96
+ end
97
+
98
+ def test_returns_true_if_after_operator_and_target_is_after
99
+ @year_ranges = [{after: 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_true_if_limited_operator_and_value_is_number_that_matches_target
111
+ @year_ranges = [{limited: 2002}]
112
+ assert_equal(true, @subject.call(2002, @year_ranges))
113
+ end
114
+
115
+ def test_returns_false_if_limited_operator_and_target_is_not_included
116
+ @year_ranges = [{limited: [1998,2000]}]
117
+ assert_equal(false, @subject.call(1997, @year_ranges))
118
+ assert_equal(false, @subject.call(1999, @year_ranges))
119
+ assert_equal(false, @subject.call(2002, @year_ranges))
120
+ end
121
+
122
+ def test_returns_true_if_limited_operator_and_target_is_included
123
+ @year_ranges = [{limited: [1998, 2000, 2002]}]
124
+ assert_equal(true, @subject.call(1998, @year_ranges))
125
+ assert_equal(true, @subject.call(2000, @year_ranges))
126
+ assert_equal(true, @subject.call(2002, @year_ranges))
127
+ end
128
+
129
+ def test_returns_error_if_between_operator_and_value_not_a_range
130
+ @year_ranges = [{between: 2000}]
131
+ assert_raises ArgumentError do
132
+ @subject.call(2003, @year_ranges)
133
+ end
134
+ end
135
+
136
+ def test_returns_false_if_between_operator_and_target_is_before
137
+ @year_ranges = [{between: 1998..2002}]
138
+ assert_equal(false, @subject.call(1997, @year_ranges))
139
+ end
140
+
141
+ def test_returns_true_if_between_operator_and_target_is_covered
142
+ @year_ranges = [{between: 1998..2002}]
143
+ assert_equal(true, @subject.call(1998, @year_ranges))
144
+ assert_equal(true, @subject.call(2000, @year_ranges))
145
+ assert_equal(true, @subject.call(2002, @year_ranges))
146
+ end
147
+
148
+ def test_returns_false_if_between_operator_and_target_is_after
149
+ @year_ranges = [{between: 1998..2002}]
150
+ assert_equal(false, @subject.call(2003, @year_ranges))
151
+ end
152
+
153
+ def test_returns_false_multiple_nonmatching_operators
154
+ @year_ranges = [{between: 1998..2002}, {:after => 2005}]
155
+ assert_equal(false, @subject.call(2003, @year_ranges))
156
+
157
+ @year_ranges = [{before: 1995}, {:limited => [1990, 1991, 1992]}]
158
+ assert_equal(false, @subject.call(1996, @year_ranges))
159
+ end
160
+
161
+ def test_returns_true_multiple_operators_all_matching
162
+ @year_ranges = [{between: 1998..2002}, {:limited=> [2000, 2001]}]
163
+ assert_equal(true, @subject.call(2001, @year_ranges))
164
+ end
165
+
166
+ def test_returns_true_if_multiple_operators_and_only_one_matches
167
+ @year_ranges = [{before: 2015}, {:after=> 2017}]
168
+ assert_equal(true, @subject.call(2001, @year_ranges))
169
+ end
170
+ end
@@ -0,0 +1,9 @@
1
+ # Integration tests
2
+
3
+ These tests are dependent on the files in /definitions (and, by proxy, /lib/generated_definitions).
4
+ It is possible that these tests will break because of 'unrelated' definition changes. The code
5
+ behind these changes could still be good but since the defintions changed we could see failures.
6
+
7
+ These are not unit tests. This is not testing whether specific internal code is working. These are
8
+ tests from the consumer perspective. You must recognize that this could fail because of code
9
+ changes unrelated to definition changes.
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/test_helper'
1
+ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
2
 
3
- class MultipleRegionsTests < Test::Unit::TestCase
3
+ class AllRegionsTests < Test::Unit::TestCase
4
4
  def setup
5
5
  Holidays::LoadAllDefinitions.call
6
6
  end
@@ -19,12 +19,26 @@ class MultipleRegionsTests < Test::Unit::TestCase
19
19
  def test_load_subregion
20
20
  holidays = Holidays.on(Date.civil(2014, 1, 1), :de_bb)
21
21
  assert holidays.any? { |h| h[:name] == 'Neujahrstag' }
22
+
23
+ holidays = Holidays.on(Date.civil(2020, 1, 1), :de_bb)
24
+ assert holidays.any? { |h| h[:name] == 'Neujahrstag' }
25
+
26
+ holidays = Holidays.on(Date.civil(2027, 1, 1), :de_bb)
27
+ assert holidays.any? { |h| h[:name] == 'Neujahrstag' }
22
28
  end
23
29
 
24
30
  def test_unknown_region_raises_exception
25
31
  assert_raise Holidays::UnknownRegionError do
26
32
  Holidays.on(Date.civil(2014, 1, 1), :something_we_do_not_recognize)
27
33
  end
34
+
35
+ assert_raise Holidays::UnknownRegionError do
36
+ Holidays.on(Date.civil(2020, 1, 1), :something_we_do_not_recognize)
37
+ end
38
+
39
+ assert_raise Holidays::UnknownRegionError do
40
+ Holidays.on(Date.civil(2030, 1, 1), :something_we_do_not_recognize)
41
+ end
28
42
  end
29
43
 
30
44
  def test_malicious_load_attempt_raises_exception
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/test_helper'
1
+ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
2
 
3
3
  class CustomHolidaysTest < Test::Unit::TestCase
4
4
 
@@ -7,7 +7,7 @@ class CustomHolidaysTest < Test::Unit::TestCase
7
7
  Holidays.on(Date.civil(2013,6,20), :custom_single_file)
8
8
  end
9
9
 
10
- loaded_holidays = Holidays.load_custom('test/data/test_single_custom_holiday_defs.yaml')
10
+ Holidays.load_custom('test/data/test_single_custom_holiday_defs.yaml')
11
11
 
12
12
  assert_not_equal [], Holidays.on(Date.civil(2013,6,20), :custom_single_file)
13
13
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/test_helper'
1
+ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
2
 
3
3
  class CustomYearRangeHolidaysTest < Test::Unit::TestCase
4
4
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require File.expand_path(File.dirname(__FILE__)) + '/test_helper'
2
+ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
3
3
 
4
4
  require "#{Holidays::DEFINITIONS_PATH}/ca"
5
5
 
@@ -7,8 +7,6 @@ require "#{Holidays::DEFINITIONS_PATH}/ca"
7
7
  # defs aren't duplicated.
8
8
  require "#{Holidays::DEFINITIONS_PATH}/north_america"
9
9
 
10
- # These are effectively integration tests. We plan on making this explicit somehow
11
- # in the future.
12
10
  class HolidaysTests < Test::Unit::TestCase
13
11
  def setup
14
12
  @date = Date.civil(2008,1,1)
@@ -115,10 +113,7 @@ class HolidaysTests < Test::Unit::TestCase
115
113
  assert_equal ['2008-05-19','Victoria Day'] , [holidays.first[:date].to_s, holidays.first[:name].to_s]
116
114
 
117
115
  # Should return 2 holidays.
118
- #
119
- # Should be 2 in the CA region but other regional files are loaded during the
120
- # unit tests add to the :any count.
121
- holidays = Holidays.next_holidays(2, [:any], Date.civil(2008,5,1))
116
+ holidays = Holidays.next_holidays(2, [:ca], Date.civil(2008,5,1))
122
117
  assert_equal 2, holidays.length
123
118
 
124
119
  # Should return 1 holiday in July
@@ -140,59 +135,77 @@ class HolidaysTests < Test::Unit::TestCase
140
135
  end
141
136
 
142
137
  def test_year_holidays
143
- # Should return 10 holidays from February 23 to December 31
138
+ # Should return 9 holidays from February 23 to December 31
144
139
  holidays = Holidays.year_holidays([:ca_on], Date.civil(2016, 2, 23))
145
- assert_equal 10, holidays.length
140
+ assert_equal 9, holidays.length
146
141
 
147
142
  # Must have options (Regions)
148
- assert_raises ArgumentError do
143
+ assert_raises ArgumentError do
149
144
  Holidays.year_holidays([], Date.civil(2016, 2, 23))
150
- end
145
+ end
151
146
 
152
- # Options must be in the form of an array.
153
- assert_raises ArgumentError do
147
+ # Options must be in the form of an array.
148
+ assert_raises ArgumentError do
154
149
  Holidays.year_holidays(:ca_on, Date.civil(2016, 2, 23))
155
- end
156
- end
150
+ end
151
+ end
157
152
 
158
153
  def test_year_holidays_with_specified_year
159
- # Should return all 12 holidays for 2016 in Ontario, Canada
154
+ # Should return all 11 holidays for 2016 in Ontario, Canada
160
155
  holidays = Holidays.year_holidays([:ca_on], Date.civil(2016, 1, 1))
161
- assert_equal 12, holidays.length
156
+ assert_equal 11, holidays.length
162
157
 
163
- # Should return all 12 holidays for 2016 in Australia
158
+ # Should return all 5 holidays for 2016 in Australia
164
159
  holidays = Holidays.year_holidays([:au], Date.civil(2016, 1, 1))
165
160
  assert_equal 5, holidays.length
166
- end
161
+ end
167
162
 
168
- def test_year_holidays_without_specified_year
163
+ def test_year_holidays_without_specified_year
169
164
  # Gets holidays for current year from today's date
170
165
  holidays = Holidays.year_holidays([:ca_on])
171
166
  assert_equal holidays.first[:date].year, Date.today.year
172
- end
167
+ end
173
168
 
174
169
  def test_year_holidays_feb_29_on_non_leap_year
175
- # Should throw argument error for invalid date
176
- assert_raises ArgumentError do
170
+ assert_raises ArgumentError do
177
171
  Holidays.year_holidays([:ca_on], Date.civil(2015, 2, 29))
178
172
  end
179
- end
173
+
174
+ assert_raises ArgumentError do
175
+ Holidays.year_holidays([:ca_on], Date.civil(2019, 2, 29))
176
+ end
177
+
178
+ assert_raises ArgumentError do
179
+ Holidays.year_holidays([:ca_on], Date.civil(2021, 2, 29))
180
+ end
181
+
182
+ assert_raises ArgumentError do
183
+ Holidays.year_holidays([:us], Date.civil(2023, 2, 29))
184
+ end
185
+
186
+ assert_raises ArgumentError do
187
+ Holidays.year_holidays([:ca_on], Date.civil(2025, 2, 29))
188
+ end
189
+ end
180
190
 
181
191
  def test_year_holidays_random_years
182
192
  # Should be 1 less holiday, as Family day didn't exist in Ontario in 1990
183
193
  holidays = Holidays.year_holidays([:ca_on], Date.civil(1990, 1, 1))
184
- assert_equal 11, holidays.length
194
+ assert_equal 10, holidays.length
185
195
 
186
196
  # Family day still didn't exist in 2000
187
197
  holidays = Holidays.year_holidays([:ca_on], Date.civil(2000, 1, 1))
188
- assert_equal 11, holidays.length
198
+ assert_equal 10, holidays.length
189
199
 
190
200
  holidays = Holidays.year_holidays([:ca_on], Date.civil(2020, 1, 1))
191
- assert_equal 12, holidays.length
201
+ assert_equal 11, holidays.length
192
202
 
193
203
  holidays = Holidays.year_holidays([:ca_on], Date.civil(2050, 1, 1))
194
- assert_equal 12, holidays.length
195
- end
204
+ assert_equal 11, holidays.length
205
+
206
+ holidays = Holidays.year_holidays([:jp], Date.civil(2070, 1, 1))
207
+ assert_equal 18, holidays.length
208
+ end
196
209
 
197
210
  def test_sub_regions
198
211
  # Should return Victoria Day.
@@ -250,15 +263,13 @@ class HolidaysTests < Test::Unit::TestCase
250
263
  }
251
264
  end
252
265
 
253
- #FIXME - I am not a huge fan of this test as it is written. It depends on the definitions not changing.
254
- # I think that this is fine for an integration test but I think it should be labeled as such.
255
266
  def test_caching
256
267
  start_date = Date.civil(2008, 3, 21)
257
268
  end_date = Date.civil(2008, 3, 25)
258
269
  cache_data = Holidays.between(start_date, end_date, :ca, :informal)
259
270
  options = [:ca, :informal]
260
271
 
261
- Holidays::DefinitionFactory.cache_repository.expects(:cache_between).with(start_date, end_date, cache_data, options)
272
+ Holidays::Factory::Definition.cache_repository.expects(:cache_between).with(start_date, end_date, cache_data, options)
262
273
 
263
274
  Holidays.cache_between(Date.civil(2008,3,21), Date.civil(2008,3,25), :ca, :informal)
264
275
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/test_helper'
1
+ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
2
 
3
3
  require "#{Holidays::DEFINITIONS_PATH}/ca"
4
4
 
@@ -10,14 +10,14 @@ require "#{Holidays::DEFINITIONS_PATH}/ca"
10
10
  # and don't want to bite off more than I can chew.
11
11
  require "#{Holidays::DEFINITIONS_PATH}/north_america"
12
12
 
13
- class HolidaysTests < Test::Unit::TestCase
13
+ class HolidaysBetweenTests < Test::Unit::TestCase
14
14
  def setup
15
15
  @date = Date.civil(2008,1,1)
16
16
  @subject = Holidays.method(:between)
17
17
  end
18
18
 
19
19
  def teardown
20
- Holidays::DefinitionFactory.cache_repository.reset!
20
+ Holidays::Factory::Definition.cache_repository.reset!
21
21
  end
22
22
 
23
23
  def test_between
@@ -46,7 +46,7 @@ class HolidaysTests < Test::Unit::TestCase
46
46
  end_date = Date.civil(2015, 1, 31)
47
47
  options = [:us, :informal]
48
48
 
49
- Holidays::DefinitionFactory.cache_repository.expects(:find).with(start_date, end_date, options).returns({cached: 'data'})
49
+ Holidays::Factory::Definition.cache_repository.expects(:find).with(start_date, end_date, options).returns({cached: 'data'})
50
50
 
51
51
  assert_equal({cached: 'data'}, @subject.call(start_date, end_date, *options))
52
52
  end
@@ -56,13 +56,9 @@ class HolidaysTests < Test::Unit::TestCase
56
56
  end_date = Date.civil(2015, 1, 31)
57
57
  options = [:us]
58
58
 
59
- options_parser_mock = mock()
60
- Holidays::OptionFactory.stubs(:parse_options).returns(options_parser_mock)
61
- options_parser_mock.expects(:call).with(options).returns([[:us], false, false])
62
-
63
59
  between_mock = mock()
64
- Holidays::UseCaseFactory.stubs(:between).returns(between_mock)
65
- between_mock.expects(:call).with(start_date, end_date, {2015 => [0, 1, 2], 2014 => [0, 12]}, [:us], false, false)
60
+ Holidays::Factory::Finder.stubs(:between).returns(between_mock)
61
+ between_mock.expects(:call).with(start_date, end_date, [:us])
66
62
 
67
63
  @subject.call(start_date, end_date, *options)
68
64
  end
@@ -72,13 +68,9 @@ class HolidaysTests < Test::Unit::TestCase
72
68
  end_date = Date.civil(2015, 1, 31)
73
69
  options = [:us]
74
70
 
75
- dates_driver_builder_mock = mock()
76
- Holidays::UseCaseFactory.stubs(:dates_driver_builder).returns(dates_driver_builder_mock)
77
- dates_driver_builder_mock.expects(:call).with(start_date, end_date).returns({2015 => [0, 1, 2]})
78
-
79
71
  between_mock = mock()
80
- Holidays::UseCaseFactory.stubs(:between).returns(between_mock)
81
- between_mock.expects(:call).with(start_date, end_date, {2015 => [0, 1, 2]}, [:us], false, false)
72
+ Holidays::Factory::Finder.stubs(:between).returns(between_mock)
73
+ between_mock.expects(:call).with(start_date, end_date, [:us])
82
74
 
83
75
  @subject.call(start_date, end_date, *options)
84
76
  end