bahai_date 1.4.0 → 2.0.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.
@@ -0,0 +1,31 @@
1
+ module BahaiDate
2
+ # The expected values here are the worked examples published with the
3
+ # algorithms (Meeus, _Astronomical Algorithms_), which is what makes this a
4
+ # check on the implementation rather than a snapshot of it.
5
+ describe Astro do
6
+ it "computes the vernal equinox" do
7
+ expect(Astro.date_of_vernal_equinox(1999).to_s).to eq "1999-03-21T01:46:56+00:00"
8
+ expect(Astro.date_of_vernal_equinox_low_accuracy(1999).to_s).to eq "1999-03-21T01:46:59+00:00"
9
+ end
10
+
11
+ it "computes the difference between dynamical time and UTC" do
12
+ expect(Astro.delta_T(DateTime.new(2007, 1, 1))).to be_within(1e-9).of(65.465744703125)
13
+ end
14
+
15
+ it "numbers the lunations from the first new Moon of 2000" do
16
+ expect(Astro.first_lunation_of_year(1776)).to eq(-2770)
17
+ expect(Astro.first_lunation_of_year(2007)).to eq 87
18
+ end
19
+
20
+ it "computes the date of a new Moon" do
21
+ expect(Astro.date_of_moon(87, Astro::PHASE_NEW).to_s).to eq "2007-01-19T04:01:45+00:00"
22
+ end
23
+
24
+ it "converts dynamical time to UTC" do
25
+ equinox = Astro.date_of_vernal_equinox(1999)
26
+
27
+ # ~64 seconds earlier in 1999; the sign is the point.
28
+ expect(Astro.utc(equinox).to_s).to eq "1999-03-21T01:45:52+00:00"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ require "json"
2
+
3
+ module BahaiDate
4
+ # Checks this gem against badiDate (https://github.com/janrg/badiDate), an
5
+ # independent JavaScript implementation that takes its equinoxes from the JPL
6
+ # DE405 ephemeris to 2200 and VSOP87 after, for every year it supports:
7
+ # 172-507 B.E. (2015-2351), well past the fifty years bahai.org publishes.
8
+ describe "the badiDate library's dates" do
9
+ data = JSON.parse(File.read(File.expand_path("../fixtures/badidate_dates.json", __dir__)))
10
+ years = data["years"]
11
+
12
+ it "covers 172 to 507 B.E." do
13
+ expect(years.map { |row| row["year"] }).to eq (172..507).to_a
14
+ end
15
+
16
+ it "agrees on Naw-Ruz, the Twin Holy Days and Ayyam-i-Ha for every year" do
17
+ wrong = years.filter_map do |row|
18
+ year = row["year"]
19
+ ours = {
20
+ "nawruz" => BahaiDate.new(year: year, month: 1, day: 1).gregorian_date.iso8601,
21
+ "birthBab" => Logic.twin_holy_days_date(year).iso8601,
22
+ "birthBahaullah" => (Logic.twin_holy_days_date(year) + 1).iso8601,
23
+ "ayyamiHa" => Logic.leap?(year) ? 5 : 4
24
+ }
25
+ theirs = row.slice(*ours.keys)
26
+ [year, theirs, ours] unless theirs == ours
27
+ end
28
+
29
+ expect(wrong).to be_empty, "years that differ: #{wrong.first(5).inspect}"
30
+ end
31
+ end
32
+ end
@@ -1,63 +1,86 @@
1
1
  module BahaiDate
2
2
  describe BahaiDate do
3
- it 'can be created from a year, month and day' do
3
+ it "can be created from a year, month and day" do
4
4
  bahai_date = BahaiDate.new(year: 1, month: 1, day: 1)
5
5
 
6
6
  expect(bahai_date).to_not be_nil
7
7
  end
8
8
 
9
- it 'can be created from a gregorian Date object' do
9
+ it "can be created from a gregorian Date object" do
10
10
  bahai_date = BahaiDate.new(date: Date.new(2010, 1, 1))
