bahai_date 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,7 @@
1
- require 'bahai_date/day'
2
- require 'bahai_date/weekday'
3
- require 'bahai_date/occasion_factory'
4
-
5
1
  module BahaiDate
6
-
7
2
  describe Day do
8
3
 
9
- it "can be created given a number from 1 to 19" do
4
+ it 'can be created given a number from 1 to 19' do
10
5
  expect(Day.new(1)).to_not be_nil
11
6
  expect(Day.new(19)).to_not be_nil
12
7
  end
@@ -24,45 +19,43 @@ module BahaiDate
24
19
 
25
20
  subject(:day) { Day.new(1) }
26
21
 
27
- it "can be converted to string" do
28
- expect(day.to_s).to eq "Baha"
22
+ it 'can be converted to string' do
23
+ expect(day.to_s).to eq 'Baha'
29
24
  end
30
25
 
31
- it "provides access to the day number" do
26
+ it 'provides access to the day number' do
32
27
  expect(day.number).to be 1
33
28
  end
34
29
 
35
- it "provides access to the translated title" do
36
- expect(day.translation).to eq "Splendour"
30
+ it 'provides access to the translated title' do
31
+ expect(day.translation).to eq 'Splendour'
37
32
  end
38
33
 
39
- it "provides access to the title in HTML" do
40
- expect(day.html).to eq "Bahá"
34
+ it 'provides access to the title in HTML' do
35
+ expect(day.html).to eq 'Bahá'
41
36
  end
42
37
 
43
- context "working with the weekday" do
44
- it "is initially nil" do
38
+ context 'working with the weekday' do
39
+ it 'is initially nil' do
45
40
  expect(day.weekday).to be_nil
46
41
  end
47
42
 
48
- it "can be set" do
49
- weekday = day.set_weekday(Weekday.new(1))
43
+ it 'can be set' do
44
+ weekday = day.weekday = Weekday.new(1)
50
45
  expect(day.weekday).to be weekday
51
46
  end
52
47
  end
53
48
 
54
- context "working with the occasions" do
55
- it "is initially nil" do
49
+ context 'working with the occasions' do
50
+ it 'is initially nil' do
56
51
  expect(day.occasions).to be_nil
57
52
  end
58
53
 
59
- it "can be set" do
60
- occasions = day.set_occasions(OccasionFactory.new(1, 1, 1).occasions)
54
+ it 'can be set' do
55
+ occasions = day.occasions = OccasionFactory.new(1, 1, 1).occasions
61
56
  expect(day.occasions).to be occasions
62
57
  end
63
58
  end
64
59
 
65
-
66
60
  end
67
-
68
61
  end
@@ -1,9 +1,6 @@
1
- require 'bahai_date/month'
2
-
3
1
  module BahaiDate
4
-
5
2
  describe Month do
6
- it "can be created given a number from 1 to 19 or -1" do
3
+ it 'can be created given a number from 1 to 19 or -1' do
7
4
  expect(Month.new(1)).to_not be_nil
8
5
  expect(Month.new(19)).to_not be_nil
9
6
  expect(Month.new(-1)).to_not be_nil
@@ -23,53 +20,52 @@ module BahaiDate
23
20
  ArgumentError, "'0' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha.")
24
21
  end
25
22
 
26
- context "when created using -1" do
23
+ context 'when created using -1' do
27
24
 
28
- it "has a title of Ayyam-i-Ha" do
25
+ it 'has a title of Ayyam-i-Ha' do
29
26
  month = Month.new(-1)
30
27
 
31
- expect(month.to_s).to eq "Ayyam-i-Ha"
28
+ expect(month.to_s).to eq 'Ayyam-i-Ha'
32
29
  end
33
30
  end
34
31
 
35
32
  subject(:month) { Month.new(1) }
36
33
 
37
- it "can be converted to string" do
38
- expect(month.to_s).to eq "Baha"
34
+ it 'can be converted to string' do
35
+ expect(month.to_s).to eq 'Baha'
39
36
  end
40
37
 
41
- it "provides access to the month number" do
38
+ it 'provides access to the month number' do
42
39
  expect(month.number).to be 1
43
40
  end
44
41
 
