calendarium-romanum 0.2.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +5 -5
  2. data/bin/calendariumrom +4 -1
  3. data/config/locales/cs.yml +54 -2
  4. data/config/locales/en.yml +64 -14
  5. data/config/locales/es.yml +90 -0
  6. data/config/locales/fr.yml +90 -0
  7. data/config/locales/it.yml +54 -4
  8. data/config/locales/la.yml +52 -2
  9. data/data/README.md +105 -5
  10. data/data/czech-brno-cs.txt +11 -5
  11. data/data/czech-budejovice-cs.txt +11 -5
  12. data/data/czech-cechy-cs.txt +11 -5
  13. data/data/czech-cs.txt +243 -234
  14. data/data/czech-hradec-cs.txt +10 -4
  15. data/data/czech-litomerice-cs.txt +12 -6
  16. data/data/czech-morava-cs.txt +11 -5
  17. data/data/czech-olomouc-cs.txt +9 -3
  18. data/data/czech-ostrava-cs.txt +10 -4
  19. data/data/czech-plzen-cs.txt +10 -4
  20. data/data/czech-praha-cs.txt +10 -3
  21. data/data/universal-en.txt +218 -212
  22. data/data/universal-es.txt +243 -0
  23. data/data/universal-fr.txt +243 -0
  24. data/data/universal-it.txt +218 -212
  25. data/data/universal-la.txt +218 -211
  26. data/lib/calendarium-romanum.rb +30 -18
  27. data/lib/calendarium-romanum/abstract_date.rb +12 -0
  28. data/lib/calendarium-romanum/calendar.rb +210 -48
  29. data/lib/calendarium-romanum/cli.rb +101 -52
  30. data/lib/calendarium-romanum/cr.rb +16 -0
  31. data/lib/calendarium-romanum/data.rb +46 -18
  32. data/lib/calendarium-romanum/day.rb +200 -21
  33. data/lib/calendarium-romanum/enum.rb +24 -5
  34. data/lib/calendarium-romanum/enums.rb +123 -37
  35. data/lib/calendarium-romanum/errors.rb +4 -0
  36. data/lib/calendarium-romanum/ordinalizer.rb +61 -0
  37. data/lib/calendarium-romanum/perpetual_calendar.rb +97 -0
  38. data/lib/calendarium-romanum/rank.rb +43 -6
  39. data/lib/calendarium-romanum/sanctorale.rb +142 -22
  40. data/lib/calendarium-romanum/sanctorale_factory.rb +74 -3
  41. data/lib/calendarium-romanum/sanctorale_loader.rb +176 -0
  42. data/lib/calendarium-romanum/temporale.rb +296 -251
  43. data/lib/calendarium-romanum/temporale/celebration_factory.rb +106 -0
  44. data/lib/calendarium-romanum/temporale/dates.rb +232 -0
  45. data/lib/calendarium-romanum/temporale/extensions/christ_eternal_priest.rb +37 -0
  46. data/lib/calendarium-romanum/transfers.rb +43 -6
  47. data/lib/calendarium-romanum/util.rb +36 -3
  48. data/lib/calendarium-romanum/version.rb +5 -1
  49. data/spec/abstract_date_spec.rb +11 -3
  50. data/spec/calendar_spec.rb +645 -188
  51. data/spec/celebration_factory_spec.rb +40 -0
  52. data/spec/celebration_spec.rb +67 -0
  53. data/spec/cli_spec.rb +154 -11
  54. data/spec/colour_spec.rb +22 -0
  55. data/spec/data_spec.rb +26 -3
  56. data/spec/date_parser_spec.rb +68 -0
  57. data/spec/date_spec.rb +8 -8
  58. data/spec/dates_spec.rb +73 -0
  59. data/spec/day_spec.rb +151 -0
  60. data/spec/i18n_spec.rb +11 -2
  61. data/spec/ordinalizer_spec.rb +44 -0
  62. data/spec/perpetual_calendar_spec.rb +125 -0
  63. data/spec/rank_spec.rb +42 -7
  64. data/spec/readme_spec.rb +18 -10
  65. data/spec/sanctorale_factory_spec.rb +113 -9
  66. data/spec/sanctorale_loader_spec.rb +229 -0
  67. data/spec/sanctorale_spec.rb +176 -62
  68. data/spec/season_spec.rb +22 -0
  69. data/spec/spec_helper.rb +27 -1
  70. data/spec/temporale_spec.rb +473 -154
  71. data/spec/year_spec.rb +25 -0
  72. metadata +42 -7
  73. data/lib/calendarium-romanum/sanctoraleloader.rb +0 -104
  74. data/spec/sanctoraleloader_spec.rb +0 -171
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe CR::Season do
4
+ CR::Seasons.each do |season|
5
+ describe season do
6
+ describe '#name' do
7
+ it { expect(season.name).to have_translation }
8
+ end
9
+ end
10
+ end
11
+
12
+ describe 'indexing' do
13
+ it 'is indexed by symbol' do
14
+ expect(CR::Seasons[:lent]).to be CR::Seasons::LENT
15
+ end
16
+ end
17
+
18
+ describe '#to_s' do
19
+ it { expect(CR::Seasons::LENT.to_s)
20
+ .to eq '#<CalendariumRomanum::Season lent>' }
21
+ end
22
+ end
@@ -1,3 +1,10 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter 'lib/calendarium-romanum/cli.rb'
4
+ end
5
+
6
+ require 'aruba/rspec'
7
+
1
8
  # This file was generated by the `rspec --init` command. Conventionally, all