11
11
 
12
12
  expect(bahai_date).to_not be_nil
13
13
  end
14
14
 
15
- it 'raises an error if invalid arguments are passed to the initializer' do
15
+ it "can be created from a Time or DateTime, keeping only the date" do
16
+ from_time = BahaiDate.new(date: Time.new(2026, 11, 28, 21, 0, 0, "+10:00"))
17
+ from_datetime = BahaiDate.new(date: DateTime.new(2026, 11, 28, 21, 0, 0))
18
+
19
+ expect(from_time.gregorian_date).to eq Date.new(2026, 11, 28)
20
+ expect(from_time.gregorian_date).to be_an_instance_of(Date)
21
+ expect(from_datetime.gregorian_date).to be_an_instance_of(Date)
22
+ expect(from_time.to_s).to eq from_datetime.to_s
23
+ end
24
+
25
+ it "raises an ArgumentError for a date that is not a date" do
26
+ expect { BahaiDate.new(date: 20261128) }.to raise_error(ArgumentError, /respond to to_date/)
27
+ end
28
+
29
+ it "supports Gregorian dates up to the end of the year 1157 B.E." do
30
+ expect(BahaiDate.new(year: 1157, month: 19, day: 19).to_s).to eq "1157.19.19"
31
+ last = BahaiDate.new(year: 1157, month: 19, day: 19).gregorian_date
32
+ expect(BahaiDate.new(date: last).to_s).to eq "1157.19.19"
33
+ expect { BahaiDate.new(date: last + 1) }.to raise_error(ArgumentError, /not a valid year/)
34
+ expect { BahaiDate.new(date: Date.new(3002, 1, 1)) }.to raise_error(ArgumentError, /outside the supported range/)
35
+ expect { BahaiDate.new(date: Date.new(1_000_000, 1, 1)) }.to raise_error(ArgumentError, /outside the supported range/)
36
+ end
37
+
38
+ it "raises an error if invalid arguments are passed to the initializer" do
16
39
  expect { BahaiDate.new }.to raise_error(ArgumentError)
17
40
  expect { BahaiDate.new({}) }.to raise_error(ArgumentError)
18
41
  expect { BahaiDate.new(day: 1) }.to raise_error(ArgumentError)
19
42
  end
20
43
 
21
44
  context "when validating the Baha'i Era date" do
22
- context 'year' do
23
- it 'raises an error if less than 1' do
45
+ context "year" do
46
+ it "raises an error if less than 1" do
24
47
  expect do
25
48
  BahaiDate.new(year: 0, month: 1, day: 1)
26
49
  end.to raise_error(ArgumentError)
27
50
  end
28
51
  end
29
52
 
30
- context 'month' do
31
- it 'raises an error if 0' do
53
+ context "month" do
54
+ it "raises an error if 0" do
32
55
  expect do
33
56
  BahaiDate.new(year: 1, month: 0, day: 1)
34
57
  end.to raise_error(ArgumentError)
35
58
  end
36
- it 'raises an error if less than -1' do
59
+ it "raises an error if less than -1" do
37
60
  expect do
38
61
  BahaiDate.new(year: 1, month: -2, day: 1)
39
62
  end.to raise_error(ArgumentError)
40
63
  end
41
- it 'raises an error if greater than 19' do
64
+ it "raises an error if greater than 19" do
42
65
  expect do
43
66
  BahaiDate.new(year: 1, month: 20, day: 1)
44
67
  end.to raise_error(ArgumentError)
45
68
  end
46
69
  end
47
70
 
48
- context 'day' do
49
- it 'raises an error if less than 1' do
71
+ context "day" do
72
+ it "raises an error if less than 1" do
50
73
  expect do
51
74
  BahaiDate.new(year: 1, month: 1, day: 0)
52
75
  end.to raise_error(ArgumentError)