45
- it "provides access to the translated title" do
46
- expect(month.translation).to eq "Splendour"
42
+ it 'provides access to the translated title' do
43
+ expect(month.translation).to eq 'Splendour'
47
44
  end
48
45
 
49
- it "provides access to the title in HTML" do
50
- expect(month.html).to eq "Bahá"
46
+ it 'provides access to the title in HTML' do
47
+ expect(month.html).to eq 'Bahá'
51
48
  end
52
49
 
53
- context "working with a hash of days" do
54
- it "is readable" do
50
+ context 'working with a hash of days' do
51
+ it 'is readable' do
55
52
  month = Month.new(1)
56
53
  expect(month.days).to eq({})
57
54
  end
58
55
 
59
- it "can be added to" do
56
+ it 'can be added to' do
60
57
  month = Month.new(1)
61
- month.set_day(1)
58
+ month.add_day(1)
62
59
  expect(month.days[1].number).to be 1
63
60
  end
64
61
 
65
62
  it "doesn't create a new Day object if one exists" do
66
63
  month = Month.new(1)
67
- day = month.set_day(1)
68
- month.set_day(1)
64
+ day = month.add_day(1)
65
+ month.add_day(1)
69
66
  expect(month.days[1]).to be day
70
67
  end
71
68
  end
72
69
 
73
70
  end
74
-
75
71
  end
@@ -1,63 +1,60 @@
1
- require 'bahai_date/occasion_factory'
2
-
3
1
  module BahaiDate
4
-
5
2
  describe OccasionFactory do
6
3
 
7
- it "can be created given a year, month, and day" do
4
+ it 'can be created given a year, month, and day' do
8
5
  occasion_factory = OccasionFactory.new(1, 1, 1)
9
6
  expect(occasion_factory).not_to be_nil
10
7
  end
11
8
 
12
- it "provides a valid occasion for feast days" do
9
+ it 'provides a valid occasion for feast days' do
13
10
  occasions = OccasionFactory.new(1, 2, 1).occasions
14
11
  expect(occasions.first.type).to eq :feast
15
12
  end
16
13
 
17
- it "provides a valid occasion for days of fasting" do
14
+ it 'provides a valid occasion for days of fasting' do
18
15
  occasions = OccasionFactory.new(1, 19, 2).occasions
19
16
  expect(occasions.first.type).to eq :fasting
20
17
  end
21
18
 
22
- it "provides a valid occasion for days during ayyam-i-ha" do
19
+ it 'provides a valid occasion for days during ayyam-i-ha' do
23
20
  occasions = OccasionFactory.new(1, -1, 1).occasions
24
21
  expect(occasions.first.type).to eq :ayyam_i_ha
25
22
  end
26
23
 
27
- it "provides a valid occasion for days during the festival of ridvan" do
24
+ it 'provides a valid occasion for days during the festival of ridvan' do
28
25
  occasions = OccasionFactory.new(1, 2, 14).occasions
29
26
  expect(occasions.first.type).to eq :ridvan
30
27
  end
31
28
 
32
- it "provides a valid occasion for holy days" do
29
+ it 'provides a valid occasion for holy days' do
33
30
  occasions = OccasionFactory.new(1, 1, 1).occasions
34
31
  expect(occasions.first.type).to eq :holy
35
32
  end
36
33
 
37
- it "provides valid occasions when more than one occurs on the same day" do
34
+ it 'provides valid occasions when more than one occurs on the same day' do
38
35
  occasions = OccasionFactory.new(1, 1, 1).occasions
39
36
  expect(occasions.size).to be 2
40
37
  expect(occasions.first.type).to eq :holy
41
38
  expect(occasions.last.type).to eq :feast
42
39
  end
43
40
 
44
- context "for dates before 172 B.E." do
45
- it "provides the Declaration of the Bab on the correct day" do
41
+ context 'for dates before 172 B.E.' do
42
+ it 'provides the Declaration of the Bab on the correct day' do
46
43
  occasions = OccasionFactory.new(1, 4, 7).occasions
47
- expect(occasions.first.short_title).to eq "Declaration of the Bab"
44
+ expect(occasions.first.short_title).to eq 'Declaration of the Bab'
48
45
 