2
9
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
10
  # Require this file using `require "spec_helper"` to ensure that it is only
@@ -5,7 +12,6 @@
5
12
  #
6
13
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
14
  RSpec.configure do |config|
8
- config.treat_symbols_as_metadata_keys_with_true_values = true
9
15
  config.run_all_when_everything_filtered = true
10
16
  config.filter_run :focus
11
17
 
@@ -16,5 +22,25 @@ RSpec.configure do |config|
16
22
  config.order = 'random'
17
23
  end
18
24
 
25
+ RSpec::Matchers.define :have_translation do |expected, locale|
26
+ match do |actual|
27
+ locale ||= :en
28
+ if expected && I18n.locale == locale
29
+ actual == expected
30
+ else
31
+ # with locale different from the one the spec is written for
32
+ # just test that the string isn't left untranslated
33
+ !(actual.nil? || actual.empty? || actual.include?('translation missing'))
34
+ end
35
+ end
36
+ end
37
+
19
38
  require 'calendarium-romanum'
20
39
  CR = CalendariumRomanum
40
+
41
+ I18n.enforce_available_locales = true
42
+ I18n.locale = ENV['LOCALE'] || :en
43
+
44
+ # make the gem's executable(s) easily available for aruba
45
+ gem_bin = File.expand_path('../../bin', __FILE__)
46
+ ENV['PATH'] = "#{gem_bin}:#{ENV['PATH']}"
@@ -1,11 +1,12 @@
1
+ # coding: utf-8
1
2
  require_relative 'spec_helper'
2
3
 
3
4
  describe CR::Temporale do
5
+ let(:t12) { described_class.new 2012 }
6
+ let(:t13) { described_class.new 2013 }
7
+ let(:t) { t12 }
4
8
 
5
- before :all do
6
- @t = @t12 = described_class.new 2012
7
- @t13 = described_class.new 2013
8
- end
9
+ let(:factory) { CR::Temporale::CelebrationFactory }
9
10
 
10
11
  describe '.liturgical_year' do
11
12
  it 'returns liturgical year for the given date' do
@@ -13,152 +14,252 @@ describe CR::Temporale do
13
14
  [Date.new(2014, 11, 1), 2013],
14
15
  [Date.new(2014, 12, 1), 2014]
15
16
  ].each do |date, year|
16
- described_class.liturgical_year(date).should eq year
17
+ expect(described_class.liturgical_year(date)).to eq year
17
18
  end
18
19
  end
19
20
  end
20
21
 
21
- describe '#weekday_before' do
22
- it 'works well for all 7 weekdays' do
23
- today = Date.new 2014, 3, 16
24
- @t.weekday_before(0, today).should eq Date.new(2014, 3, 9)
25
- @t.weekday_before(1, today).should eq Date.new(2014, 3, 10)
26
- @t.weekday_before(2, today).should eq Date.new(2014, 3, 11)
27
- @t.weekday_before(3, today).should eq Date.new(2014, 3, 12)
28
- @t.weekday_before(4, today).should eq Date.new(2014, 3, 13)
29
- @t.weekday_before(5, today).should eq Date.new(2014, 3, 14)
30
- @t.weekday_before(6, today).should eq Date.new(2014, 3, 15)
22
+ describe '.for_day' do
23
+ it 'continues the previous year\'s calendar in summer' do
24
+ expect(described_class.for_day(Date.new(2014, 6, 9))).to eq described_class.new(2013)
31
25
  end
32
- end
33
26
 
34
- describe '#weekday_after' do
35
- it 'works well for all 7 weekdays' do
36
- today = Date.new 2014, 3, 16
37
- @t.monday_after(today).should eq Date.new(2014, 3, 17)
38
- @t.tuesday_after(today).should eq Date.new(2014, 3, 18)
39
- @t.wednesday_after(today).should eq Date.new(2014, 3, 19)
40
- @t.thursday_after(today).should eq Date.new(2014, 3, 20)
41
- @t.friday_after(today).should eq Date.new(2014, 3, 21)
42
- @t.saturday_after(today).should eq Date.new(2014, 3, 22)
43
- @t.sunday_after(today).should eq Date.new(2014, 3, 23)
27
+ it 'provides the current year\'s calendar in December' do
28
+ expect(described_class.for_day(Date.new(2014, 12, 20))).to eq described_class.new(2014)
44
29
  end
45
30
  end
46
31
 
47
- describe '#advent_sunday' do
48
- it 'determines first Sunday of Advent' do
49
- [
50
- [2004, [11, 28]],
51
- [2010, [11, 28]],
52
- [2011, [11, 27]],
53
- [2012, [12, 2]],
54
- [2013, [12, 1]]
55
- ].each do |d|
56
- year, date = d
57
- @t.advent_sunday(1, year).should eq Date.new(year, *date)
32
+ describe '#==' do
33
+ let(:year) { 2012 }
34
+ let(:b) { described_class.new year }
35
+
36
+ describe 'year' do
37
+ let(:a) { described_class.new year }
38
+
39
+ it 'same' do
40
+ expect(a).to be == described_class.new(year)
41
+ end
42
+
43
+ it 'different' do
44
+ expect(a).not_to be == described_class.new(year + 1)
58
45
  end
59
46
  end
60
47
 
