calendarium-romanum 0.3.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/.rubocop.yml +47 -0
- data/.travis.yml +20 -0
- data/.yardopts +3 -0
- data/CHANGELOG.md +340 -0
- data/Gemfile +25 -0
- data/Gemfile.lock +86 -0
- data/README.md +515 -0
- data/Rakefile +9 -0
- data/bin/calendariumrom +4 -1
- data/calendarium-romanum.gemspec +26 -0
- data/config/locales/cs.yml +17 -1
- data/config/locales/en.yml +28 -14
- data/config/locales/es.yml +90 -0
- data/config/locales/fr.yml +90 -0
- data/config/locales/it.yml +18 -2
- data/config/locales/la.yml +17 -1
- data/data/README.md +43 -1
- data/data/czech-brno-cs.txt +4 -6
- data/data/czech-budejovice-cs.txt +4 -6
- data/data/czech-cechy-cs.txt +4 -5
- data/data/czech-cs.txt +237 -234
- data/data/czech-hradec-cs.txt +3 -5
- data/data/czech-litomerice-cs.txt +5 -7
- data/data/czech-morava-cs.txt +4 -5
- data/data/czech-olomouc-cs.txt +2 -4
- data/data/czech-ostrava-cs.txt +3 -5
- data/data/czech-plzen-cs.txt +3 -5
- data/data/czech-praha-cs.txt +3 -4
- data/data/universal-en.txt +214 -211
- data/data/universal-es.txt +243 -0
- data/data/universal-fr.txt +243 -0
- data/data/universal-it.txt +214 -211
- data/data/universal-la.txt +214 -210
- data/doc/data_readme.md +2 -0
- data/doc/images/class_diagram.png +0 -0
- data/doc/images/class_diagram.puml +44 -0
- data/doc/yard_readme.rdoc +76 -0
- data/lib/calendarium-romanum.rb +30 -21
- data/lib/calendarium-romanum/abstract_date.rb +12 -0
- data/lib/calendarium-romanum/calendar.rb +207 -52
- data/lib/calendarium-romanum/cli.rb +101 -52
- data/lib/calendarium-romanum/cr.rb +16 -0
- data/lib/calendarium-romanum/data.rb +46 -18
- data/lib/calendarium-romanum/day.rb +202 -20
- data/lib/calendarium-romanum/enum.rb +24 -5
- data/lib/calendarium-romanum/enums.rb +102 -36
- data/lib/calendarium-romanum/errors.rb +4 -0
- data/lib/calendarium-romanum/ordinalizer.rb +30 -6
- data/lib/calendarium-romanum/perpetual_calendar.rb +97 -0
- data/lib/calendarium-romanum/rank.rb +43 -6
- data/lib/calendarium-romanum/sanctorale.rb +170 -24
- data/lib/calendarium-romanum/sanctorale_factory.rb +74 -3
- data/lib/calendarium-romanum/sanctorale_loader.rb +176 -0
- data/lib/calendarium-romanum/temporale.rb +251 -119
- data/lib/calendarium-romanum/temporale/celebration_factory.rb +106 -0
- data/lib/calendarium-romanum/temporale/dates.rb +117 -36
- data/lib/calendarium-romanum/temporale/extensions/christ_eternal_priest.rb +18 -6
- data/lib/calendarium-romanum/transfers.rb +20 -1
- data/lib/calendarium-romanum/util.rb +36 -3
- data/lib/calendarium-romanum/version.rb +5 -1
- metadata +29 -21
- data/lib/calendarium-romanum/sanctoraleloader.rb +0 -115
- data/spec/abstract_date_spec.rb +0 -62
- data/spec/calendar_spec.rb +0 -352
- data/spec/cli_spec.rb +0 -26
- data/spec/data_spec.rb +0 -23
- data/spec/date_spec.rb +0 -61
- data/spec/dates_spec.rb +0 -45
- data/spec/enum_spec.rb +0 -51
- data/spec/i18n_spec.rb +0 -59
- data/spec/rank_spec.rb +0 -42
- data/spec/readme_spec.rb +0 -52
- data/spec/sanctorale_factory_spec.rb +0 -42
- data/spec/sanctorale_spec.rb +0 -167
- data/spec/sanctoraleloader_spec.rb +0 -171
- data/spec/spec_helper.rb +0 -35
- data/spec/temporale_spec.rb +0 -500
data/spec/cli_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'calendarium-romanum/cli'
|
3
|
-
|
4
|
-
describe CalendariumRomanum::CLI do
|
5
|
-
let(:path_universal_la) { File.expand_path('../../data/universal-la.txt', __FILE__) }
|
6
|
-
let(:path_universal_en) { File.expand_path('../../data/universal-en.txt', __FILE__) }
|
7
|
-
describe 'subcommands' do
|
8
|
-
describe 'errors' do
|
9
|
-
it 'raises no exception' do
|
10
|
-
described_class.start(['errors', path_universal_la])
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'fails on a non-existent file' do
|
14
|
-
expect do
|
15
|
-
described_class.start(['errors', 'does-not-exist.txt'])
|
16
|
-
end.to raise_exception Errno::ENOENT
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe 'cmp' do
|
21
|
-
it 'raises no exception' do
|
22
|
-
described_class.start(['cmp', path_universal_la, path_universal_en])
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/spec/data_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
|
3
|
-
describe CalendariumRomanum::Data do
|
4
|
-
describe 'all available data files are included' do
|
5
|
-
data_path = File.expand_path '../data', File.dirname(__FILE__)
|
6
|
-
glob = File.join(data_path, '*.txt')
|
7
|
-
|
8
|
-
Dir[glob].each do |file|
|
9
|
-
it file do
|
10
|
-
in_data = described_class.all.find {|f| f.path == file }
|
11
|
-
expect(in_data).not_to be nil
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'all can be loaded' do
|
17
|
-
described_class.each do |data|
|
18
|
-
it data.siglum do
|
19
|
-
expect { data.load }.not_to raise_exception
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/spec/date_spec.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# expectations concerning the Ruby implementation
|
4
|
-
describe Date do
|
5
|
-
describe '#-' do
|
6
|
-
it 'returns Rational' do
|
7
|
-
date_diff = Date.new(2013,5,5) - Date.new(2013,5,1)
|
8
|
-
expect(date_diff).to be_a Rational
|
9
|
-
expect(date_diff.numerator).to eq 4
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'range' do
|
14
|
-
let(:range) { (Date.new(2000,1,1) .. Date.new(2010,1,1)) }
|
15
|
-
|
16
|
-
# please note that the RSpec 'include' matcher cannot
|
17
|
-
# be used here, because it does't simply test
|
18
|
-
# if `n.include?(x)` returns true (see it's implementation)
|
19
|
-
# and it yields misleading results when testing inclusion
|
20
|
-
# of DateTime in a Date range.
|
21
|
-
describe 'test Date inclusion' do
|
22
|
-
it 'includes' do
|
23
|
-
expect(range.include?(Date.new(2005,3,3))).to be true
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'excludes' do
|
27
|
-
expect(range.include?(Date.new(1995,3,3))).to be false
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'test DateTime inclusion' do
|
32
|
-
# DateTime without time details is treated just like Date
|
33
|
-
describe 'without time specified' do
|
34
|
-
it 'excludes' do
|
35
|
-
expect(range.include?(DateTime.new(1995,3,3))).to be false
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'includes' do
|
39
|
-
expect(range.include?(DateTime.new(2005,3,3))).to be true
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# treatment of a DateTime with time details is different
|
44
|
-
describe 'with time specified' do
|
45
|
-
it 'excludes a DateTime not falling in the range' do
|
46
|
-
expect(range.include?(DateTime.new(1995,3,3,1,1,1))).to be false
|
47
|
-
end
|
48
|
-
|
49
|
-
it '... but also one *falling* in the range!' do
|
50
|
-
expect(range.include?(DateTime.new(2005,3,3,1,1,1))).to be false
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe 'inheritance' do
|
57
|
-
it 'is inherited by DateTime' do
|
58
|
-
expect(DateTime.new).to be_a Date
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/spec/dates_spec.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
|
3
|
-
describe CR::Temporale::Dates do
|
4
|
-
let(:today) { Date.new 2014, 3, 16 }
|
5
|
-
|
6
|
-
describe '#weekday_before' do
|
7
|
-
describe 'works well for all 7 weekdays' do
|
8
|
-
[
|
9
|
-
[0, Date.new(2014, 3, 9)],
|
10
|
-
[1, Date.new(2014, 3, 10)],
|
11
|
-
[2, Date.new(2014, 3, 11)],
|
12
|
-
[3, Date.new(2014, 3, 12)],
|
13
|
-
[4, Date.new(2014, 3, 13)],
|
14
|
-
[5, Date.new(2014, 3, 14)],
|
15
|
-
[6, Date.new(2014, 3, 15)],
|
16
|
-
].each do |e|
|
17
|
-
day_num, expected = e
|
18
|
-
it day_num do
|
19
|
-
actual = described_class.weekday_before(day_num, today)
|
20
|
-
expect(actual).to eq expected
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#weekday_after aliases' do
|
27
|
-
describe 'works well for all 7 weekdays' do
|
28
|
-
[
|
29
|
-
[:monday_after, Date.new(2014, 3, 17)],
|
30
|
-
[:tuesday_after, Date.new(2014, 3, 18)],
|
31
|
-
[:wednesday_after, Date.new(2014, 3, 19)],
|
32
|
-
[:thursday_after, Date.new(2014, 3, 20)],
|
33
|
-
[:friday_after, Date.new(2014, 3, 21)],
|
34
|
-
[:saturday_after, Date.new(2014, 3, 22)],
|
35
|
-
[:sunday_after, Date.new(2014, 3, 23)],
|
36
|
-
].each do |e|
|
37
|
-
method, expected = e
|
38
|
-
it method do
|
39
|
-
actual = described_class.public_send(method, today)
|
40
|
-
expect(actual).to eq expected
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/spec/enum_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
|
3
|
-
describe CalendariumRomanum::Enum do
|
4
|
-
let(:enum_values) { [:a, :b] }
|
5
|
-
|
6
|
-
let(:test_class) do
|
7
|
-
Class.new(described_class) { values { [:a, :b] } }
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '.all' do
|
11
|
-
it 'returns all values in the original order' do
|
12
|
-
expect(test_class.all).to eq enum_values
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '.each' do
|
17
|
-
it 'yields all values in the original order' do
|
18
|
-
expect {|b| test_class.each(&b) }.to yield_successive_args(*enum_values)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '[]' do
|
23
|
-
describe 'default indexing' do
|
24
|
-
it 'finds first element' do
|
25
|
-
expect(test_class[0]).to be :a
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'finds last element' do
|
29
|
-
expect(test_class[1]).to be :b
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'returns nil for index out of range' do
|
33
|
-
expect(test_class[2]).to be nil
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'indexed by a custom property' do
|
38
|
-
let(:test_class) do
|
39
|
-
Class.new(described_class) { values(index_by: :to_s) { [1] } }
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'finds the element' do
|
43
|
-
expect(test_class['1']).to eq 1
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'returns nil for an unknown index' do
|
47
|
-
expect(test_class[1]).to be nil
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/spec/i18n_spec.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require_relative 'spec_helper'
|
3
|
-
|
4
|
-
describe 'internationalization' do
|
5
|
-
before :all do
|
6
|
-
I18n.backend.load_translations
|
7
|
-
end
|
8
|
-
|
9
|
-
let(:temporale) { CR::Temporale.new(2016) }
|
10
|
-
let(:easter_celebration) { temporale.get Date.new(2017, 4, 16) }
|
11
|
-
|
12
|
-
describe 'supported locales' do
|
13
|
-
before :each do
|
14
|
-
@last_locale = I18n.locale
|
15
|
-
I18n.locale = locale
|
16
|
-
end
|
17
|
-
|
18
|
-
after :each do
|
19
|
-
I18n.locale = @last_locale
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'English' do
|
23
|
-
let(:locale) { 'en' }
|
24
|
-
|
25
|
-
it 'translates Temporale feast names' do
|
26
|
-
expect(easter_celebration.title).to eq 'Easter Sunday of the Resurrection of the Lord'
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'translates rank names' do
|
30
|
-
rank = CR::Ranks::SUNDAY_UNPRIVILEGED
|
31
|
-
expect(rank.desc).to eq 'Unprivileged Sundays'
|
32
|
-
expect(rank.short_desc).to eq 'Sunday'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'Czech' do
|
37
|
-
let(:locale) { 'cs' }
|
38
|
-
|
39
|
-
it 'translates Temporale feast names' do
|
40
|
-
expect(easter_celebration.title).to eq 'Zmrtvýchvstání Páně'
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'translates rank names' do
|
44
|
-
rank = CR::Ranks::SUNDAY_UNPRIVILEGED
|
45
|
-
expect(rank.desc).to eq 'Neprivilegované neděle'
|
46
|
-
expect(rank.short_desc).to eq 'neděle'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'unsupported locale' do
|
52
|
-
# I will be most happy when this locale one day moves to the 'supported' branch!
|
53
|
-
let(:locale) { 'de' }
|
54
|
-
|
55
|
-
it 'attemt to switch to it fails by default' do
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
data/spec/rank_spec.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
|
3
|
-
describe CR::Rank do
|
4
|
-
describe 'comparison' do
|
5
|
-
it 'memorial x ferial' do
|
6
|
-
expect(CR::Ranks::MEMORIAL_GENERAL).to be > CR::Ranks::FERIAL
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '[]' do
|
11
|
-
it 'has all existing instances indexed by rank number' do
|
12
|
-
expect(CR::Ranks[1.1]).to eq CR::Ranks::TRIDUUM
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#<' do
|
17
|
-
it { expect(CR::Ranks[1.2]).to be < CR::Ranks[1.1] }
|
18
|
-
it { expect(CR::Ranks[1.1]).not_to be < CR::Ranks[1.2] }
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#>' do
|
22
|
-
it { expect(CR::Ranks[1.1]).to be > CR::Ranks[1.2] }
|
23
|
-
it { expect(CR::Ranks[1.2]).not_to be > CR::Ranks[1.1] }
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#==' do
|
27
|
-
it { expect(CR::Ranks[1.2]).to be == CR::Ranks[1.2] }
|
28
|
-
it { expect(CR::Ranks[1.2]).not_to be == CR::Ranks[1.1] }
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#desc' do
|
32
|
-
it { expect(CR::Ranks[1.1].desc).to have_translation 'Easter triduum' }
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#short_desc' do
|
36
|
-
it 'is not always set' do
|
37
|
-
expect(CR::Ranks[1.1].short_desc).to be_nil
|
38
|
-
end
|
39
|
-
|
40
|
-
it { expect(CR::Ranks[2.8].short_desc).to have_translation 'feast' }
|
41
|
-
end
|
42
|
-
end
|
data/spec/readme_spec.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class MarkdownDocument
|
4
|
-
def initialize(str)
|
5
|
-
@str = str
|
6
|
-
end
|
7
|
-
|
8
|
-
def each_ruby_example
|
9
|
-
example = nil
|
10
|
-
line = nil
|
11
|
-
@str.each_line.with_index(1) do |l, i|
|
12
|
-
if example.nil?
|
13
|
-
if example_beginning?(l)
|
14
|
-
example = ''
|
15
|
-
line = i + 1
|
16
|
-
end
|
17
|
-
elsif example_end?(l)
|
18
|
-
yield example, line
|
19
|
-
example = nil
|
20
|
-
else
|
21
|
-
example += l
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
protected
|
27
|
-
|
28
|
-
def example_beginning?(line)
|
29
|
-
line =~ /^```ruby/
|
30
|
-
end
|
31
|
-
|
32
|
-
def example_end?(line)
|
33
|
-
line =~ /```/
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
%w(README.md data/README.md).each do |path|
|
38
|
-
describe path do
|
39
|
-
readme_path = File.expand_path('../../' + path, __FILE__)
|
40
|
-
readme = File.read readme_path
|
41
|
-
doc = MarkdownDocument.new readme
|
42
|
-
|
43
|
-
doc.each_ruby_example do |code, line|
|
44
|
-
describe "example L#{line}" do
|
45
|
-
it 'executes without failure' do
|
46
|
-
cls = Class.new
|
47
|
-
cls.class_eval(code, readme_path, line)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe CR::SanctoraleFactory do
|
5
|
-
describe '.create_layered'
|
6
|
-
|
7
|
-
describe '.load_layered_from_files' do
|
8
|
-
before :each do
|
9
|
-
files = %w(czech-cs.txt czech-cechy-cs.txt czech-budejovice-cs.txt).collect do |f|
|
10
|
-
File.join(File.expand_path('../data', File.dirname(__FILE__)), f)
|
11
|
-
end
|
12
|
-
@s = described_class.load_layered_from_files(*files)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'has celebrations from the first file' do
|
16
|
-
dd = @s.get 9, 28
|
17
|
-
expect(dd.size).to eq 1
|
18
|
-
|
19
|
-
d = dd.first
|
20
|
-
expect(d.rank).to eq CR::Ranks::SOLEMNITY_PROPER
|
21
|
-
expect(d.title).to eq 'Sv. Václava, mučedníka, hlavního patrona českého národa'
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'has celebrations from the second file' do
|
25
|
-
dd = @s.get 7, 4
|
26
|
-
expect(dd.size).to eq 1
|
27
|
-
|
28
|
-
d = dd.first
|
29
|
-
expect(d.rank).to eq CR::Ranks::MEMORIAL_PROPER
|
30
|
-
expect(d.title).to eq 'Sv. Prokopa, opata'
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'celebrations from the last file win' do
|
34
|
-
dd = @s.get 12, 22
|
35
|
-
expect(dd.size).to eq 1
|
36
|
-
|
37
|
-
d = dd.first
|
38
|
-
expect(d.rank).to eq CR::Ranks::FEAST_PROPER
|
39
|
-
expect(d.title).to eq 'Výročí posvěcení katedrály sv. Mikuláše'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/spec/sanctorale_spec.rb
DELETED
@@ -1,167 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe CR::Sanctorale do
|
4
|
-
before :each do
|
5
|
-
@s = described_class.new
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '#get' do
|
9
|
-
describe 'for empty day' do
|
10
|
-
it 'returns an Array' do
|
11
|
-
expect(@s.get(1,3)).to be_an Array
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'for unempty day' do
|
16
|
-
before :each do
|
17
|
-
@c = CR::Celebration.new('S. Antonii, abbatis', CR::Ranks::MEMORIAL_GENERAL)
|
18
|
-
@s.add 1, 17, @c
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'get by month, day' do
|
22
|
-
expect(@s.get(1, 17)).to eq [@c]
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'get by Date' do
|
26
|
-
expect(@s.get(Date.new(2014, 1, 17))).to eq [@c]
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'may have more CR::Celebrations for a day' do
|
30
|
-
[
|
31
|
-
'S. Fabiani, papae et martyris',
|
32
|
-
'S. Sebastiani, martyris'
|
33
|
-
].each {|t| @s.add 1, 20, CR::Celebration.new(t, CR::Ranks::MEMORIAL_OPTIONAL) }
|
34
|
-
expect(@s.get(1, 20).size).to eq 2
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#add' do
|
40
|
-
it 'adds a CR::Celebration to one month only' do
|
41
|
-
@s.add 1, 17, CR::Celebration.new('S. Antonii, abbatis', CR::Ranks::MEMORIAL_GENERAL)
|
42
|
-
expect(@s.get(2, 17)).to be_empty
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'does not allow month 0' do
|
46
|
-
expect { @s.add 0, 1, CR::Celebration.new('S. Nullius') }.to raise_exception RangeError
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'does not allow month higher than 12' do
|
50
|
-
expect { @s.add 13, 1, CR::Celebration.new('S. Nullius') }.to raise_exception RangeError
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'adds solemnity to a dedicated container' do
|
54
|
-
expect { @s.add 1, 13, CR::Celebration.new('S. Nullius', CR::Ranks::SOLEMNITY_PROPER) }.to change { @s.solemnities.size }.by 1
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'does not add non-solemnity to solemnities' do
|
58
|
-
expect { @s.add 1, 13, CR::Celebration.new('S. Nullius') }.not_to change { @s.solemnities.size }
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'multiple celebrations on a single day' do
|
62
|
-
it 'succeeds for any number of optional memorials' do
|
63
|
-
expect do
|
64
|
-
@s.add 1, 13, CR::Celebration.new('S. Nullius', CR::Ranks::MEMORIAL_OPTIONAL)
|
65
|
-
@s.add 1, 13, CR::Celebration.new('S. Ignoti', CR::Ranks::MEMORIAL_OPTIONAL)
|
66
|
-
end.not_to raise_exception
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'fails when adding a non-optional memorial' do
|
70
|
-
expect do
|
71
|
-
@s.add 1, 13, CR::Celebration.new('S. Nullius', CR::Ranks::MEMORIAL_OPTIONAL)
|
72
|
-
@s.add 1, 13, CR::Celebration.new('S. Ignoti', CR::Ranks::MEMORIAL_GENERAL)
|
73
|
-
end.to raise_exception ArgumentError
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'fails when adding to a non-optional memorial' do
|
77
|
-
expect do
|
78
|
-
@s.add 1, 13, CR::Celebration.new('S. Nullius', CR::Ranks::MEMORIAL_GENERAL)
|
79
|
-
@s.add 1, 13, CR::Celebration.new('S. Ignoti', CR::Ranks::MEMORIAL_OPTIONAL)
|
80
|
-
end.to raise_exception ArgumentError
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe '#replace' do
|
86
|
-
it 'replaces the original celebration(s)' do
|
87
|
-
nemo = CR::Celebration.new('S. Nullius')
|
88
|
-
nonus = CR::Celebration.new('S. Noni', CR::Ranks::SOLEMNITY_PROPER)
|
89
|
-
|
90
|
-
@s.add 1, 13, nemo
|
91
|
-
@s.replace 1, 13, [nonus]
|
92
|
-
|
93
|
-
expect(@s.get(1, 13)).to eq [nonus]
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'adds solemnity to a dedicated container' do
|
97
|
-
nonus = CR::Celebration.new('S. Noni', CR::Ranks::SOLEMNITY_PROPER)
|
98
|
-
expect do
|
99
|
-
@s.replace 1, 13, [nonus]
|
100
|
-
end.to change { @s.solemnities.size }.by 1
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'removes solemnity' do
|
104
|
-
nemo = CR::Celebration.new('S. Nullius', CR::Ranks::SOLEMNITY_PROPER)
|
105
|
-
nonus = CR::Celebration.new('S. Noni')
|
106
|
-
|
107
|
-
@s.add 1, 13, nemo
|
108
|
-
expect do
|
109
|
-
@s.replace 1, 13, [nonus]
|
110
|
-
end.to change { @s.solemnities.size }.by -1
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe '#update' do
|
115
|
-
before :each do
|
116
|
-
@s2 = described_class.new
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'adds entries from the argument to receiver' do
|
120
|
-
@s2.add 1, 17, CR::Celebration.new('S. Antonii, abbatis', CR::Ranks::MEMORIAL_GENERAL)
|
121
|
-
|
122
|
-
expect(@s).to be_empty
|
123
|
-
@s.update @s2
|
124
|
-
expect(@s.size).to eq 1
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'overwrites eventual previous content of the day' do
|
128
|
-
@s.add 1, 17, CR::Celebration.new('S. Antonii, abbatis', CR::Ranks::MEMORIAL_GENERAL)
|
129
|
-
cele = CR::Celebration.new('S. Nulius, monachi')
|
130
|
-
@s2.add 1, 17, cele
|
131
|
-
|
132
|
-
@s.update @s2
|
133
|
-
expect(@s.get(1, 17)).to eq [cele]
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe '#size' do
|
138
|
-
it 'knows when the Sanctorale is empty' do
|
139
|
-
expect(@s.size).to eq 0
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'knows when there is something' do
|
143
|
-
@s.add 1, 17, CR::Celebration.new('S. Antonii, abbatis', CR::Ranks::MEMORIAL_GENERAL)
|
144
|
-
expect(@s.size).to eq 1
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
describe '#empty?' do
|
149
|
-
it 'is empty at the beginning' do
|
150
|
-
expect(@s).to be_empty
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'is never more empty once a record is entered' do
|
154
|
-
@s.add 1, 17, CR::Celebration.new('S. Antonii, abbatis', CR::Ranks::MEMORIAL_GENERAL)
|
155
|
-
expect(@s).not_to be_empty
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
describe '#each_day' do
|
160
|
-
it 'yields each date and corresponding CR::Celebrations' do
|
161
|
-
cele = CR::Celebration.new('S. Antonii, abbatis', CR::Ranks::MEMORIAL_GENERAL)
|
162
|
-
@s.add 1, 17, cele
|
163
|
-
|
164
|
-
expect {|block| @s.each_day(&block) }.to yield_with_args(CR::AbstractDate.new(1, 17), [cele])
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|