53
76
  end
54
- it 'raises an error if greater than 19' do
77
+ it "raises an error if greater than 19" do
55
78
  expect do
56
79
  BahaiDate.new(year: 1, month: 1, day: 20)
57
80
  end.to raise_error(ArgumentError)
58
81
  end
59
- context 'in Ayyam-i-Ha' do
60
- it 'raises an error if greater than 4 on a non-leap year' do
82
+ context "in Ayyam-i-Ha" do
83
+ it "raises an error if greater than 4 on a non-leap year" do
61
84
  expect do
62
85
  BahaiDate.new(year: 1, month: -1, day: 5)
63
86
  end.to raise_error(ArgumentError)
@@ -67,7 +90,7 @@ module BahaiDate
67
90
  BahaiDate.new(year: 4, month: -1, day: 5)
68
91
  end.not_to raise_error
69
92
  end
70
- it 'raises an error if greater than 5 on a leap year' do
93
+ it "raises an error if greater than 5 on a leap year" do
71
94
  expect do
72
95
  BahaiDate.new(year: 4, month: -1, day: 6)
73
96
  end.to raise_error(ArgumentError)
@@ -76,7 +99,7 @@ module BahaiDate
76
99
  end
77
100
  end
78
101
 
79
- it 'exposes weekday, day, month, year and gregorian_date' do
102
+ it "exposes weekday, day, month, year and gregorian_date" do
80
103
  bahai_date = BahaiDate.new(year: 1, month: 1, day: 1)
81
104
 
82
105
  expect(bahai_date.weekday).to be_an_instance_of(Weekday)
@@ -86,97 +109,97 @@ module BahaiDate
86
109
  expect(bahai_date.gregorian_date).to be_an_instance_of(Date)
87
110
  end
88
111
 
89
- context 'when converting to a gregorian date' do
90
- it 'handles the first day of the calendar' do
112
+ context "when converting to a gregorian date" do
113
+ it "handles the first day of the calendar" do
91
114
  bahai_date = BahaiDate.new(year: 1, month: 1, day: 1)
92
115
  expect(bahai_date.gregorian_date).to eq(Date.new(1844, 3, 21))
93
116
  end
94
117
 
95
- it 'handles the last day of the year' do
118
+ it "handles the last day of the year" do
96
119
  bahai_date = BahaiDate.new(year: 1, month: 19, day: 19)
97
120
  expect(bahai_date.gregorian_date).to eq(Date.new(1845, 3, 20))
98
121
  end
99
122
 
100
- it 'handles the year component' do
123
+ it "handles the year component" do
101
124
  bahai_date = BahaiDate.new(year: 2, month: 1, day: 1)
102
125
  expect(bahai_date.gregorian_date).to eq(Date.new(1845, 3, 21))
103
126
  end
104
127
 
105
- context 'in a leap year' do
106
- it 'handles the day before Ayyam-i-Ha' do
128
+ context "in a leap year" do
129
+ it "handles the day before Ayyam-i-Ha" do
107
130
  bahai_date = BahaiDate.new(year: 168, month: 18, day: 19)
108
131
  expect(bahai_date.gregorian_date).to eq(Date.new(2012, 2, 25))
109
132
  end
110
133
 
111
- it 'handles the first day of Ayyam-i-Ha' do
134
+ it "handles the first day of Ayyam-i-Ha" do
112
135
  bahai_date = BahaiDate.new(year: 168, month: -1, day: 1)
113
136
  expect(bahai_date.gregorian_date).to eq(Date.new(2012, 2, 26))
114
137
  end
115
138
 
116
- it 'handles the last day of Ayyam-i-Ha' do
139
+ it "handles the last day of Ayyam-i-Ha" do
117
140
  bahai_date = BahaiDate.new(year: 168, month: -1, day: 5)
118
141
  expect(bahai_date.gregorian_date).to eq(Date.new(2012, 3, 1))
119
142
  end