61
- it 'determines second Sunday of Advent' do
62
- @t.advent_sunday(2, 2013).should eq Date.new(2013,12,8)
48
+ describe 'transfers' do
49
+ let(:transfers) { [:epiphany, :ascension] }
50
+ let(:a) { described_class.new year, transfer_to_sunday: transfers }
51
+
52
+ it 'same' do
53
+ reversed_transfers = transfers.reverse # order doesn't matter
54
+ expect(a)
55
+ .to be == described_class.new(year, transfer_to_sunday: reversed_transfers)
56
+ end
57
+
58
+ it 'different' do
59
+ expect(a).not_to be == b
60
+ end
63
61
  end
64
- end
65
62
 
66
- describe '#second_advent_sunday' do
67
- # alias of advent_sunday through method_missing
63
+ describe 'extensions' do
64
+ let(:empty_enumerator) do
65
+ o = Object.new
66
+ def o.each_celebration; end
67
+ o
68
+ end
69
+
70
+ let(:extensions) do
71
+ [
72
+ CR::Temporale::Extensions::ChristEternalPriest,
73
+ empty_enumerator
74
+ ]
75
+ end
76
+
77
+ let(:a) { described_class.new year, extensions: extensions }
78
+
79
+ it 'same' do
80
+ reversed_extensions = extensions.reverse # order doesn't matter
81
+ expect(a)
82
+ .to be == described_class.new(year, extensions: reversed_extensions)
83
+ end
68
84
 
69
- it 'determines second Sunday of Advent' do
70
- @t.second_advent_sunday(2013).should eq Date.new(2013,12,8)
85
+ it 'different' do
86
+ expect(a).not_to be == b
87
+ end
71
88
  end
72
89
  end
73
90
 
74
- describe '#easter_sunday' do
75
- it 'determines Easter Sunday' do
76
- [
77
- [2003, [2004, 4, 11]],
78
- [2004, [2005, 3, 27]],
79
- [2005, [2006, 4, 16]],
80
- [2006, [2007, 4, 8]],
81
- [2014, [2015, 4, 5]]
82
- ].each do |d|
83
- year, date = d
84
- @t.easter_sunday(year).should eq Date.new(*date)
91
+ describe '#first_advent_sunday determines first Sunday of Advent' do
92
+ [
93
+ [2004, [11, 28]],
94
+ [2010, [11, 28]],
95
+ [2011, [11, 27]],
96
+ [2012, [12, 2]],
97
+ [2013, [12, 1]]
98
+ ].each do |d|
99
+ year, date = d
100
+ it year do
101
+ temporale = described_class.new(year)
102
+ expect(temporale.first_advent_sunday).to eq Date.new(year, *date)
103
+ end
104
+ end
105
+ end
106
+
107
+ describe '#easter_sunday determines Easter Sunday' do
108
+ [
109
+ [2003, [2004, 4, 11]],
110
+ [2004, [2005, 3, 27]],
111
+ [2005, [2006, 4, 16]],
112
+ [2006, [2007, 4, 8]],
113
+ [2014, [2015, 4, 5]]
114
+ ].each do |d|
115
+ year, date = d
116
+ it year do
117
+ temporale = described_class.new(year)
118
+ expect(temporale.easter_sunday).to eq Date.new(*date)
85
119
  end
86
120
  end
87
121
  end
88
122
 
89
123
  describe '#date_range' do
90
124
  it 'includes days of the year' do
91
- @t.date_range.should include Date.new(2012, 12, 3)
92
- @t.date_range.should include Date.new(2013, 11, 5)
125
+ expect(t.date_range).to include Date.new(2012, 12, 3)
126
+ expect(t.date_range).to include Date.new(2013, 11, 5)
93
127
  end
94
128
  end
95
129
 
96
130
  describe '#season' do
97
- it 'determines Advent' do
98
- @t13.season(Date.new(2013, 12, 15)).should eq :advent
99
- @t13.season(Date.new(2013, 12, 1)).should eq :advent
100
- @t13.season(Date.new(2013, 12, 24)).should eq :advent
131
+ shared_examples 'season determination' do |year_beginning, year_end|
132
+ if year_beginning
133
+ it { expect { t13.season(date_beginning - 1) }.to raise_exception RangeError }
134
+ else
135
+ it { expect(t13.season(date_beginning - 1)).not_to be season }
136
+ end
137
+
138
+ it { expect(t13.season(date_beginning)).to be season }
139
+ it { expect(t13.season(date_end)).to be season }
140
+
141
+ if year_end
142
+ it { expect { t13.season(date_end + 1) }.to raise_exception RangeError }
143
+ else
144
+ it { expect(t13.season(date_end + 1)).not_to be season }
145
+ end
146
+ end
147
+
148
+ describe 'Advent' do
149
+ let(:season) { CR::Seasons::ADVENT }
150
+ let(:date_beginning) { Date.new(2013, 12, 1) }
151
+ let(:date_end) { Date.new(2013, 12, 24) }
152
+ include_examples 'season determination', true
153
+ end
154
+
155
+ describe 'Christmas' do
156
+ let(:season) { CR::Seasons::CHRISTMAS }
157
+ let(:date_beginning) { Date.new(2013, 12, 25) }
158
+ let(:date_end) { Date.new(2014, 1, 12) }
159
+ include_examples 'season determination'
160
+ end
161
+
162
+ describe 'Ordinary Time #1' do
163
+ let(:season) { CR::Seasons::ORDINARY }
164
+ let(:date_beginning) { Date.new(2014, 1, 13) }
165
+ let(:date_end) { Date.new(2014, 3, 4) }
166
+ include_examples 'season determination'
167
+ end
168
+
169
+ describe 'Lent' do
170
+ let(:season) { CR::Seasons::LENT }
171
+ let(:date_beginning) { Date.new(2014, 3, 5) }
172
+ let(:date_end) { Date.new(2014, 4, 19) }
173
+ include_examples 'season determination'
101
174
  end
