holidays 6.4.0 → 8.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitmodules +1 -1
- data/CHANGELOG.md +80 -0
- data/Makefile +17 -4
- data/README.md +236 -101
- data/Rakefile +1 -1
- data/bin/console +0 -0
- data/bin/setup +1 -0
- data/doc/CONTRIBUTING.md +72 -0
- data/{MAINTAINERS.md → doc/MAINTAINERS.md} +5 -6
- data/{REFERENCES → doc/REFERENCES} +0 -0
- data/holidays.gemspec +8 -9
- data/lib/generated_definitions/MANIFEST +12 -4
- data/lib/generated_definitions/REGIONS.rb +2 -2
- data/lib/generated_definitions/ar.rb +30 -11
- data/lib/generated_definitions/at.rb +2 -2
- data/lib/generated_definitions/au.rb +26 -8
- data/lib/generated_definitions/be_fr.rb +2 -2
- data/lib/generated_definitions/be_nl.rb +2 -2
- data/lib/generated_definitions/bg.rb +2 -2
- data/lib/generated_definitions/br.rb +2 -2
- data/lib/generated_definitions/ca.rb +24 -17
- data/lib/generated_definitions/ch.rb +16 -4
- data/lib/generated_definitions/cl.rb +7 -10
- data/lib/generated_definitions/co.rb +121 -0
- data/lib/generated_definitions/cr.rb +2 -2
- data/lib/generated_definitions/cz.rb +2 -2
- data/lib/generated_definitions/de.rb +8 -5
- data/lib/generated_definitions/dk.rb +2 -2
- data/lib/generated_definitions/{ecb_target.rb → ecbtarget.rb} +10 -10
- data/lib/generated_definitions/ee.rb +2 -2
- data/lib/generated_definitions/el.rb +2 -2
- data/lib/generated_definitions/es.rb +8 -5
- data/lib/generated_definitions/europe.rb +114 -29
- data/lib/generated_definitions/federalreserve.rb +35 -0
- data/lib/generated_definitions/{federal_reserve.rb → federalreservebanks.rb} +15 -14
- data/lib/generated_definitions/fedex.rb +2 -2
- data/lib/generated_definitions/fi.rb +2 -2
- data/lib/generated_definitions/fr.rb +2 -2
- data/lib/generated_definitions/gb.rb +15 -8
- data/lib/generated_definitions/ge.rb +2 -2
- data/lib/generated_definitions/hk.rb +2 -2
- data/lib/generated_definitions/hr.rb +10 -8
- data/lib/generated_definitions/hu.rb +4 -3
- data/lib/generated_definitions/ie.rb +2 -2
- data/lib/generated_definitions/is.rb +2 -2
- data/lib/generated_definitions/it.rb +16 -7
- data/lib/generated_definitions/jp.rb +34 -15
- data/lib/generated_definitions/kr.rb +2 -2
- data/lib/generated_definitions/kz.rb +38 -0
- data/lib/generated_definitions/li.rb +2 -2
- data/lib/generated_definitions/lt.rb +2 -2
- data/lib/generated_definitions/lu.rb +4 -2
- data/lib/generated_definitions/lv.rb +55 -0
- data/lib/generated_definitions/ma.rb +2 -2
- data/lib/generated_definitions/mt_en.rb +2 -2
- data/lib/generated_definitions/mt_mt.rb +2 -2
- data/lib/generated_definitions/mx.rb +7 -7
- data/lib/generated_definitions/my.rb +2 -2
- data/lib/generated_definitions/nerc.rb +2 -2
- data/lib/generated_definitions/ng.rb +33 -0
- data/lib/generated_definitions/nl.rb +2 -2
- data/lib/generated_definitions/no.rb +2 -2
- data/lib/generated_definitions/{north_america.rb → northamerica.rb} +33 -26
- data/lib/generated_definitions/nyse.rb +3 -2
- data/lib/generated_definitions/nz.rb +41 -3
- data/lib/generated_definitions/pe.rb +2 -2
- data/lib/generated_definitions/ph.rb +2 -2
- data/lib/generated_definitions/pl.rb +2 -2
- data/lib/generated_definitions/pt.rb +2 -2
- data/lib/generated_definitions/ro.rb +6 -3
- data/lib/generated_definitions/rs_cyrl.rb +3 -3
- data/lib/generated_definitions/rs_la.rb +3 -3
- data/lib/generated_definitions/ru.rb +2 -2
- data/lib/generated_definitions/scandinavia.rb +2 -2
- data/lib/generated_definitions/se.rb +2 -2
- data/lib/generated_definitions/sg.rb +2 -2
- data/lib/generated_definitions/si.rb +4 -3
- data/lib/generated_definitions/sk.rb +2 -2
- data/lib/generated_definitions/southamerica.rb +247 -0
- data/lib/generated_definitions/th.rb +36 -0
- data/lib/generated_definitions/tn.rb +2 -2
- data/lib/generated_definitions/tr.rb +7 -5
- data/lib/generated_definitions/ua.rb +37 -0
- data/lib/generated_definitions/{united_nations.rb → unitednations.rb} +61 -61
- data/lib/generated_definitions/ups.rb +2 -2
- data/lib/generated_definitions/us.rb +9 -9
- data/lib/generated_definitions/ve.rb +2 -2
- data/lib/generated_definitions/vi.rb +2 -2
- data/lib/generated_definitions/za.rb +3 -3
- data/lib/holidays/core_extensions/time.rb +3 -3
- data/lib/holidays/definition/context/generator.rb +23 -70
- data/lib/holidays/definition/context/load.rb +1 -1
- data/lib/holidays/definition/generator/module.rb +54 -0
- data/lib/holidays/definition/generator/regions.rb +7 -2
- data/lib/holidays/definition/parser/custom_method.rb +2 -2
- data/lib/holidays/definition/repository/cache.rb +2 -1
- data/lib/holidays/definition/repository/holidays_by_month.rb +9 -1
- data/lib/holidays/factory/definition.rb +7 -0
- data/lib/holidays/finder/context/between.rb +6 -7
- data/lib/holidays/finder/context/dates_driver_builder.rb +5 -11
- data/lib/holidays/finder/context/next_holiday.rb +12 -12
- data/lib/holidays/finder/context/parse_options.rb +0 -6
- data/lib/holidays/finder/context/search.rb +39 -32
- data/lib/holidays/finder/rules/year_range.rb +30 -54
- data/lib/holidays/version.rb +1 -1
- data/lib/holidays.rb +14 -7
- data/test/coverage_report.rb +23 -7
- data/test/data/test_custom_informal_holidays_defs.yaml +11 -0
- data/test/data/test_custom_year_range_holiday_defs.yaml +6 -10
- data/test/data/test_multiple_regions_with_conflicts_region_1.yaml +38 -0
- data/test/data/test_multiple_regions_with_conflicts_region_2.yaml +38 -0
- data/test/defs/test_defs_ar.rb +30 -6
- data/test/defs/test_defs_at.rb +5 -3
- data/test/defs/test_defs_au.rb +29 -0
- data/test/defs/test_defs_be_fr.rb +10 -0
- data/test/defs/test_defs_be_nl.rb +10 -0
- data/test/defs/test_defs_ca.rb +63 -8
- data/test/defs/test_defs_ch.rb +6 -0
- data/test/defs/test_defs_co.rb +113 -0
- data/test/defs/test_defs_de.rb +7 -1
- data/test/defs/{test_defs_ecb_target.rb → test_defs_ecbtarget.rb} +11 -11
- data/test/defs/test_defs_es.rb +2 -0
- data/test/defs/test_defs_europe.rb +250 -15
- data/test/defs/test_defs_federalreserve.rb +119 -0
- data/test/defs/test_defs_federalreservebanks.rb +251 -0
- data/test/defs/test_defs_gb.rb +42 -0
- data/test/defs/test_defs_hr.rb +6 -6
- data/test/defs/test_defs_hu.rb +12 -4
- data/test/defs/test_defs_it.rb +20 -0
- data/test/defs/test_defs_jp.rb +30 -2
- data/test/defs/test_defs_kz.rb +39 -0
- data/test/defs/test_defs_lu.rb +6 -0
- data/test/defs/test_defs_lv.rb +96 -0
- data/test/defs/test_defs_mx.rb +3 -1
- data/test/defs/test_defs_ng.rb +29 -0
- data/test/defs/{test_defs_north_america.rb → test_defs_northamerica.rb} +77 -20
- data/test/defs/test_defs_nyse.rb +7 -0
- data/test/defs/test_defs_nz.rb +4 -0
- data/test/defs/test_defs_ro.rb +14 -0
- data/test/defs/test_defs_rs_cyrl.rb +1 -1
- data/test/defs/test_defs_rs_la.rb +1 -1
- data/test/defs/test_defs_southamerica.rb +323 -0
- data/test/defs/test_defs_th.rb +33 -0
- data/test/defs/test_defs_tr.rb +7 -0
- data/test/defs/test_defs_ua.rb +41 -0
- data/test/defs/{test_defs_united_nations.rb → test_defs_unitednations.rb} +3 -3
- data/test/defs/test_defs_us.rb +11 -11
- data/test/holidays/core_extensions/test_date.rb +3 -2
- data/test/holidays/definition/context/test_generator.rb +17 -20
- data/test/holidays/definition/context/test_load.rb +3 -3
- data/test/holidays/definition/generator/test_module.rb +268 -0
- data/test/holidays/definition/parser/test_custom_method.rb +4 -4
- data/test/holidays/definition/repository/test_holidays_by_month.rb +121 -1
- data/test/holidays/finder/context/test_parse_options.rb +0 -10
- data/test/holidays/finder/rules/test_year_range.rb +43 -47
- data/test/integration/test_any_holidays_during_work_week.rb +90 -0
- data/test/integration/test_available_regions.rb +1 -1
- data/test/integration/test_custom_informal_holidays.rb +15 -0
- data/test/integration/test_custom_year_range_holidays.rb +0 -7
- data/test/integration/test_holidays.rb +4 -56
- data/test/integration/test_holidays_between.rb +11 -1
- data/test/integration/test_multiple_regions.rb +54 -6
- data/test/integration/test_multiple_regions_with_conflict.rb +29 -0
- data/test/integration/test_nonstandard_regions.rb +25 -0
- metadata +79 -53
- data/CONTRIBUTING.md +0 -51
- data/test/defs/test_defs_federal_reserve.rb +0 -111
data/test/defs/test_defs_tr.rb
CHANGED
@@ -22,32 +22,39 @@ class TrDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
22
22
|
assert_equal "Ramazan Bayramı", (Holidays.on(Date.civil(2017, 6, 25), [:tr])[0] || {})[:name]
|
23
23
|
assert_equal "Ramazan Bayramı", (Holidays.on(Date.civil(2018, 6, 15), [:tr])[0] || {})[:name]
|
24
24
|
assert_equal "Ramazan Bayramı", (Holidays.on(Date.civil(2019, 6, 4), [:tr])[0] || {})[:name]
|
25
|
+
assert_equal "Ramazan Bayramı", (Holidays.on(Date.civil(2020, 5, 24), [:tr])[0] || {})[:name]
|
25
26
|
|
26
27
|
assert_equal "Ramazan Bayramı (ikinci tatil)", (Holidays.on(Date.civil(2017, 6, 26), [:tr])[0] || {})[:name]
|
27
28
|
assert_equal "Ramazan Bayramı (ikinci tatil)", (Holidays.on(Date.civil(2018, 6, 16), [:tr])[0] || {})[:name]
|
28
29
|
assert_equal "Ramazan Bayramı (ikinci tatil)", (Holidays.on(Date.civil(2019, 6, 5), [:tr])[0] || {})[:name]
|
30
|
+
assert_equal "Ramazan Bayramı (ikinci tatil)", (Holidays.on(Date.civil(2020, 5, 25), [:tr])[0] || {})[:name]
|
29
31
|
|
30
32
|
assert_equal "Ramazan Bayramı (üçüncü tatil)", (Holidays.on(Date.civil(2017, 6, 27), [:tr])[0] || {})[:name]
|
31
33
|
assert_equal "Ramazan Bayramı (üçüncü tatil)", (Holidays.on(Date.civil(2018, 6, 17), [:tr])[0] || {})[:name]
|
32
34
|
assert_equal "Ramazan Bayramı (üçüncü tatil)", (Holidays.on(Date.civil(2019, 6, 6), [:tr])[0] || {})[:name]
|
35
|
+
assert_equal "Ramazan Bayramı (üçüncü tatil)", (Holidays.on(Date.civil(2020, 5, 26), [:tr])[0] || {})[:name]
|
33
36
|
|
34
37
|
assert_equal "Demokrasi ve Milli Birlik Günü", (Holidays.on(Date.civil(2017, 7, 15), [:tr])[0] || {})[:name]
|
35
38
|
|
36
39
|
assert_equal "Kurban Bayramı", (Holidays.on(Date.civil(2017, 9, 1), [:tr])[0] || {})[:name]
|
37
40
|
assert_equal "Kurban Bayramı", (Holidays.on(Date.civil(2018, 8, 21), [:tr])[0] || {})[:name]
|
38
41
|
assert_equal "Kurban Bayramı", (Holidays.on(Date.civil(2019, 8, 11), [:tr])[0] || {})[:name]
|
42
|
+
assert_equal "Kurban Bayramı", (Holidays.on(Date.civil(2020, 7, 31), [:tr])[0] || {})[:name]
|
39
43
|
|
40
44
|
assert_equal "Kurban Bayramı (ikinci tatil)", (Holidays.on(Date.civil(2017, 9, 2), [:tr])[0] || {})[:name]
|
41
45
|
assert_equal "Kurban Bayramı (ikinci tatil)", (Holidays.on(Date.civil(2018, 8, 22), [:tr])[0] || {})[:name]
|
42
46
|
assert_equal "Kurban Bayramı (ikinci tatil)", (Holidays.on(Date.civil(2019, 8, 12), [:tr])[0] || {})[:name]
|
47
|
+
assert_equal "Kurban Bayramı (ikinci tatil)", (Holidays.on(Date.civil(2020, 8, 1), [:tr])[0] || {})[:name]
|
43
48
|
|
44
49
|
assert_equal "Kurban Bayramı (üçüncü tatil)", (Holidays.on(Date.civil(2017, 9, 3), [:tr])[0] || {})[:name]
|
45
50
|
assert_equal "Kurban Bayramı (üçüncü tatil)", (Holidays.on(Date.civil(2018, 8, 23), [:tr])[0] || {})[:name]
|
46
51
|
assert_equal "Kurban Bayramı (üçüncü tatil)", (Holidays.on(Date.civil(2019, 8, 13), [:tr])[0] || {})[:name]
|
52
|
+
assert_equal "Kurban Bayramı (üçüncü tatil)", (Holidays.on(Date.civil(2020, 8, 2), [:tr])[0] || {})[:name]
|
47
53
|
|
48
54
|
assert_equal "Kurban Bayramı (dördüncü tatil)", (Holidays.on(Date.civil(2017, 9, 4), [:tr])[0] || {})[:name]
|
49
55
|
assert_equal "Kurban Bayramı (dördüncü tatil)", (Holidays.on(Date.civil(2018, 8, 24), [:tr])[0] || {})[:name]
|
50
56
|
assert_equal "Kurban Bayramı (dördüncü tatil)", (Holidays.on(Date.civil(2019, 8, 14), [:tr])[0] || {})[:name]
|
57
|
+
assert_equal "Kurban Bayramı (dördüncü tatil)", (Holidays.on(Date.civil(2020, 8, 3), [:tr])[0] || {})[:name]
|
51
58
|
|
52
59
|
end
|
53
60
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
3
|
+
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
5
|
+
#
|
6
|
+
# Definitions loaded: definitions/ua.yaml
|
7
|
+
class UaDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
|
+
|
9
|
+
def test_ua
|
10
|
+
assert_equal "Новий Рік", (Holidays.on(Date.civil(2018, 1, 1), [:ua])[0] || {})[:name]
|
11
|
+
|
12
|
+
assert_equal "Різдво Христове", (Holidays.on(Date.civil(2018, 1, 7), [:ua])[0] || {})[:name]
|
13
|
+
|
14
|
+
assert_equal "Різдво Христове", (Holidays.on(Date.civil(2018, 1, 8), [:ua], [:observed])[0] || {})[:name]
|
15
|
+
|
16
|
+
assert_equal "Міжнародний жіночий день", (Holidays.on(Date.civil(2018, 3, 8), [:ua])[0] || {})[:name]
|
17
|
+
|
18
|
+
assert_equal "Великдень", (Holidays.on(Date.civil(2018, 4, 8), [:ua])[0] || {})[:name]
|
19
|
+
|
20
|
+
assert_equal "Великдень", (Holidays.on(Date.civil(2018, 4, 9), [:ua], [:observed])[0] || {})[:name]
|
21
|
+
|
22
|
+
assert_equal "День праці", (Holidays.on(Date.civil(2018, 5, 1), [:ua])[0] || {})[:name]
|
23
|
+
|
24
|
+
assert_equal "День перемоги над нацизмом у Другій світовій війні", (Holidays.on(Date.civil(2018, 5, 9), [:ua])[0] || {})[:name]
|
25
|
+
|
26
|
+
assert_equal "Трійця", (Holidays.on(Date.civil(2018, 5, 27), [:ua])[0] || {})[:name]
|
27
|
+
|
28
|
+
assert_equal "Трійця", (Holidays.on(Date.civil(2018, 5, 28), [:ua], [:observed])[0] || {})[:name]
|
29
|
+
|
30
|
+
assert_equal "День Конституції", (Holidays.on(Date.civil(2018, 6, 28), [:ua])[0] || {})[:name]
|
31
|
+
|
32
|
+
assert_equal "День Незалежності", (Holidays.on(Date.civil(2018, 8, 24), [:ua])[0] || {})[:name]
|
33
|
+
|
34
|
+
assert_equal "День захисника України", (Holidays.on(Date.civil(2018, 10, 14), [:ua])[0] || {})[:name]
|
35
|
+
|
36
|
+
assert_equal "День захисника України", (Holidays.on(Date.civil(2018, 10, 15), [:ua], [:observed])[0] || {})[:name]
|
37
|
+
|
38
|
+
assert_equal "Різдво Христове", (Holidays.on(Date.civil(2018, 12, 25), [:ua])[0] || {})[:name]
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded: definitions/
|
7
|
-
class
|
6
|
+
# Definitions loaded: definitions/unitednations.yaml
|
7
|
+
class UnitednationsDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
|
-
def
|
9
|
+
def test_unitednations
|
10
10
|
end
|
11
11
|
end
|
data/test/defs/test_defs_us.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded: definitions/us.yaml, definitions/
|
6
|
+
# Definitions loaded: definitions/us.yaml, definitions/northamericainformal.yaml
|
7
7
|
class UsDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_us
|
@@ -87,10 +87,6 @@ assert_equal "Presidents' Day", (Holidays.on(Date.civil(2018, 2, 19), [:us])[0]
|
|
87
87
|
assert_nil (Holidays.on(Date.civil(2018, 3, 5), [:us])[0] || {})[:name]
|
88
88
|
assert_nil (Holidays.on(Date.civil(2019, 3, 4), [:us])[0] || {})[:name]
|
89
89
|
|
90
|
-
assert_equal "Casimir Pulaski Day", (Holidays.on(Date.civil(2017, 3, 6), [:us_il])[0] || {})[:name]
|
91
|
-
assert_equal "Casimir Pulaski Day", (Holidays.on(Date.civil(2018, 3, 5), [:us_il])[0] || {})[:name]
|
92
|
-
assert_equal "Casimir Pulaski Day", (Holidays.on(Date.civil(2019, 3, 4), [:us_il])[0] || {})[:name]
|
93
|
-
|
94
90
|
assert_nil (Holidays.on(Date.civil(2017, 3, 7), [:us])[0] || {})[:name]
|
95
91
|
assert_nil (Holidays.on(Date.civil(2018, 3, 6), [:us])[0] || {})[:name]
|
96
92
|
assert_nil (Holidays.on(Date.civil(2019, 3, 5), [:us])[0] || {})[:name]
|
@@ -127,7 +123,7 @@ assert_equal "Seward's Day", (Holidays.on(Date.civil(2019, 3, 25), [:us_ak])[0]
|
|
127
123
|
assert_equal "Emancipation Day", (Holidays.on(Date.civil(2022, 4, 15), [:us_dc, :us_ca], [:observed])[0] || {})[:name]
|
128
124
|
assert_equal "Emancipation Day", (Holidays.on(Date.civil(2028, 4, 17), [:us_dc, :us_ca], [:observed])[0] || {})[:name]
|
129
125
|
|
130
|
-
assert_equal "Emancipation Day", (Holidays.on(Date.civil(2017, 4, 16), [:us_dc
|
126
|
+
assert_equal "Emancipation Day", (Holidays.on(Date.civil(2017, 4, 16), [:us_dc])[0] || {})[:name]
|
131
127
|
|
132
128
|
assert_nil (Holidays.on(Date.civil(2017, 4, 17), [:us])[0] || {})[:name]
|
133
129
|
assert_nil (Holidays.on(Date.civil(2018, 4, 16), [:us])[0] || {})[:name]
|
@@ -197,6 +193,10 @@ assert_equal "King Kamehameha I Day", (Holidays.on(Date.civil(2022, 6, 10), [:us
|
|
197
193
|
|
198
194
|
assert_equal "King Kamehameha I Day", (Holidays.on(Date.civil(2017, 6, 11), [:us_hi])[0] || {})[:name]
|
199
195
|
|
196
|
+
assert_nil (Holidays.on(Date.civil(2021, 6, 19), [:us], [:observed])[0] || {})[:name]
|
197
|
+
|
198
|
+
assert_equal "Juneteenth National Independence Day", (Holidays.on(Date.civil(2021, 6, 18), [:us], [:observed])[0] || {})[:name]
|
199
|
+
|
200
200
|
assert_equal "Emancipation Day in Texas", (Holidays.on(Date.civil(2017, 6, 19), [:us_tx])[0] || {})[:name]
|
201
201
|
|
202
202
|
assert_nil (Holidays.on(Date.civil(2017, 6, 20), [:us])[0] || {})[:name]
|
@@ -303,9 +303,9 @@ assert_equal "Nevada Day", (Holidays.on(Date.civil(2019, 10, 25), [:us_nv])[0] |
|
|
303
303
|
assert_nil (Holidays.on(Date.civil(2018, 11, 6), [:us])[0] || {})[:name]
|
304
304
|
assert_nil (Holidays.on(Date.civil(2021, 11, 2), [:us])[0] || {})[:name]
|
305
305
|
|
306
|
-
assert_equal "Election Day", (Holidays.on(Date.civil(2017, 11, 7), [:us_de, :us_hi, :
|
307
|
-
assert_equal "Election Day", (Holidays.on(Date.civil(2018, 11, 6), [:us_de, :us_hi, :
|
308
|
-
assert_equal "Election Day", (Holidays.on(Date.civil(2021, 11, 2), [:us_de, :us_hi, :
|
306
|
+
assert_equal "Election Day", (Holidays.on(Date.civil(2017, 11, 7), [:us_de, :us_hi, :us_in, :us_mt, :us_nj, :us_ny, :us_pa, :us_ri])[0] || {})[:name]
|
307
|
+
assert_equal "Election Day", (Holidays.on(Date.civil(2018, 11, 6), [:us_de, :us_hi, :us_in, :us_mt, :us_nj, :us_ny, :us_pa, :us_ri])[0] || {})[:name]
|
308
|
+
assert_equal "Election Day", (Holidays.on(Date.civil(2021, 11, 2), [:us_de, :us_hi, :us_in, :us_mt, :us_nj, :us_ny, :us_pa, :us_ri])[0] || {})[:name]
|
309
309
|
|
310
310
|
assert_equal "Veterans Day", (Holidays.on(Date.civil(2017, 11, 10), [:us], [:observed])[0] || {})[:name]
|
311
311
|
assert_equal "Veterans Day", (Holidays.on(Date.civil(2018, 11, 12), [:us], [:observed])[0] || {})[:name]
|
@@ -355,9 +355,9 @@ assert_equal "Christmas Eve (Holiday)", (Holidays.on(Date.civil(2028, 12, 22), [
|
|
355
355
|
assert_nil (Holidays.on(Date.civil(2022, 12, 26), [:us])[0] || {})[:name]
|
356
356
|
assert_nil (Holidays.on(Date.civil(2027, 12, 27), [:us])[0] || {})[:name]
|
357
357
|
|
358
|
-
assert_equal "Christmas Day", (Holidays.on(Date.civil(2021, 12,
|
358
|
+
assert_equal "Christmas Day", (Holidays.on(Date.civil(2021, 12, 24), [:us], [:observed])[0] || {})[:name]
|
359
359
|
assert_equal "Christmas Day", (Holidays.on(Date.civil(2022, 12, 26), [:us], [:observed])[0] || {})[:name]
|
360
|
-
assert_equal "Christmas Day", (Holidays.on(Date.civil(2027, 12,
|
360
|
+
assert_equal "Christmas Day", (Holidays.on(Date.civil(2027, 12, 24), [:us], [:observed])[0] || {})[:name]
|
361
361
|
|
362
362
|
assert_equal "Christmas Day", (Holidays.on(Date.civil(2017, 12, 25), [:us])[0] || {})[:name]
|
363
363
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__)) + '/../../test_helper'
|
2
2
|
|
3
|
+
require 'date'
|
3
4
|
require 'holidays/core_extensions/date'
|
4
5
|
|
5
6
|
class Date
|
@@ -114,8 +115,8 @@ class CoreExtensionDateTests < Test::Unit::TestCase
|
|
114
115
|
|
115
116
|
def test_datetime_holiday?
|
116
117
|
# in situations with activesupport
|
117
|
-
assert DateTime.
|
118
|
-
assert DateTime.
|
118
|
+
assert DateTime.civil(2008, 1, 1).to_date.holiday?('ca')
|
119
|
+
assert DateTime.civil(2008, 1, 1).holiday?('ca')
|
119
120
|
end
|
120
121
|
|
121
122
|
end
|
@@ -17,12 +17,15 @@ class GeneratorTests < Test::Unit::TestCase
|
|
17
17
|
@test_parser = mock()
|
18
18
|
@test_source_generator = mock()
|
19
19
|
|
20
|
+
@module_source_generator = mock()
|
21
|
+
|
20
22
|
@generator = Holidays::Definition::Context::Generator.new(
|
21
23
|
@custom_method_parser,
|
22
24
|
@custom_method_source_decorator,
|
23
25
|
@custom_methods_repository,
|
24
26
|
@test_parser,
|
25
27
|
@test_source_generator,
|
28
|
+
@module_source_generator,
|
26
29
|
)
|
27
30
|
end
|
28
31
|
|
@@ -99,12 +102,13 @@ class GeneratorTests < Test::Unit::TestCase
|
|
99
102
|
|
100
103
|
@test_parser.expects(:call).with([{'given' => {'date' => '2013-06-20', 'regions' => ['custom_single_file']}, 'expect' => {'name' => 'Company Founding'}}]).returns(['parsed tests'])
|
101
104
|
|
105
|
+
@module_source_generator.expects(:call).with("test", ["test/data/test_single_custom_holiday_defs.yaml"], [:custom_single_file], [" 6 => [{:mday => 20, :name => \"Company Founding\", :regions => [:custom_single_file]}]"], "").returns("module source")
|
102
106
|
@test_source_generator.expects(:call).with('test', ['test/data/test_single_custom_holiday_defs.yaml'], ['parsed tests']).returns("test source")
|
103
107
|
|
104
108
|
regions, rules_by_month, custom_methods, tests = @generator.parse_definition_files(files)
|
105
109
|
module_src = @generator.generate_definition_source("test", files, regions, rules_by_month, custom_methods, tests)[0]
|
106
110
|
|
107
|
-
expected_module_src = "
|
111
|
+
expected_module_src = "module source"
|
108
112
|
|
109
113
|
assert_equal expected_module_src, module_src
|
110
114
|
end
|
@@ -115,6 +119,8 @@ class GeneratorTests < Test::Unit::TestCase
|
|
115
119
|
|
116
120
|
@test_parser.expects(:call).with([{'given' => {'date' => '2013-06-20', 'regions' => ['custom_single_file']}, 'expect' => {'name' => 'Company Founding'}}]).returns(['parsed tests'])
|
117
121
|
|
122
|
+
@module_source_generator.expects(:call).returns("module_source")
|
123
|
+
|
118
124
|
@test_source_generator.expects(:call).with('test', ['test/data/test_single_custom_holiday_defs.yaml'], ['parsed tests']).returns("test source")
|
119
125
|
|
120
126
|
regions, rules_by_month, custom_methods, tests = @generator.parse_definition_files(files)
|
@@ -137,31 +143,25 @@ class GeneratorTests < Test::Unit::TestCase
|
|
137
143
|
:name => "after_year",
|
138
144
|
:regions => [:custom_year_range_file],
|
139
145
|
:mday => 1,
|
140
|
-
:year_ranges =>
|
146
|
+
:year_ranges => {:from => 2016}
|
141
147
|
},
|
142
148
|
{
|
143
149
|
:name => "before_year",
|
144
150
|
:regions => [:custom_year_range_file],
|
145
151
|
:mday => 2,
|
146
|
-
:year_ranges =>
|
152
|
+
:year_ranges => {:until => 2017}
|
147
153
|
},
|
148
154
|
{
|
149
155
|
:name => "between_year",
|
150
156
|
:regions => [:custom_year_range_file],
|
151
157
|
:mday => 3,
|
152
|
-
:year_ranges =>
|
158
|
+
:year_ranges => {:between => 2016..2018 }
|
153
159
|
},
|
154
160
|
{
|
155
161
|
:name => "limited_year",
|
156
162
|
:regions => [:custom_year_range_file],
|
157
163
|
:mday => 4,
|
158
|
-
:year_ranges =>
|
159
|
-
},
|
160
|
-
{
|
161
|
-
:name => "multiple_conditions",
|
162
|
-
:regions => [:custom_year_range_file],
|
163
|
-
:mday => 5,
|
164
|
-
:year_ranges => [{"before" => 2015}, {"after" => 2017}]
|
164
|
+
:year_ranges => {:limited => [2016,2018,2019]}
|
165
165
|
}
|
166
166
|
]
|
167
167
|
}
|
@@ -177,9 +177,11 @@ class GeneratorTests < Test::Unit::TestCase
|
|
177
177
|
|
178
178
|
@test_source_generator.expects(:call).with('test', ['test/data/test_custom_year_range_holiday_defs.yaml'], ['parsed tests']).returns('test source')
|
179
179
|
|
180
|
+
@module_source_generator.expects(:call).with("test", ["test/data/test_custom_year_range_holiday_defs.yaml"], [:custom_year_range_file], [" 6 => [{:mday => 1, :year_ranges => { :from => 2016 },:name => \"after_year\", :regions => [:custom_year_range_file]},\n {:mday => 2, :year_ranges => { :until => 2017 },:name => \"before_year\", :regions => [:custom_year_range_file]},\n {:mday => 3, :year_ranges => { :between => 2016..2018 },:name => \"between_year\", :regions => [:custom_year_range_file]},\n {:mday => 4, :year_ranges => { :limited => [2016, 2018, 2019] },:name => \"limited_year\", :regions => [:custom_year_range_file]}]"], "").returns('module_source')
|
181
|
+
|
180
182
|
regions, rules_by_month, custom_methods, tests = @generator.parse_definition_files(files)
|
181
183
|
module_src = @generator.generate_definition_source("test", files, regions, rules_by_month, custom_methods, tests)[0]
|
182
|
-
expected_module_src = "
|
184
|
+
expected_module_src = "module_source"
|
183
185
|
|
184
186
|
assert_equal expected_module_src, module_src
|
185
187
|
end
|
@@ -193,12 +195,13 @@ class GeneratorTests < Test::Unit::TestCase
|
|
193
195
|
|
194
196
|
@test_parser.expects(:call).with([{'given' => {'date' => '2013-06-20', 'regions' => ['custom_single_file']}, 'expect' => {'name' => 'Company Founding'}}, {'given' => {'date' => '2015-01-01', 'regions' => ['custom_single_file']}, 'expect' => {'name' => 'Custom Holiday'}}]).returns(['parsed tests'])
|
195
197
|
|
198
|
+
@module_source_generator.expects(:call).with("test", ["test/data/test_single_custom_holiday_with_custom_procs.yaml"], [:custom_single_file], [" 0 => [{:function => \"custom_method(year, month)\", :function_arguments => [:year, :month], :function_modifier => 5, :name => \"Custom Holiday\", :regions => [:custom_single_file]}]", " 6 => [{:mday => 20, :name => \"Company Founding\", :regions => [:custom_single_file]}]"], "\"custom_method(year, month)\" => Proc.new { |year, month|\nsource_stuff\n},\n\n").returns("module source")
|
196
199
|
@test_source_generator.expects(:call).with('test', ['test/data/test_single_custom_holiday_with_custom_procs.yaml'], ['parsed tests']).returns('test source')
|
197
200
|
|
198
201
|
regions, rules_by_month, custom_methods, tests = @generator.parse_definition_files(files)
|
199
202
|
module_src = @generator.generate_definition_source("test", files, regions, rules_by_month, custom_methods, tests)[0]
|
200
203
|
|
201
|
-
expected_module_src = "
|
204
|
+
expected_module_src = "module source"
|
202
205
|
|
203
206
|
assert_equal expected_module_src, module_src
|
204
207
|
end
|
@@ -212,6 +215,7 @@ class GeneratorTests < Test::Unit::TestCase
|
|
212
215
|
|
213
216
|
@test_parser.expects(:call).with([{'given' => {'date' => '2013-06-20', 'regions' => ['custom_single_file']}, 'expect' => {'name' => 'Company Founding'}}, {'given' => {'date' => '2015-01-01', 'regions' => ['custom_single_file']}, 'expect' => {'name' => 'Custom Holiday'}}]).returns(['parsed tests'])
|
214
217
|
|
218
|
+
@module_source_generator.expects(:call).returns("module_source")
|
215
219
|
@test_source_generator.expects(:call).with('test', ['test/data/test_single_custom_holiday_with_custom_procs.yaml'], ['parsed tests']).returns('test source')
|
216
220
|
|
217
221
|
regions, rules_by_month, custom_methods, tests = @generator.parse_definition_files(files)
|
@@ -219,11 +223,4 @@ class GeneratorTests < Test::Unit::TestCase
|
|
219
223
|
|
220
224
|
assert_equal 'test source', test_src
|
221
225
|
end
|
222
|
-
|
223
|
-
#TODO Missing test scenarios. Adding here so I don't forget when I split this
|
224
|
-
# apart into smaller components.
|
225
|
-
#
|
226
|
-
# 1) If a year_range contains empty entries then we should blow up.
|
227
|
-
# 2) If year_range contains invalid (i.e. too many types per entry) then
|
228
|
-
# we should blow up
|
229
226
|
end
|
@@ -14,7 +14,7 @@ class LoadTests < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_region_is_found_and_loaded_and_merged
|
17
|
-
@definition_merger.expects(:call).with(
|
17
|
+
@definition_merger.expects(:call).with(:test_region, {}, {})
|
18
18
|
@subject.call(:test_region)
|
19
19
|
end
|
20
20
|
|
@@ -31,7 +31,7 @@ class LoadTests < Test::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_returns_list_of_loaded_regions
|
34
|
-
@definition_merger.expects(:call).with(
|
35
|
-
assert_equal([:test_region, :test_region2], @subject.call(:test_region))
|
34
|
+
@definition_merger.expects(:call).with(:test_region, {}, {})
|
35
|
+
assert_equal([:test_region, :test_region2], @subject.call(:test_region), "Should cache subregions under the parent region's name")
|
36
36
|
end
|
37
37
|
end
|
@@ -0,0 +1,268 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../../../test_helper'
|
2
|
+
|
3
|
+
require 'holidays/definition/generator/module'
|
4
|
+
|
5
|
+
class GeneratorModuleTests < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@generator = Holidays::Definition::Generator::Module.new
|
8
|
+
|
9
|
+
@module_name = "TEST"
|
10
|
+
@files = ["file1.rb", "file2.rb"]
|
11
|
+
@regions = [:test, :test2]
|
12
|
+
@month_strings = ["first-string", "second-string"]
|
13
|
+
@custom_methods = "custom-methods"
|
14
|
+
end
|
15
|
+
|
16
|
+
def subject
|
17
|
+
@generator.call(
|
18
|
+
@module_name,
|
19
|
+
@files,
|
20
|
+
@regions,
|
21
|
+
@month_strings,
|
22
|
+
@custom_methods,
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_generates_source
|
27
|
+
expected = <<-EOF
|
28
|
+
# encoding: utf-8
|
29
|
+
module Holidays
|
30
|
+
# This file is generated by the Ruby Holidays gem.
|
31
|
+
#
|
32
|
+
# Definitions loaded: file1.rb, file2.rb
|
33
|
+
#
|
34
|
+
# All the definitions are available at https://github.com/holidays/holidays
|
35
|
+
module TEST # :nodoc:
|
36
|
+
def self.defined_regions
|
37
|
+
[:test, :test2]
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.holidays_by_month
|
41
|
+
{
|
42
|
+
first-string,
|
43
|
+
second-string
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.custom_methods
|
48
|
+
{
|
49
|
+
custom-methods
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
EOF
|
55
|
+
|
56
|
+
assert_equal expected, subject
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_module_name_more_than_one_word
|
60
|
+
@module_name = "TESTWITHHYPHEN"
|
61
|
+
|
62
|
+
expected = <<-EOF
|
63
|
+
# encoding: utf-8
|
64
|
+
module Holidays
|
65
|
+
# This file is generated by the Ruby Holidays gem.
|
66
|
+
#
|
67
|
+
# Definitions loaded: file1.rb, file2.rb
|
68
|
+
#
|
69
|
+
# All the definitions are available at https://github.com/holidays/holidays
|
70
|
+
module TESTWITHHYPHEN # :nodoc:
|
71
|
+
def self.defined_regions
|
72
|
+
[:test, :test2]
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.holidays_by_month
|
76
|
+
{
|
77
|
+
first-string,
|
78
|
+
second-string
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.custom_methods
|
83
|
+
{
|
84
|
+
custom-methods
|
85
|
+
}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
EOF
|
90
|
+
|
91
|
+
assert_equal expected, subject
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_generates_source_with_blank_custom_methods
|
95
|
+
@custom_methods = ""
|
96
|
+
|
97
|
+
expected = <<-EOF
|
98
|
+
# encoding: utf-8
|
99
|
+
module Holidays
|
100
|
+
# This file is generated by the Ruby Holidays gem.
|
101
|
+
#
|
102
|
+
# Definitions loaded: file1.rb, file2.rb
|
103
|
+
#
|
104
|
+
# All the definitions are available at https://github.com/holidays/holidays
|
105
|
+
module TEST # :nodoc:
|
106
|
+
def self.defined_regions
|
107
|
+
[:test, :test2]
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.holidays_by_month
|
111
|
+
{
|
112
|
+
first-string,
|
113
|
+
second-string
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.custom_methods
|
118
|
+
{
|
119
|
+
|
120
|
+
}
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
EOF
|
125
|
+
|
126
|
+
assert_equal expected, subject
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_generates_source_with_nil_custom_methods
|
130
|
+
@custom_methods = nil
|
131
|
+
|
132
|
+
expected = <<-EOF
|
133
|
+
# encoding: utf-8
|
134
|
+
module Holidays
|
135
|
+
# This file is generated by the Ruby Holidays gem.
|
136
|
+
#
|
137
|
+
# Definitions loaded: file1.rb, file2.rb
|
138
|
+
#
|
139
|
+
# All the definitions are available at https://github.com/holidays/holidays
|
140
|
+
module TEST # :nodoc:
|
141
|
+
def self.defined_regions
|
142
|
+
[:test, :test2]
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.holidays_by_month
|
146
|
+
{
|
147
|
+
first-string,
|
148
|
+
second-string
|
149
|
+
}
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.custom_methods
|
153
|
+
{
|
154
|
+
|
155
|
+
}
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
EOF
|
160
|
+
|
161
|
+
assert_equal expected, subject
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_generates_source_with_symbol_module_name
|
165
|
+
@module_name = :test
|
166
|
+
|
167
|
+
expected = <<-EOF
|
168
|
+
# encoding: utf-8
|
169
|
+
module Holidays
|
170
|
+
# This file is generated by the Ruby Holidays gem.
|
171
|
+
#
|
172
|
+
# Definitions loaded: file1.rb, file2.rb
|
173
|
+
#
|
174
|
+
# All the definitions are available at https://github.com/holidays/holidays
|
175
|
+
module TEST # :nodoc:
|
176
|
+
def self.defined_regions
|
177
|
+
[:test, :test2]
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.holidays_by_month
|
181
|
+
{
|
182
|
+
first-string,
|
183
|
+
second-string
|
184
|
+
}
|
185
|
+
end
|
186
|
+
|
187
|
+
def self.custom_methods
|
188
|
+
{
|
189
|
+
custom-methods
|
190
|
+
}
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
EOF
|
195
|
+
|
196
|
+
assert_equal expected, subject
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_raise_error_if_module_name_is_blank
|
200
|
+
@module_name = ""
|
201
|
+
assert_raises ArgumentError do
|
202
|
+
subject
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_raise_error_if_module_name_is_nil
|
207
|
+
@module_name = nil
|
208
|
+
assert_raises ArgumentError do
|
209
|
+
subject
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_raise_error_if_files_are_empty
|
214
|
+
@files = []
|
215
|
+
|
216
|
+
assert_raises ArgumentError do
|
217
|
+
subject
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_raise_error_if_files_are_not_all_strings
|
222
|
+
@files = [:test, 1]
|
223
|
+
|
224
|
+
assert_raises ArgumentError do
|
225
|
+
subject
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_raise_error_if_files_is_nil
|
230
|
+
@files = nil
|
231
|
+
|
232
|
+
assert_raises ArgumentError do
|
233
|
+
subject
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_raise_error_if_regions_are_empty
|
238
|
+
@regions = []
|
239
|
+
|
240
|
+
assert_raises ArgumentError do
|
241
|
+
subject
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_raise_error_if_regions_is_nil
|
246
|
+
@regions = nil
|
247
|
+
|
248
|
+
assert_raises ArgumentError do
|
249
|
+
subject
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def test_raise_error_if_month_strings_are_empty
|
254
|
+
@month_strings = []
|
255
|
+
|
256
|
+
assert_raises ArgumentError do
|
257
|
+
subject
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_raise_error_if_month_strings_is_nil
|
262
|
+
@month_strings = nil
|
263
|
+
|
264
|
+
assert_raises ArgumentError do
|
265
|
+
subject
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
@@ -11,7 +11,7 @@ class ParserCustomMethodTests < Test::Unit::TestCase
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_parse_happy_single_method
|
14
|
-
input = {"custom_method"=>{"arguments"=>"year", "
|
14
|
+
input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}}
|
15
15
|
@validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(true)
|
16
16
|
|
17
17
|
result = @parser.call(input)
|
@@ -28,7 +28,7 @@ class ParserCustomMethodTests < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_call_happy_with_multiple_methods
|
31
|
-
input = {"custom_method"=>{"arguments"=>"year", "
|
31
|
+
input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}, "second_method"=>{"arguments"=>"month","ruby"=>"source"}}
|
32
32
|
@validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(true)
|
33
33
|
@validator.expects(:valid?).with({:name => "second_method", :arguments => "month", :source => "source"}).returns(true)
|
34
34
|
|
@@ -59,7 +59,7 @@ class ParserCustomMethodTests < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_call_raises_error_if_validator_returns_false_for_single_method
|
62
|
-
input = {"custom_method"=>{"arguments"=>"year", "
|
62
|
+
input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}}
|
63
63
|
@validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(false)
|
64
64
|
|
65
65
|
assert_raises ArgumentError do
|
@@ -68,7 +68,7 @@ class ParserCustomMethodTests < Test::Unit::TestCase
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_call_raises_error_if_validator_returns_false_for_one_of_multiple_methods
|
71
|
-
input = {"custom_method"=>{"arguments"=>"year", "
|
71
|
+
input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}, "second_method"=>{"arguments"=>"month","ruby"=>"source"}}
|
72
72
|
@validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(true)
|
73
73
|
@validator.expects(:valid?).with({:name => "second_method", :arguments => "month", :source => "source"}).returns(false)
|
74
74
|
|