120
143
 
121
- it 'handles the first day of the month after Ayyam-i-Ha' do
144
+ it "handles the first day of the month after Ayyam-i-Ha" do
122
145
  bahai_date = BahaiDate.new(year: 168, month: 19, day: 1)
123
146
  expect(bahai_date.gregorian_date).to eq(Date.new(2012, 3, 2))
124
147
  end
125
148
  end
126
149
 
127
- context 'in a non-leap year' do
128
- it 'handles the last day of Ayyam-i-Ha' do
150
+ context "in a non-leap year" do
151
+ it "handles the last day of Ayyam-i-Ha" do
129
152
  bahai_date = BahaiDate.new(year: 169, month: -1, day: 4)
130
153
  expect(bahai_date.gregorian_date).to eq(Date.new(2013, 3, 1))
131
154
  end
132
155
  end
133
156
  end
134
157
 
135
- context 'when converting from gregorian date' do
136
- it 'handles the first day of the calendar' do
158
+ context "when converting from gregorian date" do
159
+ it "handles the first day of the calendar" do
137
160
  bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21))
138
161
  expect(bahai_date.year.bahai_era).to be 1
139
162
  expect(bahai_date.month.number).to be 1
140
163
  expect(bahai_date.day.number).to be 1
141
164
  end
142
165
 
143
- it 'handles the last day of the year' do
166
+ it "handles the last day of the year" do
144
167
  bahai_date = BahaiDate.new(date: Date.new(1845, 3, 20))
145
168
  expect(bahai_date.year.bahai_era).to be 1
146
169
  expect(bahai_date.month.number).to be 19
147
170
  expect(bahai_date.day.number).to be 19
148
171
  end
149
172
 
150
- it 'handles the year component' do
173
+ it "handles the year component" do
151
174
  bahai_date = BahaiDate.new(date: Date.new(1845, 3, 21))
152
175
  expect(bahai_date.year.bahai_era).to be 2
153
176
  expect(bahai_date.month.number).to be 1
154
177
  expect(bahai_date.day.number).to be 1
155
178
  end
156
179
 
157
- context 'in a leap year' do
158
- it 'handles the day before Ayyam-i-Ha' do
180
+ context "in a leap year" do
181
+ it "handles the day before Ayyam-i-Ha" do
159
182
  bahai_date = BahaiDate.new(date: Date.new(2012, 2, 25))
160
183
  expect(bahai_date.year.bahai_era).to be 168
161
184
  expect(bahai_date.month.number).to be 18
162
185
  expect(bahai_date.day.number).to be 19
163
186
  end
164
187
 
165
- it 'handles the first day of Ayyam-i-Ha' do
188
+ it "handles the first day of Ayyam-i-Ha" do
166
189
  bahai_date = BahaiDate.new(date: Date.new(2012, 2, 26))
167
190
  expect(bahai_date.year.bahai_era).to be 168
168
191
  expect(bahai_date.month.number).to be(-1)
169
192
  expect(bahai_date.day.number).to be 1
170
193
  end
171
194
 
172
- it 'handles the last day of Ayyam-i-Ha' do
195
+ it "handles the last day of Ayyam-i-Ha" do
173
196
  bahai_date = BahaiDate.new(date: Date.new(2012, 3, 1))
174
197
  expect(bahai_date.year.bahai_era).to be 168
175
198
  expect(bahai_date.month.number).to be(-1)
176
199
  expect(bahai_date.day.number).to be 5
177
200
  end
178
201
 
179
- it 'handles the first day of the month after Ayyam-i-Ha' do
202
+ it "handles the first day of the month after Ayyam-i-Ha" do
180
203
  bahai_date = BahaiDate.new(date: Date.new(2012, 3, 2))
181
204
  expect(bahai_date.year.bahai_era).to be 168
182
205
  expect(bahai_date.month.number).to be 19
@@ -184,8 +207,8 @@ module BahaiDate
184
207
  end