102
175
 
103
- it 'determines Christmas' do
104
- @t13.season(Date.new(2013, 12, 25)).should eq :christmas
105
- @t13.season(Date.new(2014, 1, 12)).should eq :christmas
106
- @t13.season(Date.new(2014, 1, 13)).should eq :ordinary
176
+ describe 'Easter time' do
177
+ let(:season) { CR::Seasons::EASTER }
178
+ let(:date_beginning) { Date.new(2014, 4, 20) }
179
+ let(:date_end) { Date.new(2014, 6, 8) }
180
+ include_examples 'season determination'
107
181
  end
108
182
 
109
- it 'determines Lent' do
110
- @t13.season(Date.new(2014, 3, 4)).should eq :ordinary
111
- @t13.season(Date.new(2014, 3, 5)).should eq :lent
112
- @t13.season(Date.new(2014, 4, 19)).should eq :lent
113
- @t13.season(Date.new(2014, 4, 20)).should eq :easter
183
+ describe 'Ordinary Time #2' do
184
+ let(:season) { CR::Seasons::ORDINARY }
185
+ let(:date_beginning) { Date.new(2014, 6, 9) }
186
+ let(:date_end) { Date.new(2014, 11, 29) }
187
+ include_examples 'season determination', nil, true
114
188
  end
189
+ end
190
+
191
+ describe '#season_beginning' do
192
+ let(:year) { 2016 }
193
+ let(:options) { {} }
194
+ let(:t) { described_class.new(year, **options) }
195
+
196
+ describe 'unsupported season' do
197
+ it 'fails' do
198
+ season = CR::Season.new(:strawberry_season, CR::Colours::RED)
199
+ expect do
200
+ t.season_beginning season
201
+ end.to raise_exception(ArgumentError, /unsupported season/)
202
+ end
203
+ end
204
+
205
+ describe 'Ordinary Time' do
206
+ describe 'Epiphany not transferred' do
207
+ it do
208
+ expect(t.season_beginning(CR::Seasons::ORDINARY))
209
+ .to eq Date.new(2017, 1, 9)
210
+ end
211
+ end
212
+
213
+ describe 'Epiphany transferred' do
214
+ let(:t) { described_class.new(year, transfer_to_sunday: [:epiphany]) }
115
215
 
116
- it 'determines Easter time' do
117
- @t13.season(Date.new(2014, 4, 20)).should eq :easter
118
- @t13.season(Date.new(2014, 6, 8)).should eq :easter
119
- @t13.season(Date.new(2014, 6, 9)).should eq :ordinary
216
+ it do
217
+ expect(t.season_beginning(CR::Seasons::ORDINARY))
218
+ .to eq Date.new(2017, 1, 10)
219
+ end
220
+ end
120
221
  end
121
222
  end
122
223
 
123
224
  describe '#get' do
124
225
  it 'returns a Celebration' do
125
- expect(@t13.get(8, 12)).to be_a CR::Celebration
226
+ expect(t13.get(8, 12)).to be_a CR::Celebration
126
227
  end
127
228
 
128
229
  describe 'for' do
129
230
  describe 'ferial' do
130
231
  it 'in Ordinary Time' do
131
- c = @t13.get(8, 12)
232
+ c = t13.get(8, 12)
132
233
  expect(c.rank).to eq CR::Ranks::FERIAL
133
234
  expect(c.color).to eq CR::Colours::GREEN
134
235
  end
135
236
 
136
237
  it 'in Advent' do
137
- c = @t13.get(12, 12)
238
+ c = t13.get(12, 12)
138
239
  expect(c.rank).to eq CR::Ranks::FERIAL
139
240
  expect(c.color).to eq CR::Colours::VIOLET
140
241
  end
141
242
 
142
243
  it 'in the last week of Advent' do
143
- c = @t13.get(12, 23)
244
+ c = t13.get(12, 23)
144
245
  expect(c.rank).to eq CR::Ranks::FERIAL_PRIVILEGED
145
246
  expect(c.color).to eq CR::Colours::VIOLET
146
247
  end
147
248
 
148
249
  it 'in Christmas time' do
149
- c = @t13.get(1, 3)
250
+ c = t13.get(1, 3)
150
251
  expect(c.rank).to eq CR::Ranks::FERIAL
151
252
  expect(c.color).to eq CR::Colours::WHITE
152
253
  end
153
254
 
154
255
  it 'in Lent' do
155
- c = @t13.get(3, 18)
256
+ c = t13.get(3, 18)
156
257
  expect(c.rank).to eq CR::Ranks::FERIAL_PRIVILEGED
157
258
  expect(c.color).to eq CR::Colours::VIOLET
158
259
  end
159
260
 
160
261
  it 'in Easter Time' do
161
- c = @t13.get(5, 5)
262
+ c = t13.get(5, 5)
162
263
  expect(c.rank).to eq CR::Ranks::FERIAL