49
46
  occasions = OccasionFactory.new(1, 4, 8).occasions
50
47
  expect(occasions.size).to be 0
51
48
  end
52
49
 
53
- it "provides the Martyrdom of the Bab on the correct day" do
50
+ it 'provides the Martyrdom of the Bab on the correct day' do
54
51
  occasions = OccasionFactory.new(1, 6, 16).occasions
55
- expect(occasions.first.short_title).to eq "Martyrdom of the Bab"
52
+ expect(occasions.first.short_title).to eq 'Martyrdom of the Bab'
56
53
  end
57
54
 
58
- it "provides the Birth of the Bab on the correct day" do
55
+ it 'provides the Birth of the Bab on the correct day' do
59
56
  occasions = OccasionFactory.new(1, 12, 5).occasions
60
- expect(occasions.first.short_title).to eq "Birth of the Bab"
57
+ expect(occasions.first.short_title).to eq 'Birth of the Bab'
61
58
  end
62
59
 
63
60
  it "provides the Birth of Baha'u'llah on the correct day" do
@@ -66,27 +63,26 @@ module BahaiDate
66
63
  end
67
64
  end
68
65
 
69
- context "for dates after 172 B.E." do
70
- it "provides the Declaration of the Bab on the correct day" do
66
+ context 'for dates after 172 B.E.' do
67
+ it 'provides the Declaration of the Bab on the correct day' do
71
68
  occasions = OccasionFactory.new(172, 4, 7).occasions
72
69
  expect(occasions.size).to be 0
73
70
 
74
71
  occasions = OccasionFactory.new(172, 4, 8).occasions
75
- expect(occasions.first.short_title).to eq "Declaration of the Bab"
72
+ expect(occasions.first.short_title).to eq 'Declaration of the Bab'
76
73
  end
77
74
 
78
- it "provides the Martyrdom of the Bab on the correct day" do
75
+ it 'provides the Martyrdom of the Bab on the correct day' do
79
76
  occasions = OccasionFactory.new(172, 6, 17).occasions
80
- expect(occasions.first.short_title).to eq "Martyrdom of the Bab"
77
+ expect(occasions.first.short_title).to eq 'Martyrdom of the Bab'
81
78
  end
82
79
 
83
- it "provides the Birth of the Bab on the correct day" do
80
+ it 'provides the Birth of the Bab on the correct day' do
84
81
  occasions = OccasionFactory.new(172, 13, 10).occasions
85
- expect(occasions.first.short_title).to eq "Birth of the Bab"
82
+ expect(occasions.first.short_title).to eq 'Birth of the Bab'
86
83
  end
87
84
 
88
85
  end
89
86
 
90
87
  end
91
-
92
88
  end
@@ -1,28 +1,22 @@
1
- require 'bahai_date/occasion'
2
-
3
1
  module BahaiDate
4
-
5
2
  describe Occasion do
6
3
 
7
- subject(:occasion) {
8
- Occasion.new({
9
- :type => :ayyam_i_ha,
10
- :work_suspended => false,
11
- :title => "Test title",
12
- :short_title => "Test short title",
13
- :title_html => "Test title html",
14
- :short_title_html => "Test short title html"
15
- })
16
- }
17
-
18
- it "can be created given an options hash" do
4
+ subject(:occasion) do
5
+ Occasion.new(type: :ayyam_i_ha,
6
+ work_suspended: false,
7
+ title: 'Test title',
8
+ short_title: 'Test short title',
9
+ title_html: 'Test title html',
10
+ short_title_html: 'Test short title html ')
11
+ end
12
+
13
+ it 'can be created given an options hash' do
19
14
  expect(occasion).not_to be_nil
20
15
  end
21
16
 
22
- it "exposes a work_suspended? method" do
23
- expect(occasion.work_suspended?).to be false
17
+ it 'exposes a work_suspended? method' do
18
+ expect(occasion.work_suspended?).to be false
24
19
  end
25
20
 
26
21
  end
27
-
28
22
  end
@@ -1,9 +1,6 @@
1
- require 'bahai_date/weekday'
2
-
3
1
  module BahaiDate
4
-
5
2
  describe Weekday do