185
208
  end
186
209
 
187
- context 'in a non-leap year' do
188
- it 'handles the last day of Ayyam-i-Ha' do
210
+ context "in a non-leap year" do
211
+ it "handles the last day of Ayyam-i-Ha" do
189
212
  bahai_date = BahaiDate.new(date: Date.new(2013, 3, 1))
190
213
  expect(bahai_date.year.bahai_era).to be 169
191
214
  expect(bahai_date.month.number).to be(-1)
@@ -194,7 +217,7 @@ module BahaiDate
194
217
  end
195
218
  end
196
219
 
197
- it 'can get weekday from a gregorian date accurately' do
220
+ it "can get weekday from a gregorian date accurately" do
198
221
  bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21))
199
222
  expect(bahai_date.weekday.number).to be 6
200
223
 
@@ -220,36 +243,36 @@ module BahaiDate
220
243
  expect(bahai_date.weekday.number).to be 6
221
244
  end
222
245
 
223
- it 'can be converted to string' do
246
+ it "can be converted to string" do
224
247
  bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21))
225
- expect(bahai_date.to_s).to eq '1.1.1'
248
+ expect(bahai_date.to_s).to eq "1.1.1"
226
249
  end
227
250
 
228
- it 'can provide the date in long format' do
251
+ it "can provide the date in long format" do
229
252
  bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21))
230
- expect(bahai_date.long_format).to eq 'Istijlal 1 Baha 1 B.E.'
253
+ expect(bahai_date.long_format).to eq "Istijlal 1 Baha 1 B.E."
231
254
  end
232
255
 
233
- it 'can provide the date in short format' do
256
+ it "can provide the date in short format" do
234
257
  bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21))
235
- expect(bahai_date.short_format).to eq '1 Baha 1'
258
+ expect(bahai_date.short_format).to eq "1 Baha 1"
236
259
  end
237
260
 
238
- it 'can provide an array of occasions for a given day' do
261
+ it "can provide an array of occasions for a given day" do
239
262
  bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21))
240
263
  occasions_array = bahai_date.occasions
241
264
  expect(occasions_array.size).to be 2
242
- expect(occasions_array.first.short_title).to eq 'Naw-Ruz'
243
- expect(occasions_array.last.short_title).to eq 'Feast of Baha'
265
+ expect(occasions_array.first.short_title).to eq "Naw-Ruz"
266
+ expect(occasions_array.last.short_title).to eq "Feast of Baha"
244
267
  end
245
268
 
246
- it 'can add to date, returning itself' do
269
+ it "can add to date, returning itself" do
247
270
  bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21))
248
271
  bahai_date += 1
249
272
  expect(bahai_date.gregorian_date).to eq Date.new(1844, 3, 22)
250
273
  end
251
274
 
252
- it 'can subtract from the date, returning itself' do
275
+ it "can subtract from the date, returning itself" do
253
276
  bahai_date = BahaiDate.new(date: Date.new(1844, 3, 22))
254
277
  bahai_date -= 1
255
278
  expect(bahai_date.gregorian_date).to eq Date.new(1844, 3, 21)
@@ -1,56 +1,59 @@
1
1
  module BahaiDate
2
2
  describe Day do
3
- it 'can be created given a number from 1 to 19' do
3
+ it "can be created given a number from 1 to 19" do
4
4
  expect(Day.new(1)).to_not be_nil
5
5
  expect(Day.new(19)).to_not be_nil
6
6
  end
7
7
 
8
8
  it "can't be created with a number other than 1 to 19" do
9
9
  expect { Day.new(0) }.to raise_error(
10
- ArgumentError, "'0' is not a valid day. Please use 1 to 19.")
10
+ ArgumentError, "'0' is not a valid day. Please use 1 to 19."
11
+ )
11
12
 