163
264
  expect(c.color).to eq CR::Colours::WHITE
164
265
  end
@@ -166,31 +267,31 @@ describe CR::Temporale do
166
267
 
167
268
  describe 'Sunday' do
168
269
  it 'in Ordinary Time' do
169
- c = @t13.get(8, 10)
270
+ c = t13.get(8, 10)
170
271
  expect(c.rank).to eq CR::Ranks::SUNDAY_UNPRIVILEGED
171
272
  expect(c.color).to eq CR::Colours::GREEN
172
273
  end
173
274
 
174
275
  it 'in Advent' do
175
- c = @t13.get(12, 15)
276
+ c = t13.get(12, 15)
176
277
  expect(c.rank).to eq CR::Ranks::PRIMARY
177
278
  expect(c.color).to eq CR::Colours::VIOLET
178
279
  end
179
280
 
180
281
  it 'in Christmas time' do
181
- c = @t13.get(1, 5)
282
+ c = t13.get(1, 5)
182
283
  expect(c.rank).to eq CR::Ranks::SUNDAY_UNPRIVILEGED
183
284
  expect(c.color).to eq CR::Colours::WHITE
184
285
  end
185
286
 
186
287
  it 'in Lent' do
187
- c = @t13.get(3, 23)
288
+ c = t13.get(3, 23)
188
289
  expect(c.rank).to eq CR::Ranks::PRIMARY
189
290
  expect(c.color).to eq CR::Colours::VIOLET
190
291
  end
191
292
 
192
293
  it 'in Easter Time' do
193
- c = @t13.get(5, 11)
294
+ c = t13.get(5, 11)
194
295
  expect(c.rank).to eq CR::Ranks::PRIMARY
195
296
  expect(c.color).to eq CR::Colours::WHITE
196
297
  end
@@ -198,176 +299,394 @@ describe CR::Temporale do
198
299
 
199
300
  describe 'solemnities and their cycles - ' do
200
301
  it 'end of Advent time' do
201
- c = @t13.get(12, 17)
302
+ c = t13.get(12, 17)
202
303
  expect(c.rank).to eq CR::Ranks::FERIAL_PRIVILEGED
203
304
  expect(c.colour).to eq CR::Colours::VIOLET
204
305
  end
205
306
 
206
307
  it 'Nativity' do
207
- c = @t13.get(12, 25)
308
+ c = t13.get(12, 25)
208
309
  expect(c.rank).to eq CR::Ranks::PRIMARY
209
- expect(c.title).to eq 'The Nativity of the Lord'
310
+ expect(c.title).to have_translation 'Christmas'
210
311
  expect(c.colour).to eq CR::Colours::WHITE
312
+ expect(c.symbol).to eq :nativity
313
+ expect(c.date).to eq CR::AbstractDate.new(12, 25)
211
314
  end
212
315
 
213
316
  it 'day in the octave of Nativity' do
214
- c = @t13.get(12, 27)
317
+ c = t13.get(12, 27)
215
318
  expect(c.rank).to eq CR::Ranks::FERIAL_PRIVILEGED
216
319
  expect(c.colour).to eq CR::Colours::WHITE
217
320
  end
218
321
 
219
322
  it 'Holy Family' do
220
- c = @t13.get(12, 29)
323
+ c = t13.get(12, 29)
221
324
  expect(c.rank).to eq CR::Ranks::FEAST_LORD_GENERAL
222
- expect(c.title).to eq 'The Holy Family of Jesus, Mary and Joseph'
325
+ expect(c.title).to have_translation 'The Holy Family'
223
326
  expect(c.colour).to eq CR::Colours::WHITE
224
327
  end
225
328
 
226
329
  context 'when a Sunday does not occur between Dec 25 and Jan 1' do
227
330
  it 'is Holy Family on Friday Dec 30' do
228
- @t16 = described_class.new 2016
229
- c = @t16.get(12, 30)
230
- expect(c.title).to eq 'The Holy Family of Jesus, Mary and Joseph'
331
+ t16 = described_class.new 2016
332
+ c = t16.get(12, 30)
333
+ expect(c.title).to have_translation 'The Holy Family'
231
334
  end
232
335
  end
233
336
 
234
337
  it 'Epiphany' do
235
- c = @t13.get(1, 6)
338
+ c = t13.get(1, 6)
236
339
  expect(c.rank).to eq CR::Ranks::PRIMARY
237
- expect(c.title).to eq 'The Epiphany of the Lord'
340
+ expect(c.title).to have_translation 'The Epiphany'
238
341
  expect(c.colour).to eq CR::Colours::WHITE
239
342
  end
240
343
 
241
344
  it 'Baptism of the Lord' do
242
- c = @t13.get(1, 12)
345
+ c = t13.get(1, 12)
243
346
  expect(c.rank).to eq CR::Ranks::FEAST_LORD_GENERAL
244
- expect(c.title).to eq 'The Baptism of the Lord'
347
+ expect(c.title).to have_translation 'The Baptism of the Lord'
245
348
  expect(c.colour).to eq CR::Colours::WHITE
246
349
  end
247
350
 
248
351
  it 'Ash Wednesday' do
249
- c = @t13.get(3, 5)
352
+ c = t13.get(3, 5)
250
353
  expect(c.rank).to eq CR::Ranks::PRIMARY
251
- expect(c.title).to eq 'Ash Wednesday'
354
+ expect(c.title).to have_translation 'Ash Wednesday'
252
355
  expect(c.colour).to eq CR::Colours::VIOLET