6
- it "can be created given a number from 1 to 7" do
3
+ it 'can be created given a number from 1 to 7' do
7
4
  expect(Weekday.new(1)).to_not be_nil
8
5
  expect(Weekday.new(7)).to_not be_nil
9
6
  end
@@ -21,26 +18,25 @@ module BahaiDate
21
18
 
22
19
  subject(:weekday) { Weekday.new(1) }
23
20
 
24
- it "can be converted to string" do
25
- expect(weekday.to_s).to eq "Jalal"
21
+ it 'can be converted to string' do
22
+ expect(weekday.to_s).to eq 'Jalal'
26
23
  end
27
24
 
28
- it "provides access to the day number" do
25
+ it 'provides access to the day number' do
29
26
  expect(weekday.number).to be 1
30
27
  end
31
28
 
32
- it "provides access to the translated title" do
33
- expect(weekday.translation).to eq "Glory"
29
+ it 'provides access to the translated title' do
30
+ expect(weekday.translation).to eq 'Glory'
34
31
  end
35
32
 
36
- it "provides access to the title in HTML" do
37
- expect(weekday.html).to eq "Jalál"
33
+ it 'provides access to the title in HTML' do
34
+ expect(weekday.html).to eq 'Jalál'
38
35
  end
39
36
 
40
- it "provides access to the English equivalent" do
41
- expect(weekday.english_equivalent).to eq("Saturday")
37
+ it 'provides access to the English equivalent' do
38
+ expect(weekday.english_equivalent).to eq('Saturday')
42
39
  end
43
40
 
44
41
  end
45
-
46
42
  end
@@ -1,20 +1,17 @@
1
- require 'bahai_date/year_calendar'
2
-
3
1
  module BahaiDate
4
-
5
2
  describe YearCalendar do
6
3
 
7
4
  subject(:year_calendar) { YearCalendar.new(1) }
8
5
 
9
- it "can be created" do
6
+ it 'can be created' do
10
7
  expect(year_calendar).not_to be_nil
11
8
  end
12
9
 
13
- it "is an instance of year" do
10
+ it 'is an instance of year' do
14
11
  expect(year_calendar).to be_a Year
15
12
  end
16
13
 
17
- it "has months set" do
14
+ it 'has months set' do
18
15
  months = year_calendar.months
19
16
  expect(months.size).to be 20
20
17
  expect(months[-1]).not_to be_nil
@@ -22,24 +19,23 @@ module BahaiDate
22
19
  expect(months[19]).not_to be_nil
23
20
  end
24
21
 
25
- it "has days set" do
22
+ it 'has days set' do
26
23
  days = year_calendar.months[1].days
27
24
  expect(days.size).to be 19
28
25
  expect(days[1]).not_to be_nil
29
26
  expect(days[19]).not_to be_nil
30
27
  end
31
28
 
32
- it "has weekdays set" do
29
+ it 'has weekdays set' do
33
30
  day = year_calendar.months[1].days[1]
34
31
  expect(day.weekday).not_to be_nil
35
32
  expect(day.weekday.number).to be 6
36
33
  end
37
34
 
38
- it "has occasions set" do
35
+ it 'has occasions set' do
39
36
  day = year_calendar.months[1].days[1]
40
37
  expect(day.occasions.size).to be 2
41
38
  end
42
39
 
43
40
  end
44
-
45
41
  end
@@ -1,19 +1,15 @@
1
- require 'bahai_date/year_data'
2
-
3
1
  module BahaiDate
4
-
5
2
  describe YearData do
6
3
 
7
- it "supplies a Date object for Naw Ruz of a given year" do
8
- expect(YearData.nawruz_for(1844)).to eq(Date.new(1844,3,21))
4
+ it 'supplies a Date object for Naw Ruz of a given year' do
5
+ expect(YearData.nawruz_for(1844)).to eq(Date.new(1844, 3, 21))
9
6
  end
10
7
 
11
- it "determines whether a year is leap or not" do
12
- expect(YearData.is_leap?(1)).to eq(false)
13
- expect(YearData.is_leap?(4)).to eq(true)
14
- expect(YearData.is_leap?(168)).to eq(true)
8
+ it 'determines whether a year is leap or not' do
9
+ expect(YearData.leap?(1)).to eq(false)
10
+ expect(YearData.leap?(4)).to eq(true)
11
+ expect(YearData.leap?(168)).to eq(true)
15
12
  end