12
13
  expect { Day.new(20) }.to raise_error(
13
- ArgumentError, "'20' is not a valid day. Please use 1 to 19.")
14
+ ArgumentError, "'20' is not a valid day. Please use 1 to 19."
15
+ )
14
16
 
15
- expect { Day.new('hello') }.to raise_error(
16
- ArgumentError, "'0' is not a valid day. Please use 1 to 19.")
17
+ expect { Day.new("hello") }.to raise_error(
18
+ ArgumentError, "'0' is not a valid day. Please use 1 to 19."
19
+ )
17
20
  end
18
21
 
19
22
  subject(:day) { Day.new(1) }
20
23
 
21
- it 'can be converted to string' do
22
- expect(day.to_s).to eq 'Baha'
24
+ it "can be converted to string" do
25
+ expect(day.to_s).to eq "Baha"
23
26
  end
24
27
 
25
- it 'provides access to the day number' do
28
+ it "provides access to the day number" do
26
29
  expect(day.number).to be 1
27
30
  end
28
31
 
29
- it 'provides access to the translated title' do
30
- expect(day.translation).to eq 'Splendour'
32
+ it "provides access to the translated title" do
33
+ expect(day.translation).to eq "Splendour"
31
34
  end
32
35
 
33
- it 'provides access to the title in HTML' do
34
- expect(day.html).to eq 'Bahá'
36
+ it "provides access to the title in HTML" do
37
+ expect(day.html).to eq "Bahá"
35
38
  end
36
39
 
37
- context 'working with the weekday' do
38
- it 'is initially nil' do
40
+ context "working with the weekday" do
41
+ it "is initially nil" do
39
42
  expect(day.weekday).to be_nil
40
43
  end
41
44
 
42
- it 'can be set' do
45
+ it "can be set" do
43
46
  weekday = day.weekday = Weekday.new(1)
44
47
  expect(day.weekday).to be weekday
45
48
  end
46
49
  end
47
50
 
48
- context 'working with the occasions' do
49
- it 'is initially nil' do
51
+ context "working with the occasions" do
52
+ it "is initially nil" do
50
53
  expect(day.occasions).to be_nil
51
54
  end
52
55
 
53
- it 'can be set' do
56
+ it "can be set" do
54
57
  occasions = day.occasions = OccasionFactory.new(1, 1, 1).occasions
55
58
  expect(day.occasions).to be occasions
56
59
  end
@@ -1,10 +1,10 @@
1
1
  module BahaiDate
2
2
  describe Logic do
3
- it 'supplies a Date object for Naw Ruz of a given year' do
3
+ it "supplies a Date object for Naw Ruz of a given year" do
4
4
  expect(Logic.nawruz_for(1844)).to eq(Date.new(1844, 3, 21))
5
5
  end
6
6
 
7
- it 'determines whether a year is leap or not' do
7
+ it "determines whether a year is leap or not" do
8
8
  expect(Logic.leap?(1)).to eq(false)
9
9
  expect(Logic.leap?(4)).to eq(true)
10
10
  expect(Logic.leap?(168)).to eq(true)
@@ -16,5 +16,25 @@ module BahaiDate
16
16
  expect(Logic.leap?(176)).to eq(false)
17
17
  expect(Logic.leap?(177)).to eq(false)
18
18
  end