253
356
  end
254
357
 
255
358
  it 'Palm Sunday' do
256
- c = @t13.get(4, 13)
359
+ c = t13.get(4, 13)
257
360
  expect(c.rank).to eq CR::Ranks::PRIMARY
258
- expect(c.title).to eq 'Palm Sunday of the Passion of the Lord'
361
+ expect(c.title).to have_translation 'Passion Sunday (Palm Sunday)'
259
362
  expect(c.colour).to eq CR::Colours::RED
260
363
  end
261
364
 
262
365
  it 'Good Friday' do
263
- c = @t13.get(4, 18)
366
+ c = t13.get(4, 18)
264
367
  expect(c.rank).to eq CR::Ranks::TRIDUUM
265
- expect(c.title).to eq 'Friday of the Passion of the Lord'
368
+ expect(c.title).to have_translation 'Good Friday'
266
369
  expect(c.colour).to eq CR::Colours::RED
267
370
  end
268
371
 
269
372
  it 'Holy Saturday' do
270
- c = @t13.get(4, 19)
373
+ c = t13.get(4, 19)
271
374
  expect(c.rank).to eq CR::Ranks::TRIDUUM
272
- expect(c.title).to eq 'Holy Saturday'
375
+ expect(c.title).to have_translation 'Holy Saturday'
273
376
  expect(c.colour).to eq CR::Colours::VIOLET
274
377
  end
275
378
 
276
379
  it 'Resurrection' do
277
- c = @t13.get(4, 20)
380
+ c = t13.get(4, 20)
278
381
  expect(c.rank).to eq CR::Ranks::TRIDUUM
279
- expect(c.title).to eq 'Easter Sunday of the Resurrection of the Lord'
280
- expect(c.colour).to eq CR::Colours::WHITE
281
- end
282
-
283
- it 'day in the Easter Octave' do
284
- c = @t13.get(4, 22)
285
- expect(c.rank).to eq CR::Ranks::PRIMARY
382
+ expect(c.title).to have_translation 'Easter Sunday'
286
383
  expect(c.colour).to eq CR::Colours::WHITE
384
+ expect(c.symbol).to eq :easter_sunday
287
385
  end
288
386
 
289
387
  it 'Ascension' do
290
- c = @t13.get(5, 29)
388
+ c = t13.get(5, 29)
291
389
  expect(c.rank).to eq CR::Ranks::PRIMARY
292
- expect(c.title).to eq 'Ascension of the Lord'
390
+ expect(c.title).to have_translation 'The Ascension'
293
391
  expect(c.colour).to eq CR::Colours::WHITE
294
392
  end
295
393
 
296
394
  it 'Pentecost' do
297
- c = @t13.get(6, 8)
395
+ c = t13.get(6, 8)
298
396
  expect(c.rank).to eq CR::Ranks::PRIMARY
299
- expect(c.title).to eq 'Pentecost Sunday'
397
+ expect(c.title).to have_translation 'Pentecost'
300
398
  expect(c.colour).to eq CR::Colours::RED
399
+ expect(c.symbol).to eq :pentecost
301
400
  end
302
401
 
303
402
  it 'Trinity' do
304
- c = @t13.get(6, 15)
403
+ c = t13.get(6, 15)
305
404
  expect(c.rank).to eq CR::Ranks::SOLEMNITY_GENERAL
306
- expect(c.title).to eq 'The Most Holy Trinity'
405
+ expect(c.title).to have_translation 'Trinity Sunday'
307
406
  expect(c.colour).to eq CR::Colours::WHITE
308
407
  end
309
408
 
310
409
  it 'Body of Christ' do
311
- c = @t13.get(6, 19)
410
+ c = t13.get(6, 19)
312
411
  expect(c.rank).to eq CR::Ranks::SOLEMNITY_GENERAL
313
- expect(c.title).to eq 'The Most Holy Body and Blood of Christ'
412
+ expect(c.title).to have_translation 'Corpus Christi (The Body and Blood of Christ)'
314
413
  expect(c.colour).to eq CR::Colours::WHITE
315
414
  end
316
415
 
317
416
  it 'Sacred Heart' do
318
- c = @t13.get(6, 27)
417
+ c = t13.get(6, 27)
319
418
  expect(c.rank).to eq CR::Ranks::SOLEMNITY_GENERAL
320
- expect(c.title).to eq 'The Most Sacred Heart of Jesus'
419
+ expect(c.title).to have_translation 'The Sacred Heart of Jesus'
321
420
  expect(c.colour).to eq CR::Colours::WHITE
322
421
  end
323
422
 
324
423
  it 'Christ the King' do
325
- c = @t13.get(11, 23)
424
+ c = t13.get(11, 23)
326
425
  expect(c.rank).to eq CR::Ranks::SOLEMNITY_GENERAL
327
- expect(c.title).to eq 'Our Lord Jesus Christ, King of the Universe'
426
+ expect(c.title).to have_translation 'Christ The King'
328
427
  expect(c.colour).to eq CR::Colours::WHITE
329
428
  end