16
13
 
17
14
  end
18
-
19
15
  end
@@ -1,9 +1,6 @@
1
- require 'bahai_date/year'
2
-
3
1
  module BahaiDate
4
-
5
2
  describe Year do
6
- it "can be created given a number greater than or equal to 1" do
3
+ it 'can be created given a number greater than or equal to 1' do
7
4
  expect(Year.new(1)).to_not be_nil
8
5
  expect(Year.new(160)).to_not be_nil
9
6
  end
@@ -18,35 +15,35 @@ module BahaiDate
18
15
 
19
16
  subject(:year) { Year.new(1) }
20
17
 
21
- it "can be converted to string showing the B.E. number" do
22
- expect(year.to_s).to eq "1"
18
+ it 'can be converted to string showing the B.E. number' do
19
+ expect(year.to_s).to eq '1'
23
20
  end
24
21
 
25
- it "provides access to the title" do
26
- expect(year.title).to eq "Alif"
22
+ it 'provides access to the title' do
23
+ expect(year.title).to eq 'Alif'
27
24
  end
28
25
 
29
- it "provides access to the year number" do
26
+ it 'provides access to the year number' do
30
27
  expect(year.number).to be 1
31
28
  end
32
29
 
33
- it "provides access to the translated title" do
34
- expect(year.translation).to eq "A"
30
+ it 'provides access to the translated title' do
31
+ expect(year.translation).to eq 'A'
35
32
  end
36
33
 
37
- it "provides access to the title in HTML" do
38
- expect(year.html).to eq "Alif"
34
+ it 'provides access to the title in HTML' do
35
+ expect(year.html).to eq 'Alif'
39
36
  end
40
37
 
41
- it "provides access to the vahid" do
38
+ it 'provides access to the vahid' do
42
39
  expect(year.vahid).to be 1
43
40
  end
44
41
 
45
- it "provides access to the kull-i-shay" do
42
+ it 'provides access to the kull-i-shay' do
46
43
  expect(year.kull_i_shay).to be 1
47
44
  end
48
45
 
49
- it "calculates the number properly" do
46
+ it 'calculates the number properly' do
50
47
  year = Year.new(1)
51
48
  expect(year.number).to eq(1)
52
49
 
@@ -63,7 +60,7 @@ module BahaiDate
63
60
  expect(year.number).to eq(1)
64
61
  end
65
62
 
66
- it "calculates the vahid properly" do
63
+ it 'calculates the vahid properly' do
67
64
  year = Year.new(1)
68
65
  expect(year.vahid).to eq(1)
69
66
 
@@ -77,7 +74,7 @@ module BahaiDate
77
74
  expect(year.vahid).to eq(1)
78
75
  end
79
76
 
80
- it "calculates the kull-i-shay properly" do
77
+ it 'calculates the kull-i-shay properly' do
81
78
  year = Year.new(1)
82
79
  expect(year.kull_i_shay).to eq(1)
83
80
 
@@ -88,26 +85,25 @@ module BahaiDate
88
85
  expect(year.kull_i_shay).to eq(2)
89
86
  end
90
87
 
91
- context "working with a hash of months" do
92
- it "is readable" do
88
+ context 'working with a hash of months' do
89
+ it 'is readable' do
93
90
  year = Year.new(1)
94
91
  expect(year.months).to eq({})
95
92
  end
96
93
 
97
- it "can be added to" do
94
+ it 'can be added to' do
98
95
  year = Year.new(1)
99
- year.set_month(-1)
100
- expect(year.months[-1].number).to be -1
96
+ year.add_month(-1)
97
+ expect(year.months[-1].number).to be(-1)
101
98
  end
102
99
 
103
100
  it "doesn't create a new Month object if one exists" do
104
101
  year = Year.new(1)
105
- month = year.set_month(1)
106
- year.set_month(1)
102
+ month = year.add_month(1)
103
+ year.add_month(1)
107
104
  expect(year.months[1]).to be month
108
105
  end
109
106
  end
110
107
 
111
108
  end
112
-
113
109
  end