19
+
20
+ it "supports Gregorian years up to 3001, where the year 1157 B.E. ends" do
21
+ expect(Logic.nawruz_for(3001)).to be_a(Date)
22
+ expect { Logic.nawruz_for(3002) }.to raise_error(ArgumentError, /outside the supported range/)
23
+ expect { Logic.nawruz_for(10**12) }.to raise_error(ArgumentError, /outside the supported range/)
24
+ end
25
+
26
+ it "rejects Baha'i years after 1157 instead of computing nonsense" do
27
+ expect { Logic.leap?(1158) }.to raise_error(ArgumentError, /not a valid year/)
28
+ expect { Logic.twin_holy_days_date(10**6) }.to raise_error(ArgumentError, /not a valid year/)
29
+ expect { OccasionFactory.find(:birth_bab, 10**6) }.to raise_error(ArgumentError, /not a valid year/)
30
+ end
31
+
32
+ it "computes Naw-Ruz with a fixed Tehran offset, without time zone data" do
33
+ # Dates as in spec/fixtures/bahai_org_calendar.json; published_calendar_spec
34
+ # checks all fifty years.
35
+ expect(Logic.nawruz_for(2026)).to eq Date.new(2026, 3, 21)
36
+ expect(Logic.nawruz_for(2027)).to eq Date.new(2027, 3, 21)
37
+ expect(Logic.nawruz_for(2044)).to eq Date.new(2044, 3, 20)
38
+ end
19
39
  end
20
40
  end
@@ -1,6 +1,6 @@
1
1
  module BahaiDate
2
2
  describe Month do
3
- 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
4
4
  expect(Month.new(1)).to_not be_nil
5
5
  expect(Month.new(19)).to_not be_nil
6
6
  expect(Month.new(-1)).to_not be_nil
@@ -8,51 +8,55 @@ module BahaiDate
8
8
 
9
9
  it "can't be created with a number other than 1 to 19 or -1" do
10
10
  expect { Month.new(0) }.to raise_error(
11
- ArgumentError, "'0' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha.")
11
+ ArgumentError, "'0' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha."
12
+ )
12
13
 
13
14
  expect { Month.new(-2) }.to raise_error(
14
- ArgumentError, "'-2' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha.")
15
+ ArgumentError, "'-2' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha."
16
+ )
15
17
 
16
18
  expect { Month.new(20) }.to raise_error(
17
- ArgumentError, "'20' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha.")
19
+ ArgumentError, "'20' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha."
20
+ )
18
21
 
19
- expect { Month.new('hello') }.to raise_error(
20
- ArgumentError, "'0' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha.")
22
+ expect { Month.new("hello") }.to raise_error(
23
+ ArgumentError, "'0' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha."
24
+ )
21
25
  end
22
26
 
23
- context 'when created using -1' do
24
- it 'has a title of Ayyam-i-Ha' do
27
+ context "when created using -1" do
28
+ it "has a title of Ayyam-i-Ha" do
25
29
  month = Month.new(-1)
26
30
 
27
- expect(month.to_s).to eq 'Ayyam-i-Ha'
31
+ expect(month.to_s).to eq "Ayyam-i-Ha"
28
32
  end
29
33
  end
30
34
 
31
35
  subject(:month) { Month.new(1) }
32
36
 
33
- it 'can be converted to string' do
34
- expect(month.to_s).to eq 'Baha'
37
+ it "can be converted to string" do
38
+ expect(month.to_s).to eq "Baha"
35
39
  end
36
40
 
37
- it 'provides access to the month number' do
41
+ it "provides access to the month number" do
38
42
  expect(month.number).to be 1
39
43
  end
40
44
 
41
- it 'provides access to the translated title' do
42
- expect(month.translation).to eq 'Splendour'
45
+ it "provides access to the translated title" do
46
+ expect(month.translation).to eq "Splendour"
43
47
  end
44
48
 
45
- it 'provides access to the title in HTML' do
46
- expect(month.html).to eq 'Bahá'
49
+ it "provides access to the title in HTML" do
50
+ expect(month.html).to eq "Bahá"
47
51
  end
48
52
 
49
- context 'working with a hash of days' do
50
- it 'is readable' do
53
+ context "working with a hash of days" do
54
+ it "is readable" do
51
55
  month = Month.new(1)
52
56
  expect(month.days).to eq({})
53
57
  end
54
58
 
55
- it 'can be added to' do
59
+ it "can be added to" do
56
60
  month = Month.new(1)
57
61
  month.add_day(1)
58
62
  expect(month.days[1].number).to be 1