429
+
430
+ describe 'other locales' do
431
+ it 'Latin' do
432
+ I18n.with_locale(:la) do
433
+ c = t13.get(11, 23)
434
+ expect(c.title).to eq 'Domini nostri Iesu Christi universorum regis'
435
+ end
436
+ end
437
+
438
+ it 'Czech' do
439
+ I18n.with_locale(:cs) do
440
+ c = t13.get(11, 23)
441
+ expect(c.title).to eq 'Ježíše Krista krále'
442
+ end
443
+ end
444
+
445
+ it 'Italian' do
446
+ I18n.with_locale(:it) do
447
+ c = t13.get(11, 23)
448
+ expect(c.title).to eq "Nostro Signore Gesù Cristo Re dell'universo"
449
+ end
450
+ end
451
+ end
452
+ end
453
+
454
+ # movable sanctorale feasts don't really belong in Temporale, but ...
455
+ describe 'movable sanctorale feasts' do
456
+ it 'Immaculate Heart' do
457
+ c = t13.get(6, 28)
458
+ expect(c.title).to have_translation 'The Immaculate Heart of Mary'
459
+ expect(c.rank).to eq CR::Ranks::MEMORIAL_GENERAL
460
+ end
461
+
462
+ it 'Mary, Mother of the Church' do
463
+ # it would be an anachronism to retrieve this celebration
464
+ # from t13
465
+ t17 = described_class.new 2017
466
+ c = t17.get(5, 21)
467
+ expect(c.title).to have_translation 'Mary, Mother of the Church'
468
+ expect(c.rank).to eq CR::Ranks::MEMORIAL_GENERAL
469
+ end
470
+ end
471
+ end
472
+
473
+ describe 'titles of Sundays and ferials' do
474
+ def title_for(month, day)
475
+ t13.get(month, day).title
476
+ end
477
+
478
+ describe 'Ordinary time' do
479
+ it 'Sunday' do
480
+ expect(title_for(1, 19)).to have_translation '2nd Sunday in Ordinary Time'
481
+ end
482
+
483
+ it 'ferial' do
484
+ expect(title_for(1, 13)).to have_translation 'Monday, 1st week in Ordinary Time'
485
+ end
486
+ end
487
+
488
+ describe 'Advent' do
489
+ it 'Sunday' do
490
+ expect(title_for(12, 1)).to have_translation '1st Sunday of Advent'
491
+ end
492
+
493
+ it 'ferial' do
494
+ expect(title_for(12, 2)).to have_translation 'Monday, 1st week of Advent'
495
+ end
496
+
497
+ it 'ferial before Christmas' do
498
+ expect(title_for(12, 17)).to have_translation '17th December'
499
+ end
500
+ end
501
+
502
+ describe 'Christmas time' do
503
+ describe 'Octave of Christmas' do
504
+ it 'ferial' do
505
+ day = t13.get(12, 30)
506
+ expect(day.rank).to eq CR::Ranks::FERIAL_PRIVILEGED
507
+ expect(day.title).to have_translation '6th day of Christmas Octave'
508
+ end
509
+ end
510
+
511
+ describe 'after Octave of Christmas' do
512
+ it 'ferial' do
513
+ expect(title_for(1, 2)).to have_translation 'Thursday after Christmas Octave'
514
+ end
515
+
516
+ it 'Sunday' do
517
+ expect(title_for(1, 5)).to have_translation '2nd Sunday after the Nativity of the Lord'
518
+ end
519
+ end
520
+
521
+ describe 'after Epiphany' do
522
+ it 'ferial' do
523
+ expect(title_for(1, 7)).to have_translation 'Tuesday after Epiphany'
524
+ end
525
+ end
526
+ end
527
+
528
+ describe 'Lent' do
529
+ describe 'before first Sunday' do
530
+ it 'ferial' do
531
+ expect(title_for(3, 6)).to have_translation 'Thursday after Ash Wednesday'
532
+ end
533
+ end
534
+
535
+ it 'Sunday' do
536
+ expect(title_for(3, 9)).to have_translation '1st Sunday of Lent'
537
+ end
538
+
539
+ it 'ferial' do
540
+ expect(title_for(3, 10)).to have_translation 'Monday, 1st week of Lent'
541
+ end
542
+
543
+ describe 'Holy Week' do
544
+ it 'ferial' do
545
+ day = t13.get(4, 14)
546
+ expect(day.rank).to eq CR::Ranks::PRIMARY
547
+ expect(day.title).to have_translation 'Monday of Holy Week'
548
+ end
549
+ end
550
+ end
551
+
552
+ describe 'Easter' do
553
+ describe 'Easter Octave' do
554
+ it 'ferial' do
555
+ c = t13.get(4, 22)
556
+ expect(c.rank).to eq CR::Ranks::PRIMARY
557
+ expect(c.title).to have_translation 'Easter Tuesday'
558
+ end
559
+
560
+ it 'Sunday (the octave day)' do
561
+ c = t13.get(4, 27)
562
+ expect(c.rank).to eq CR::Ranks::PRIMARY
563
+ expect(c.title).to have_translation '2nd Sunday of Easter'
564
+ end
565
+ end
566
+
567
+ it 'Sunday' do
568
+ expect(title_for(5, 4)).to have_translation '3rd Sunday of Easter'
569
+ end
570
+
571
+ it 'ferial' do
572
+ expect(title_for(5, 5)).to have_translation 'Monday, 3rd week of Easter'
573
+ end
574
+ end
575
+
576
+ describe 'other locales' do
577
+ it 'Latin' do
578
+ I18n.with_locale(:la) do
579
+ expect(title_for(5, 5)).to eq 'Feria secunda, hebdomada III temporis paschalis'
580
+ end
581
+ end
582
+
583
+ it 'Czech' do
584
+ I18n.with_locale(:cs) do
585
+ expect(title_for(5, 5)).to eq 'Pondělí po 3. neděli velikonoční'
586
+ end
587
+ end
588
+
589
+ it 'French' do
590
+ I18n.with_locale(:fr) do
591
+ expect(title_for(5, 5)).to eq 'Lundi, 3ème semaine de Pâques'
592
+ end
593
+ end
594
+
595
+ it 'Italian' do
596
+ I18n.with_locale(:it) do
597
+ expect(title_for(5, 5)).to eq 'Lunedì, III di Pasqua'
598
+ end
599
+ end
330
600
  end
331
601
  end
332
602
  end
333
603
 
334
- describe 'initialized without a year' do
335
- before :each do
336
- @tny = described_class.new
604
+ describe 'packaged extensions' do
605
+ describe 'ChristEternalPriest' do
606
+ let(:t) { described_class.new(2016, extensions: [CR::Temporale::Extensions::ChristEternalPriest]) }
607
+
608
+ it 'adds the feast' do
609
+ I18n.with_locale(:cs) do
610
+ c = t.get(6, 8)
611
+ expect(c.title).to eq 'Ježíše Krista, nejvyššího a věčného kněze'
612
+ expect(c.rank).to eq CR::Ranks::FEAST_PROPER
613
+ expect(c.colour).to eq CR::Colours::WHITE
614
+ end
615
+ end
337
616
  end
617
+ end
618
+
619
+ describe 'Solemnities transferred to a Sunday' do
620
+ let(:year) { 2016 }
621
+ let(:transferred) { [:epiphany, :ascension, :corpus_christi] }
622
+ let(:t) { described_class.new(year, transfer_to_sunday: transferred) }
623
+ let(:t_notransfer) { described_class.new(year) }
338
624
 
339
- it 'is possible to initialize a Temporale without a year' do
340
- expect { described_class.new }.not_to raise_exception
625
+ it 'Epiphany' do
626
+ date = Date.new(2017, 1, 8)
627
+ expect(date).to be_sunday # make sure
628
+
629
+ expect(t.epiphany).to eq date
630
+
631
+ c = t.get(date)
632
+ expect(c).to eq factory.epiphany
341
633
  end
342
634
 
343
- it 'crashes when a date is requested without year' do
344
- expect { @tny.first_advent_sunday }.to raise_exception
635
+ it 'Baptism of the Lord after transferred Epiphany' do
636
+ date = Date.new(2017, 1, 9)
637
+ expect(date).to be_monday # make sure
638
+
639
+ expect(t.baptism_of_lord).to eq date
640
+
641
+ c = t.get(date)
642
+ expect(c).to eq factory.baptism_of_lord
345
643
  end
346
644
 
347
- it 'computes dates as expected if year is given' do
348
- days = %i(first_advent_sunday nativity holy_family mother_of_god
349
- epiphany baptism_of_lord ash_wednesday easter_sunday good_friday
350
- holy_saturday pentecost
351
- holy_trinity body_blood sacred_heart christ_king
645
+ describe 'Ordinary Time numbering after transferred Epiphany' do
646
+ it 'ferials correct' do
647
+ first_ot_tuesday = Date.new(2017, 1, 10)
648
+ expect(t.get(first_ot_tuesday)).to eq t_notransfer.get(first_ot_tuesday)
649
+ end
352
650
 
353
- date_range)
354
- days.each do |msg|
355
- @tny.send(msg, 2012).should eq @t12.send(msg)
651
+ it 'Sundays correct' do
652
+ second_ot_sunday = Date.new(2017, 1, 15)
653
+ expect(t.get(second_ot_sunday)).to eq t_notransfer.get(second_ot_sunday)
356
654
  end
357
655
  end
358
656
 
359
- describe '#get' do
360
- it 'always raises an exception' do
361
- # for get to work well is imoportant to have precomputed
362
- # solemnity dates. That is only possible when a year
363
- # is specified on initialization.
364
- [
365
- Date.new(2015, 1, 1),
366
- Date.new(2015, 9, 23),
367
- Date.new(2015, 3, 4)
368
- ].each do |date|
369
- expect { @tny.get(date) }.to raise_exception
370
- end
657
+ it 'Ascension' do
658
+ date = Date.new(2017, 5, 28)
659
+ expect(date).to be_sunday # make sure
660
+
661
+ expect(t.ascension).to eq date
662
+
663
+ c = t.get(date)
664
+ expect(c).to eq factory.ascension
665
+ end
666
+
667
+ it 'Corpus Christi' do
668
+ date = Date.new(2017, 6, 18)
669
+ expect(date).to be_sunday # make sure
670
+
671
+ expect(t.corpus_christi).to eq date
672
+
673
+ c = t.get(date)
674
+ expect(c).to eq factory.corpus_christi
675
+ end
676
+
677
+ it 'fails on an unsupported solemnity' do
678
+ expect do
679
+ described_class.new(2016, transfer_to_sunday: [:sacred_heart])
680
+ end.to raise_exception(RuntimeError, /not supported/)
681
+ end
682
+ end
683
+
684
+ describe 'properly setting cycle' do
685
+ t = CR::Temporale.new(2013)
686
+ t.date_range.each do |date|
687
+ it date do
688
+ c = t.get date
689
+ expect(c.cycle).to be :temporale
371
690
  end
372
691
  end
373
692
  end