timeboss 0.3.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gem-push.yml +31 -0
  3. data/.github/workflows/ruby.yml +35 -0
  4. data/.travis.yml +3 -2
  5. data/Gemfile +2 -1
  6. data/README.md +22 -7
  7. data/Rakefile +3 -1
  8. data/bin/tbsh +2 -2
  9. data/lib/tasks/calendars.rake +5 -5
  10. data/lib/tasks/timeboss.rake +2 -2
  11. data/lib/timeboss/calendar/day.rb +3 -2
  12. data/lib/timeboss/calendar/half.rb +2 -1
  13. data/lib/timeboss/calendar/month.rb +2 -1
  14. data/lib/timeboss/calendar/parser.rb +9 -8
  15. data/lib/timeboss/calendar/period.rb +13 -6
  16. data/lib/timeboss/calendar/quarter.rb +2 -1
  17. data/lib/timeboss/calendar/support/formatter.rb +5 -4
  18. data/lib/timeboss/calendar/support/has_fiscal_weeks.rb +17 -0
  19. data/lib/timeboss/calendar/support/has_iso_weeks.rb +30 -0
  20. data/lib/timeboss/calendar/support/month_basis.rb +1 -1
  21. data/lib/timeboss/calendar/support/monthly_unit.rb +8 -8
  22. data/lib/timeboss/calendar/support/navigable.rb +2 -1
  23. data/lib/timeboss/calendar/support/shiftable.rb +12 -11
  24. data/lib/timeboss/calendar/support/translatable.rb +3 -2
  25. data/lib/timeboss/calendar/support/unit.rb +24 -13
  26. data/lib/timeboss/calendar/waypoints/absolute.rb +4 -3
  27. data/lib/timeboss/calendar/waypoints/relative.rb +14 -13
  28. data/lib/timeboss/calendar/week.rb +3 -2
  29. data/lib/timeboss/calendar/year.rb +2 -1
  30. data/lib/timeboss/calendar.rb +8 -7
  31. data/lib/timeboss/calendars/broadcast.rb +10 -7
  32. data/lib/timeboss/calendars/gregorian.rb +4 -5
  33. data/lib/timeboss/calendars.rb +3 -2
  34. data/lib/timeboss/version.rb +2 -1
  35. data/lib/timeboss.rb +2 -0
  36. data/spec/calendar/day_spec.rb +14 -14
  37. data/spec/calendar/quarter_spec.rb +9 -9
  38. data/spec/calendar/support/monthly_unit_spec.rb +50 -44
  39. data/spec/calendar/support/unit_spec.rb +23 -22
  40. data/spec/calendar/week_spec.rb +20 -20
  41. data/spec/calendars/broadcast_spec.rb +310 -310
  42. data/spec/calendars/gregorian_spec.rb +376 -267
  43. data/spec/calendars_spec.rb +19 -19
  44. data/spec/spec_helper.rb +2 -2
  45. data/timeboss.gemspec +16 -14
  46. metadata +35 -4
  47. data/lib/timeboss/support/shellable.rb +0 -17
@@ -1,681 +1,790 @@
1
1
  module TimeBoss
2
2
  describe Calendars::Gregorian do
3
- let(:subject) { described_class.new }
4
-
5
- context 'days' do
6
- it 'can get today' do
3
+ subject { described_class.new }
4
+ context "days" do
5
+ it "can get today" do
7
6
  day = subject.today
8
7
  expect(day).to be_instance_of(TimeBoss::Calendar::Day)
9
8
  expect(day.start_date).to eq Date.today
10
9
  end
11
10
 
12
- it 'can get yesterday' do
11
+ it "can get yesterday" do
13
12
  day = subject.yesterday
14
13
  expect(day).to be_instance_of(TimeBoss::Calendar::Day)
15
14
  expect(day.start_date).to eq Date.yesterday
16
15
  end
17
16
 
18
- it 'can get tomorrow' do
17
+ it "can get tomorrow" do
19
18
  day = subject.tomorrow
20
19
  expect(day).to be_instance_of(TimeBoss::Calendar::Day)
21
20
  expect(day.start_date).to eq Date.tomorrow
22
21
  end
23
22
  end
24
23
 
25
- context 'quarters' do
26
- describe '#quarter' do
27
- it 'knows 2017Q2' do
24
+ context "quarters" do
25
+ describe "#quarter" do
26
+ it "knows 2017Q2" do
28
27
  quarter = subject.quarter(2017, 2)
29
- expect(quarter.name).to eq '2017Q2'
30
- expect(quarter.title).to eq 'Q2 2017'
28
+ expect(quarter.name).to eq "2017Q2"
29
+ expect(quarter.title).to eq "Q2 2017"
31
30
  expect(quarter.year_index).to eq 2017
32
31
  expect(quarter.index).to eq 2
33
- expect(quarter.start_date).to eq Date.parse('2017-04-01')
34
- expect(quarter.end_date).to eq Date.parse('2017-06-30')
32
+ expect(quarter.start_date).to eq Date.parse("2017-04-01")
33
+ expect(quarter.end_date).to eq Date.parse("2017-06-30")
35
34
  expect(quarter.to_range).to eq quarter.start_date..quarter.end_date
36
35
  end
37
36
 
38
- it 'knows 2018Q3' do
37
+ it "knows 2018Q3" do
39
38
  quarter = subject.quarter(2018, 3)
40
- expect(quarter.name).to eq '2018Q3'
41
- expect(quarter.title).to eq 'Q3 2018'
39
+ expect(quarter.name).to eq "2018Q3"
40
+ expect(quarter.title).to eq "Q3 2018"
42
41
  expect(quarter.year_index).to eq 2018
43
42
  expect(quarter.index).to eq 3
44
- expect(quarter.start_date).to eq Date.parse('2018-07-01')
45
- expect(quarter.end_date).to eq Date.parse('2018-09-30')
43
+ expect(quarter.start_date).to eq Date.parse("2018-07-01")
44
+ expect(quarter.end_date).to eq Date.parse("2018-09-30")
46
45
  expect(quarter.to_range).to eq quarter.start_date..quarter.end_date
47
46
  end
48
47
 
49
- it 'knows 2019Q4' do
48
+ it "knows 2019Q4" do
50
49
  quarter = subject.quarter(2019, 4)
51
50
  expect(quarter.year_index).to eq 2019
52
51
  expect(quarter.index).to eq 4
53
- expect(quarter.name).to eq '2019Q4'
54
- expect(quarter.title).to eq 'Q4 2019'
55
- expect(quarter.start_date).to eq Date.parse('2019-10-01')
56
- expect(quarter.end_date).to eq Date.parse('2019-12-31')
52
+ expect(quarter.name).to eq "2019Q4"
53
+ expect(quarter.title).to eq "Q4 2019"
54
+ expect(quarter.start_date).to eq Date.parse("2019-10-01")
55
+ expect(quarter.end_date).to eq Date.parse("2019-12-31")
57
56
  expect(quarter.to_range).to eq quarter.start_date..quarter.end_date
58
57
  end
59
58
  end
60
59
 
61
- describe '#quarter_for' do
62
- it 'knows what quarter 2018-07-05 is in' do
63
- quarter = subject.quarter_for(Date.parse('2018-07-05'))
64
- expect(quarter.name).to eq '2018Q3'
60
+ describe "#quarter_for" do
61
+ it "knows what quarter 2018-07-05 is in" do
62
+ quarter = subject.quarter_for(Date.parse("2018-07-05"))
63
+ expect(quarter.name).to eq "2018Q3"
65
64
  end
66
65
 
67
- it 'knows what quarter 2018-06-22 is in' do
68
- quarter = subject.quarter_for(Date.parse('2018-06-22'))
69
- expect(quarter.name).to eq '2018Q2'
66
+ it "knows what quarter 2018-06-22 is in" do
67
+ quarter = subject.quarter_for(Date.parse("2018-06-22"))
68
+ expect(quarter.name).to eq "2018Q2"
70
69
  end
71
70
  end
72
71
 
73
- describe '#quarters_for' do
74
- it 'knows what quarters are in 2020' do
72
+ describe "#quarters_for" do
73
+ it "knows what quarters are in 2020" do
75
74
  basis = subject.year(2020)
76
75
  periods = subject.quarters_for(basis)
77
76
  expect(periods.map(&:name)).to eq %w[2020Q1 2020Q2 2020Q3 2020Q4]
78
77
  end
79
78
 
80
- it 'knows what quarter 2018M7 is in' do
79
+ it "knows what quarter 2018M7 is in" do
81
80
  basis = subject.month(2018, 7)
82
81
  periods = subject.quarters_for(basis)
83
82
  expect(periods.map(&:name)).to eq %w[2018Q3]
84
83
  end
85
84
  end
86
85
 
87
- describe '#this_quarter' do
86
+ describe "#this_quarter" do
88
87
  let(:today) { double }
89
88
  let(:quarter) { double }
90
89
 
91
- it 'gets the quarter for today' do
90
+ it "gets the quarter for today" do
92
91
  allow(Date).to receive(:today).and_return today
93
92
  expect(subject).to receive(:quarter_for).with(today).and_return quarter
94
93
  expect(subject.this_quarter).to eq quarter
95
94
  end
96
95
  end
97
96
 
98
- describe '#format' do
97
+ describe "#format" do
99
98
  let(:entry) { subject.quarter(2015, 3) }
100
99
 
101
- it 'can do a default format' do
102
- expect(entry.format).to eq '2015H2Q1'
100
+ it "can do a default format" do
101
+ expect(entry.format).to eq "2015H2Q1"
103
102
  end
104
103
 
105
- it 'can format with only the quarter' do
106
- expect(entry.format(:quarter)).to eq '2015Q3'
104
+ it "can format with only the quarter" do
105
+ expect(entry.format(:quarter)).to eq "2015Q3"
107
106
  end
108
107
 
109
- it 'ignores stupidity' do
110
- expect(entry.format(:day, :banana)).to eq '2015Q3'
108
+ it "ignores stupidity" do
109
+ expect(entry.format(:day, :banana)).to eq "2015Q3"
111
110
  end
112
111
  end
113
112
 
114
- context 'relative' do
113
+ context "relative" do
115
114
  let(:this_quarter) { subject.quarter(2015, 3) }
116
115
  let(:quarter) { double }
117
116
  before(:each) { allow(subject).to receive(:this_quarter).and_return this_quarter }
118
117
 
119
- it 'can get the last quarter' do
118
+ it "can get the last quarter" do
120
119
  allow(this_quarter).to receive(:previous).and_return quarter
121
120
  expect(subject.last_quarter).to eq quarter
122
121
  end
123
122
 
124
- it 'can get the next quarter' do
123
+ it "can get the next quarter" do
125
124
  allow(this_quarter).to receive(:next).and_return quarter
126
125
  expect(subject.next_quarter).to eq quarter
127
126
  end
128
127
 
129
- it 'can get some number of quarters' do
128
+ it "can get some number of quarters" do
130
129
  quarters = subject.quarters(5)
131
130
  expect(quarters.length).to eq 5
132
131
  quarters.each { |q| expect(q).to be_a TimeBoss::Calendar::Quarter }
133
- expect(quarters.map(&:name)).to eq ['2015Q3', '2015Q4', '2016Q1', '2016Q2', '2016Q3']
132
+ expect(quarters.map(&:name)).to eq ["2015Q3", "2015Q4", "2016Q1", "2016Q2", "2016Q3"]
134
133
  end
135
134
 
136
- it 'can get a quarter ahead' do
135
+ it "can get a quarter ahead" do
137
136
  quarter = subject.quarters_ahead(4)
138
137
  expect(quarter).to be_a TimeBoss::Calendar::Quarter
139
- expect(quarter.name).to eq '2016Q3'
138
+ expect(quarter.name).to eq "2016Q3"
140
139
  end
141
140
 
142
- it 'can get some number of quarters back' do
141
+ it "can get some number of quarters back" do
143
142
  quarters = subject.quarters_back(5)
144
143
  expect(quarters.length).to eq 5
145
144
  quarters.each { |q| expect(q).to be_a TimeBoss::Calendar::Quarter }
146
- expect(quarters.map(&:name)).to eq ['2014Q3', '2014Q4', '2015Q1', '2015Q2', '2015Q3']
145
+ expect(quarters.map(&:name)).to eq ["2014Q3", "2014Q4", "2015Q1", "2015Q2", "2015Q3"]
147
146
  end
148
147
 
149
- it 'can get a quarter ago' do
148
+ it "can get a quarter ago" do
150
149
  quarter = subject.quarters_ago(4)
151
150
  expect(quarter).to be_a TimeBoss::Calendar::Quarter
152
- expect(quarter.name).to eq '2014Q3'
151
+ expect(quarter.name).to eq "2014Q3"
153
152
  end
154
153
  end
155
154
  end
156
155
 
157
- context 'months' do
158
- describe '#month' do
159
- it 'knows 2017M2' do
156
+ context "months" do
157
+ describe "#month" do
158
+ it "knows 2017M2" do
160
159
  month = subject.month(2017, 2)
161
- expect(month.name).to eq '2017M2'
162
- expect(month.title).to eq 'February 2017'
160
+ expect(month.name).to eq "2017M2"
161
+ expect(month.title).to eq "February 2017"
163
162
  expect(month.year_index).to eq 2017
164
163
  expect(month.index).to eq 2
165
- expect(month.start_date).to eq Date.parse('2017-02-01')
166
- expect(month.end_date).to eq Date.parse('2017-02-28')
164
+ expect(month.start_date).to eq Date.parse("2017-02-01")
165
+ expect(month.end_date).to eq Date.parse("2017-02-28")
167
166
  expect(month.to_range).to eq month.start_date..month.end_date
168
167
  end
169
168
 
170
- it 'knows 2018M3' do
169
+ it "knows 2018M3" do
171
170
  month = subject.month(2018, 3)
172
- expect(month.name).to eq '2018M3'
173
- expect(month.title).to eq 'March 2018'
171
+ expect(month.name).to eq "2018M3"
172
+ expect(month.title).to eq "March 2018"
174
173
  expect(month.year_index).to eq 2018
175
174
  expect(month.index).to eq 3
176
- expect(month.start_date).to eq Date.parse('2018-03-01')
177
- expect(month.end_date).to eq Date.parse('2018-03-31')
175
+ expect(month.start_date).to eq Date.parse("2018-03-01")
176
+ expect(month.end_date).to eq Date.parse("2018-03-31")
178
177
  expect(month.to_range).to eq month.start_date..month.end_date
179
178
  end
180
179
 
181
- it 'knows 2019M11' do
180
+ it "knows 2019M11" do
182
181
  month = subject.month(2019, 11)
183
182
  expect(month.year_index).to eq 2019
184
183
  expect(month.index).to eq 11
185
- expect(month.name).to eq '2019M11'
186
- expect(month.title).to eq 'November 2019'
187
- expect(month.start_date).to eq Date.parse('2019-11-01')
188
- expect(month.end_date).to eq Date.parse('2019-11-30')
184
+ expect(month.name).to eq "2019M11"
185
+ expect(month.title).to eq "November 2019"
186
+ expect(month.start_date).to eq Date.parse("2019-11-01")
187
+ expect(month.end_date).to eq Date.parse("2019-11-30")
189
188
  expect(month.to_range).to eq month.start_date..month.end_date
190
189
  end
191
190
  end
192
191
 
193
- describe '#month_for' do
194
- it 'knows what month 2018-07-05 is in' do
195
- month = subject.month_for(Date.parse('2018-07-05'))
196
- expect(month.name).to eq '2018M7'
192
+ describe "#month_for" do
193
+ it "knows what month 2018-07-05 is in" do
194
+ month = subject.month_for(Date.parse("2018-07-05"))
195
+ expect(month.name).to eq "2018M7"
197
196
  end
198
197
 
199
- it 'knows what month 2018-06-22 is in' do
200
- month = subject.month_for(Date.parse('2018-06-22'))
201
- expect(month.name).to eq '2018M6'
198
+ it "knows what month 2018-06-22 is in" do
199
+ month = subject.month_for(Date.parse("2018-06-22"))
200
+ expect(month.name).to eq "2018M6"
202
201
  end
203
202
  end
204
203
 
205
- describe '#months_for' do
206
- it 'knows what months are in 2020' do
204
+ describe "#months_for" do
205
+ it "knows what months are in 2020" do
207
206
  basis = subject.year(2020)
208
207
  periods = subject.months_for(basis)
209
208
  expect(periods.map(&:name)).to eq %w[2020M1 2020M2 2020M3 2020M4 2020M5 2020M6 2020M7 2020M8 2020M9 2020M10 2020M11 2020M12]
210
209
  end
211
210
 
212
- it 'knows what months are in 2018Q2' do
213
- basis = subject.parse('2018Q2')
211
+ it "knows what months are in 2018Q2" do
212
+ basis = subject.parse("2018Q2")
214
213
  periods = subject.months_for(basis)
215
214
  expect(periods.map(&:name)).to eq %w[2018M4 2018M5 2018M6]
216
215
  end
217
216
 
218
- it 'knows what month 2019-12-12 is in' do
219
- basis = subject.parse('2019-12-12')
217
+ it "knows what month 2019-12-12 is in" do
218
+ basis = subject.parse("2019-12-12")
220
219
  periods = subject.months_for(basis)
221
220
  expect(periods.map(&:name)).to eq %w[2019M12]
222
221
  end
223
222
  end
224
223
 
225
- describe '#this_month' do
224
+ describe "#this_month" do
226
225
  let(:today) { double }
227
226
  let(:month) { double }
228
227
 
229
- it 'gets the month for today' do
228
+ it "gets the month for today" do
230
229
  allow(Date).to receive(:today).and_return today
231
230
  expect(subject).to receive(:month_for).with(today).and_return month
232
231
  expect(subject.this_month).to eq month
233
232
  end
234
233
  end
235
234
 
236
- describe '#format' do
235
+ describe "#format" do
237
236
  let(:entry) { subject.month(2015, 8) }
238
237
 
239
- it 'can do a default format' do
240
- expect(entry.format).to eq '2015H2Q1M2'
238
+ it "can do a default format" do
239
+ expect(entry.format).to eq "2015H2Q1M2"
241
240
  end
242
241
 
243
- it 'can format with only the quarter' do
244
- expect(entry.format(:quarter)).to eq '2015Q3M2'
242
+ it "can format with only the quarter" do
243
+ expect(entry.format(:quarter)).to eq "2015Q3M2"
245
244
  end
246
245
 
247
- it 'ignores stupidity' do
248
- expect(entry.format(:banana, :half, :week)).to eq '2015H2M2'
246
+ it "ignores stupidity" do
247
+ expect(entry.format(:banana, :half, :week)).to eq "2015H2M2"
249
248
  end
250
249
  end
251
250
 
252
- context 'relative' do
251
+ context "relative" do
253
252
  let(:this_month) { subject.month(2015, 3) }
254
253
  let(:month) { double }
255
254
  before(:each) { allow(subject).to receive(:this_month).and_return this_month }
256
255
 
257
- it 'can get the last month' do
256
+ it "can get the last month" do
258
257
  allow(this_month).to receive(:previous).and_return month
259
258
  expect(subject.last_month).to eq month
260
259
  end
261
260
 
262
- it 'can get the next month' do
261
+ it "can get the next month" do
263
262
  allow(this_month).to receive(:next).and_return month
264
263
  expect(subject.next_month).to eq month
265
264
  end
266
265
 
267
- it 'can get some number of months' do
266
+ it "can get some number of months" do
268
267
  months = subject.months(5)
269
268
  expect(months.length).to eq 5
270
269
  months.each { |m| expect(m).to be_a TimeBoss::Calendar::Month }
271
- expect(months.map(&:name)).to eq ['2015M3', '2015M4', '2015M5', '2015M6', '2015M7']
270
+ expect(months.map(&:name)).to eq ["2015M3", "2015M4", "2015M5", "2015M6", "2015M7"]
272
271
  end
273
272
 
274
- it 'can get a month ahead' do
273
+ it "can get a month ahead" do
275
274
  month = subject.months_ahead(4)
276
275
  expect(month).to be_a TimeBoss::Calendar::Month
277
- expect(month.name).to eq '2015M7'
276
+ expect(month.name).to eq "2015M7"
278
277
  end
279
278
 
280
- it 'can get some number of months back' do
279
+ it "can get some number of months back" do
281
280
  months = subject.months_back(5)
282
281
  expect(months.length).to eq 5
283
282
  months.each { |m| expect(m).to be_a TimeBoss::Calendar::Month }
284
- expect(months.map(&:name)).to eq ['2014M11', '2014M12', '2015M1', '2015M2', '2015M3']
283
+ expect(months.map(&:name)).to eq ["2014M11", "2014M12", "2015M1", "2015M2", "2015M3"]
285
284
  end
286
285
 
287
- it 'can get a month ago' do
286
+ it "can get a month ago" do
288
287
  month = subject.months_ago(4)
289
288
  expect(month).to be_a TimeBoss::Calendar::Month
290
- expect(month.name).to eq '2014M11'
289
+ expect(month.name).to eq "2014M11"
291
290
  end
292
291
  end
293
292
  end
294
293
 
295
- context 'weeks' do
296
- it 'is uninterested in weeks' do
297
- expect { subject.this_week }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
298
- expect { subject.parse('2020W3') }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
299
- expect { subject.weeks_ago(2) }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
294
+ context "weeks" do
295
+ before(:each) { allow(Date).to receive(:today).and_return Date.parse("2019-08-23") }
296
+
297
+ it "knows this week " do
298
+ expect(subject.this_week.name).to eq "2019W34"
299
+ expect(subject.this_week.title).to eq "Week of August 19, 2019"
300
+ end
301
+
302
+ it "knows last week" do
303
+ expect(subject.last_week.name).to eq "2019W33"
304
+ expect(subject.last_week.title).to eq "Week of August 12, 2019"
305
+ end
306
+
307
+ it "knows next week" do
308
+ expect(subject.next_week.name).to eq "2019W35"
309
+ expect(subject.next_week.title).to eq "Week of August 26, 2019"
310
+ end
311
+
312
+ describe "over the years" do
313
+ [
314
+ [2010, "2010-01-04", 52, "2010-12-27"],
315
+ [2011, "2011-01-03", 52, "2011-12-26"],
316
+ [2012, "2012-01-02", 52, "2012-12-24"],
317
+ [2013, "2012-12-31", 52, "2013-12-23"],
318
+ [2014, "2013-12-30", 52, "2014-12-22"],
319
+ [2015, "2014-12-29", 53, "2015-12-28"],
320
+ [2016, "2016-01-04", 52, "2016-12-26"],
321
+ [2017, "2017-01-02", 52, "2017-12-25"],
322
+ [2018, "2018-01-01", 52, "2018-12-24"],
323
+ [2019, "2018-12-31", 52, "2019-12-23"],
324
+ [2020, "2019-12-30", 53, "2020-12-28"],
325
+ [2021, "2021-01-04", 52, "2021-12-27"],
326
+ [2022, "2022-01-03", 52, "2022-12-26"],
327
+ [2023, "2023-01-02", 52, "2023-12-25"],
328
+ [2024, "2024-01-01", 52, "2024-12-23"],
329
+ [2025, "2024-12-30", 52, "2025-12-22"],
330
+ [2026, "2025-12-29", 53, "2026-12-28"],
331
+ [2027, "2027-01-04", 52, "2027-12-27"],
332
+ [2028, "2028-01-03", 52, "2028-12-25"],
333
+ [2029, "2029-01-01", 52, "2029-12-24"],
334
+ [2030, "2029-12-31", 52, "2030-12-23"]
335
+ ].each do |year_number, first_start, num_weeks, last_start|
336
+ context "year #{year_number}" do
337
+ let(:year) { subject.year(year_number) }
338
+ let(:weeks) { year.weeks }
339
+
340
+ it "knows the first week of #{year_number} starts on #{first_start}" do
341
+ expect(weeks.first.start_date).to eq Date.parse(first_start)
342
+ end
343
+
344
+ it "can navigate to the second week of the year" do
345
+ week = weeks.first.next
346
+ expect(week.start_date).to eq Date.parse(first_start) + 7.days
347
+ expect(week.year).to eq year
348
+ end
349
+
350
+ it "knows that every week is 7 days" do
351
+ weeks.each { |w| expect(w.end_date - w.start_date).to eq 6 }
352
+ end
353
+
354
+ it "knows there are #{num_weeks} in #{year_number}" do
355
+ expect(weeks.count).to eq num_weeks
356
+ end
357
+
358
+ it "knows the last week of #{year_number} starts on #{last_start}" do
359
+ expect(weeks.first.start_date).to eq Date.parse(first_start)
360
+ end
361
+
362
+ it "can navigate to the first week of the next year" do
363
+ week = weeks.last.next
364
+ expect(week.start_date).to eq Date.parse(last_start) + 7.days
365
+ expect(week.year).to eq year.next
366
+ end
367
+ end
368
+ end
300
369
  end
301
370
  end
302
371
 
303
- context 'years' do
304
- describe '#year' do
305
- it 'knows 2016' do
372
+ context "years" do
373
+ describe "#year" do
374
+ it "knows 2016" do
306
375
  year = subject.year(2016)
307
- expect(year.name).to eq '2016'
308
- expect(year.title).to eq '2016'
376
+ expect(year.name).to eq "2016"
377
+ expect(year.title).to eq "2016"
309
378
  expect(year.year_index).to eq 2016
310
379
  expect(year.index).to eq 1
311
- expect(year.start_date).to eq Date.parse('2016-01-01')
312
- expect(year.end_date).to eq Date.parse('2016-12-31')
380
+ expect(year.start_date).to eq Date.parse("2016-01-01")
381
+ expect(year.end_date).to eq Date.parse("2016-12-31")
313
382
  expect(year.to_range).to eq year.start_date..year.end_date
314
383
  end
315
384
 
316
- it 'knows 2017' do
385
+ it "knows 2017" do
317
386
  year = subject.year(2017)
318
- expect(year.name).to eq '2017'
319
- expect(year.title).to eq '2017'
387
+ expect(year.name).to eq "2017"
388
+ expect(year.title).to eq "2017"
320
389
  expect(year.year_index).to eq 2017
321
390
  expect(year.index).to eq 1
322
- expect(year.start_date).to eq Date.parse('2017-01-01')
323
- expect(year.end_date).to eq Date.parse('2017-12-31')
391
+ expect(year.start_date).to eq Date.parse("2017-01-01")
392
+ expect(year.end_date).to eq Date.parse("2017-12-31")
324
393
  expect(year.to_range).to eq year.start_date..year.end_date
325
394
  end
326
395
 
327
- it 'knows 2018' do
396
+ it "knows 2018" do
328
397
  year = subject.year(2018)
329
- expect(year.name).to eq '2018'
330
- expect(year.title).to eq '2018'
398
+ expect(year.name).to eq "2018"
399
+ expect(year.title).to eq "2018"
331
400
  expect(year.year_index).to eq 2018
332
401
  expect(year.index).to eq 1
333
- expect(year.start_date).to eq Date.parse('2018-01-01')
334
- expect(year.end_date).to eq Date.parse('2018-12-31')
402
+ expect(year.start_date).to eq Date.parse("2018-01-01")
403
+ expect(year.end_date).to eq Date.parse("2018-12-31")
335
404
  expect(year.to_range).to eq year.start_date..year.end_date
336
405
  end
337
406
  end
338
407
 
339
- describe '#year_for' do
340
- it 'knows what year 2018-04-07 is in' do
341
- year = subject.year_for(Date.parse('2018-04-07'))
342
- expect(year.name).to eq '2018'
408
+ describe "#year_for" do
409
+ it "knows what year 2018-04-07 is in" do
410
+ year = subject.year_for(Date.parse("2018-04-07"))
411
+ expect(year.name).to eq "2018"
343
412
  end
344
413
 
345
- it 'knows what year 2016-12-27 is in' do
346
- year = subject.year_for(Date.parse('2016-12-27'))
347
- expect(year.name).to eq '2016'
414
+ it "knows what year 2016-12-27 is in" do
415
+ year = subject.year_for(Date.parse("2016-12-27"))
416
+ expect(year.name).to eq "2016"
348
417
  end
349
418
  end
350
419
 
351
- describe '#years_for' do
352
- it 'knows what years are in 2020 (duh)' do
420
+ describe "#years_for" do
421
+ it "knows what years are in 2020 (duh)" do
353
422
  basis = subject.year(2020)
354
423
  periods = subject.years_for(basis)
355
424
  expect(periods.map(&:name)).to eq %w[2020]
356
425
  end
357
426
 
358
- it 'knows what year 2018Q2 is in' do
359
- basis = subject.parse('2018Q2')
427
+ it "knows what year 2018Q2 is in" do
428
+ basis = subject.parse("2018Q2")
360
429
  periods = subject.years_for(basis)
361
430
  expect(periods.map(&:name)).to eq %w[2018]
362
431
  end
363
432
 
364
- it 'knows what years 2019-12-12 is in' do
365
- basis = subject.parse('2019-12-12')
433
+ it "knows what years 2019-12-12 is in" do
434
+ basis = subject.parse("2019-12-12")
366
435
  periods = subject.years_for(basis)
367
436
  expect(periods.map(&:name)).to eq %w[2019]
368
437
  end
369
438
  end
370
439
 
371
- describe '#this_year' do
440
+ describe "#this_year" do
372
441
  let(:today) { double }
373
442
  let(:year) { double }
374
443
 
375
- it 'gets the year for today' do
444
+ it "gets the year for today" do
376
445
  allow(Date).to receive(:today).and_return today
377
446
  expect(subject).to receive(:year_for).with(today).and_return year
378
447
  expect(subject.this_year).to eq year
379
448
  end
380
449
  end
381
450
 
382
- describe '#format' do
383
- let(:entry) { subject.parse('2020M8') }
451
+ describe "#format" do
452
+ let(:entry) { subject.parse("2020M8") }
384
453
 
385
- it 'can do a default format' do
386
- expect(entry.format).to eq '2020H2Q1M2'
454
+ it "can do a default format" do
455
+ expect(entry.format).to eq "2020H2Q1M2"
387
456
  end
388
457
 
389
- it 'can format with only the quarter' do
390
- expect(entry.format(:quarter)).to eq '2020Q3M2'
458
+ it "can format with only the quarter" do
459
+ expect(entry.format(:quarter)).to eq "2020Q3M2"
391
460
  end
392
461
 
393
- context 'with days' do
394
- let(:entry) { subject.parse('2020D201') }
462
+ context "with days" do
463
+ let(:entry) { subject.parse("2020D201") }
395
464
 
396
- it 'can do a default format' do
397
- expect(entry.format).to eq '2020H2Q1M1D19'
465
+ it "can do a default format" do
466
+ expect(entry.format).to eq "2020H2Q1M1W3D7"
398
467
  end
399
468
  end
400
469
  end
401
470
 
402
- context 'relative' do
471
+ context "relative" do
403
472
  let(:this_year) { subject.year(2015) }
404
473
  let(:year) { double }
405
474
  before(:each) { allow(subject).to receive(:this_year).and_return this_year }
406
475
 
407
- it 'can get the last year' do
476
+ it "can get the last year" do
408
477
  allow(this_year).to receive(:previous).and_return year
409
478
  expect(subject.last_year).to eq year
410
479
  end
411
480
 
412
- it 'can get the next year' do
481
+ it "can get the next year" do
413
482
  allow(this_year).to receive(:next).and_return year
414
483
  expect(subject.next_year).to eq year
415
484
  end
416
485
 
417
- it 'can get some number of years' do
486
+ it "can get some number of years" do
418
487
  years = subject.years(5)
419
488
  expect(years.length).to eq 5
420
489
  years.each { |y| expect(y).to be_a TimeBoss::Calendar::Year }
421
- expect(years.map(&:name)).to eq ['2015', '2016', '2017', '2018', '2019']
490
+ expect(years.map(&:name)).to eq ["2015", "2016", "2017", "2018", "2019"]
422
491
  end
423
492
 
424
- it 'can get some number of years back' do
493
+ it "can get some number of years back" do
425
494
  years = subject.years_back(5)
426
495
  expect(years.length).to eq 5
427
496
  years.each { |y| expect(y).to be_a TimeBoss::Calendar::Year }
428
- expect(years.map(&:name)).to eq ['2011', '2012', '2013', '2014', '2015']
497
+ expect(years.map(&:name)).to eq ["2011", "2012", "2013", "2014", "2015"]
429
498
  end
430
499
  end
431
500
  end
432
501
 
433
- describe '#parse' do
434
- it 'can parse a year' do
435
- date = subject.parse('2018')
502
+ describe "#parse" do
503
+ it "can parse a year" do
504
+ date = subject.parse("2018")
436
505
  expect(date).to be_a TimeBoss::Calendar::Year
437
- expect(date.name).to eq '2018'
506
+ expect(date.name).to eq "2018"
438
507
  end
439
508
 
440
- it 'can parse a quarter identifier' do
441
- date = subject.parse('2017Q2')
509
+ it "can parse a quarter identifier" do
510
+ date = subject.parse("2017Q2")
442
511
  expect(date).to be_a TimeBoss::Calendar::Quarter
443
- expect(date.name).to eq '2017Q2'
512
+ expect(date.name).to eq "2017Q2"
444
513
  end
445
514
 
446
- it 'can parse a month identifier' do
447
- date = subject.parse('2017M4')
515
+ it "can parse a month identifier" do
516
+ date = subject.parse("2017M4")
448
517
  expect(date).to be_a TimeBoss::Calendar::Month
449
- expect(date.name).to eq '2017M4'
518
+ expect(date.name).to eq "2017M4"
450
519
  end
451
520
 
452
- it 'cannot parse a week within a year' do
453
- expect { subject.parse('2018W37') }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
521
+ it "can parse a week within a year" do
522
+ date = subject.parse("2018W37")
523
+ expect(date).to be_a TimeBoss::Calendar::Week
524
+ expect(date).to be_instance_of TimeBoss::Calendars::Gregorian::Week
525
+ expect(date.name).to eq "2018W37"
454
526
  end
455
527
 
456
- it 'cannot parse a week within a quarter' do
457
- expect { subject.parse('2017Q2W2') }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
528
+ it "can parse a week within a quarter" do
529
+ date = subject.parse("2017Q2W2")
530
+ expect(date).to be_a TimeBoss::Calendar::Week
531
+ expect(date).to be_instance_of TimeBoss::Calendars::Gregorian::Week
532
+ expect(date.name).to eq "2017W15"
458
533
  end
459
534
 
460
- it 'cannot parse a week within a month' do
461
- expect { subject.parse('2017M4W1') }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
535
+ it "can parse a week within a month" do
536
+ date = subject.parse("2017M4W1")
537
+ expect(date).to be_a TimeBoss::Calendar::Week
538
+ expect(date).to be_instance_of TimeBoss::Calendars::Gregorian::Week
539
+ expect(date.name).to eq "2017W14"
462
540
  end
463
541
 
464
- it 'can parse a date' do
465
- date = subject.parse('2017-04-08')
542
+ it "can parse a date" do
543
+ date = subject.parse("2017-04-08")
466
544
  expect(date).to be_a TimeBoss::Calendar::Day
467
- expect(date.start_date).to eq Date.parse('2017-04-08')
468
- expect(date.end_date).to eq Date.parse('2017-04-08')
545
+ expect(date.start_date).to eq Date.parse("2017-04-08")
546
+ expect(date.end_date).to eq Date.parse("2017-04-08")
469
547
  end
470
548
 
471
- it 'can parse an aesthetically displeasing date' do
472
- date = subject.parse('20170408')
549
+ it "can parse an aesthetically displeasing date" do
550
+ date = subject.parse("20170408")
473
551
  expect(date).to be_a TimeBoss::Calendar::Day
474
- expect(date.start_date).to eq Date.parse('2017-04-08')
475
- expect(date.end_date).to eq Date.parse('2017-04-08')
552
+ expect(date.start_date).to eq Date.parse("2017-04-08")
553
+ expect(date.end_date).to eq Date.parse("2017-04-08")
476
554
  end
477
555
 
478
- it 'gives you nothing if you give it nothing' do
556
+ it "gives you nothing if you give it nothing" do
479
557
  expect(subject.parse(nil)).to be nil
480
- expect(subject.parse('')).to be nil
558
+ expect(subject.parse("")).to be nil
481
559
  end
482
560
  end
483
561
 
484
- context 'expressions' do
485
- it 'can parse waypoints' do
486
- result = subject.parse('this_year')
562
+ context "expressions" do
563
+ it "can parse waypoints" do
564
+ result = subject.parse("this_year")
487
565
  expect(result).to be_a TimeBoss::Calendar::Year
488
566
  expect(result).to be_current
489
567
  end
490
568
 
491
- it 'can parse mathematic expressions' do
492
- result = subject.parse('this_month + 2')
569
+ it "can parse mathematic expressions" do
570
+ result = subject.parse("this_month + 2")
493
571
  expect(result).to be_a TimeBoss::Calendar::Month
494
572
  expect(result).to eq subject.months_ahead(2)
495
573
  end
496
574
 
497
- context 'ranges' do
575
+ context "ranges" do
498
576
  before(:each) { allow(subject).to receive(:this_year).and_return subject.year(2018) }
499
- let(:result) { subject.parse('this_year-2 .. this_year') }
577
+ let(:result) { subject.parse("this_year-2 .. this_year") }
500
578
 
501
- it 'can parse range expressions' do
579
+ it "can parse range expressions" do
502
580
  expect(result).to be_a TimeBoss::Calendar::Period
503
581
  expect(result.to_s).to eq "2016: 2016-01-01 thru 2016-12-31 .. 2018: 2018-01-01 thru 2018-12-31"
504
582
  end
505
583
 
506
- it 'can get an overall start date for a range' do
507
- expect(result.start_date).to eq Date.parse('2016-01-01')
584
+ it "can get an overall start date for a range" do
585
+ expect(result.start_date).to eq Date.parse("2016-01-01")
508
586
  end
509
587
 
510
- it 'can get an overall end date for a range' do
511
- expect(result.end_date).to eq Date.parse('2018-12-31')
588
+ it "can get an overall end date for a range" do
589
+ expect(result.end_date).to eq Date.parse("2018-12-31")
512
590
  end
513
591
 
514
- context 'sub-periods' do
515
- it 'can get the months included in a range' do
592
+ context "sub-periods" do
593
+ it "can get the months included in a range" do
516
594
  entries = result.months
517
595
  entries.each { |e| expect(e).to be_a TimeBoss::Calendar::Month }
518
- expect(entries.map(&:name)).to include('2016M1', '2016M9', '2017M3', '2018M12')
596
+ expect(entries.map(&:name)).to include("2016M1", "2016M9", "2017M3", "2018M12")
519
597
  end
520
598
 
521
- it 'cannot get the weeks included in a range' do
522
- expect { result.weeks }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
599
+ it "can get the weeks included in a range" do
600
+ entries = result.weeks
601
+ entries.each { |e| expect(e).to be_a TimeBoss::Calendars::Gregorian::Week }
602
+ expect(entries.count).to eq 156
603
+ expect(entries.map(&:name)).to include("2016W1", "2016W38", "2017W15", "2017W52", "2018W52")
523
604
  end
524
605
 
525
- it 'can get the days included in a range' do
606
+ it "can get the days included in a range" do
526
607
  entries = result.days
527
608
  entries.each { |e| expect(e).to be_a TimeBoss::Calendar::Day }
528
- expect(entries.map(&:name)).to include('2016-01-01', '2016-05-12', '2017-09-22', '2018-12-31')
609
+ expect(entries.map(&:name)).to include("2016-01-01", "2016-05-12", "2017-09-22", "2018-12-31")
529
610
  end
530
611
  end
531
612
  end
532
613
  end
533
614
 
534
- context 'shifting' do
535
- context 'from day' do
536
- let(:basis) { subject.parse('2020-04-21') }
615
+ context "shifting" do
616
+ context "from day" do
617
+ let(:basis) { subject.parse("2020-04-21") }
537
618
 
538
- it 'cannot shift to a different week' do
539
- expect { basis.last_week }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
540
- expect { basis.in_week }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
619
+ it "can shift to a different week" do
620
+ allow(subject).to receive(:this_week).and_return subject.parse("2020W23")
621
+ result = basis.last_week
622
+ expect(result).to be_a TimeBoss::Calendar::Day
623
+ expect(result.to_s).to eq "2020-05-26"
624
+ expect(basis.in_week).to eq 2
541
625
  end
542
626
 
543
- it 'can shift to a different quarter' do
544
- allow(subject).to receive(:this_quarter).and_return subject.parse('2020Q3')
627
+ it "can shift to a different quarter" do
628
+ allow(subject).to receive(:this_quarter).and_return subject.parse("2020Q3")
545
629
  result = basis.quarters_ago(2)
546
630
  expect(result).to be_a TimeBoss::Calendar::Day
547
- expect(result.to_s).to eq '2020-01-21'
631
+ expect(result.to_s).to eq "2020-01-21"
548
632
  expect(basis.in_quarter).to eq 21
549
633
  end
550
634
 
551
- it 'can shift to a different year' do
552
- allow(subject).to receive(:this_year).and_return subject.parse('2019')
635
+ it "can shift to a different year" do
636
+ allow(subject).to receive(:this_year).and_return subject.parse("2019")
553
637
  result = basis.years_ahead(3)
554
638
  expect(result).to be_a TimeBoss::Calendar::Day
555
- expect(result.to_s).to eq '2022-04-22'
639
+ expect(result.to_s).to eq "2022-04-22"
556
640
  expect(basis.in_year).to eq 112
557
641
  end
558
642
  end
559
643
 
560
- context 'from month' do
561
- let(:basis) { subject.parse('2017M4') }
644
+ context "from week" do
645
+ let(:basis) { subject.parse("2017W8") }
646
+
647
+ it "cannot shift to a different day" do
648
+ expect(basis.last_day).to be nil
649
+ expect(basis.in_day).to be nil
650
+ end
651
+
652
+ it "can shift to a different month" do
653
+ allow(subject).to receive(:this_month).and_return subject.parse("2020M4")
654
+ result = basis.next_month
655
+ expect(result).to be_a TimeBoss::Calendars::Gregorian::Week
656
+ expect(result.to_s).to eq "2020W22: 2020-05-25 thru 2020-05-31"
657
+ expect(basis.in_month).to eq 4
658
+ end
659
+
660
+ it "can shift to a different half" do
661
+ allow(subject).to receive(:this_half).and_return subject.parse("2019H1")
662
+ result = basis.last_half
663
+ expect(result).to be_a TimeBoss::Calendars::Gregorian::Week
664
+ expect(result.to_s).to eq "2018W34: 2018-08-20 thru 2018-08-26"
665
+ expect(basis.in_half).to eq 8
666
+ end
667
+ end
668
+
669
+ context "from month" do
670
+ let(:basis) { subject.parse("2017M4") }
562
671
 
563
- it 'cannot shift to a different week' do
564
- expect { basis.last_week }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
565
- expect { basis.in_week }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
672
+ it "cannot shift to a different week" do
673
+ expect(basis.last_week).to be nil
674
+ expect(basis.in_week).to be nil
566
675
  end
567
676
 
568
- it 'can shift to a different year' do
569
- allow(subject).to receive(:this_year).and_return subject.parse('2020')
677
+ it "can shift to a different year" do
678
+ allow(subject).to receive(:this_year).and_return subject.parse("2020")
570
679
  result = basis.years_ahead(4)
571
680
  expect(result).to be_a TimeBoss::Calendar::Month
572
- expect(result.name).to eq '2024M4'
681
+ expect(result.name).to eq "2024M4"
573
682
  expect(basis.in_year).to eq 4
574
683
  end
575
684
  end
576
685
 
577
- context 'from quarter' do
578
- let(:basis) { subject.parse('2018Q2') }
686
+ context "from quarter" do
687
+ let(:basis) { subject.parse("2018Q2") }
579
688
 
580
- it 'cannot shift to a different month' do
689
+ it "cannot shift to a different month" do
581
690
  expect(basis.months_ago(4)).to be nil
582
691
  expect(basis.in_month).to be nil
583
692
  end
584
693
 
585
- it 'can shift to a different half' do
586
- allow(subject).to receive(:this_half).and_return subject.parse('2020H1')
694
+ it "can shift to a different half" do
695
+ allow(subject).to receive(:this_half).and_return subject.parse("2020H1")
587
696
  result = basis.last_half
588
697
  expect(result).to be_a TimeBoss::Calendar::Quarter
589
- expect(result.name).to eq '2019Q4'
698
+ expect(result.name).to eq "2019Q4"
590
699
  expect(basis.in_half).to eq 2
591
700
  end
592
701
  end
593
702
 
594
- context 'from year' do
595
- let(:basis) { subject.parse('2014') }
703
+ context "from year" do
704
+ let(:basis) { subject.parse("2014") }
596
705
 
597
- it 'cannot shift to a different half' do
706
+ it "cannot shift to a different half" do
598
707
  expect(basis.next_half).to be nil
599
708
  expect(basis.in_half).to be nil
600
709
  end
601
710
 
602
- it 'shifts to a different year, but knows how useless that is' do
603
- allow(subject).to receive(:this_year).and_return subject.parse('2020')
711
+ it "shifts to a different year, but knows how useless that is" do
712
+ allow(subject).to receive(:this_year).and_return subject.parse("2020")
604
713
  result = basis.years_ago(2)
605
714
  expect(result).to be_a TimeBoss::Calendar::Year
606
- expect(result.name).to eq '2018'
715
+ expect(result.name).to eq "2018"
607
716
  expect(basis.in_year).to eq 1
608
717
  end
609
718
  end
610
719
  end
611
720
 
612
- context 'units' do
721
+ context "units" do
613
722
  let(:calendar) { described_class.new }
614
723
 
615
- context 'day' do
616
- let(:start_date) { Date.parse('2019-09-30') }
724
+ context "day" do
725
+ let(:start_date) { Date.parse("2019-09-30") }
617
726
  let(:subject) { TimeBoss::Calendar::Day.new(calendar, start_date) }
618
727
 
619
- context 'links' do
620
- it 'can get its previous' do
621
- expect(subject.previous.name).to eq '2019-09-29'
728
+ context "links" do
729
+ it "can get its previous" do
730
+ expect(subject.previous.name).to eq "2019-09-29"
622
731
  end
623
732
 
624
- it 'can get its next' do
625
- expect(subject.next.name).to eq '2019-10-01'
733
+ it "can get its next" do
734
+ expect(subject.next.name).to eq "2019-10-01"
626
735
  end
627
736
 
628
- it 'can offset backwards' do
629
- expect(subject.offset(-3).name).to eq '2019-09-27'
630
- expect((subject - 3).name).to eq '2019-09-27'
737
+ it "can offset backwards" do
738
+ expect(subject.offset(-3).name).to eq "2019-09-27"
739
+ expect((subject - 3).name).to eq "2019-09-27"
631
740
  end
632
741
 
633
- it 'can offset forwards' do
634
- expect(subject.offset(4).name).to eq '2019-10-04'
635
- expect((subject + 4).name).to eq '2019-10-04'
742
+ it "can offset forwards" do
743
+ expect(subject.offset(4).name).to eq "2019-10-04"
744
+ expect((subject + 4).name).to eq "2019-10-04"
636
745
  end
637
746
  end
638
747
  end
639
748
 
640
- context 'quarter' do
641
- let(:start_date) { Date.parse('2019-10-01') }
642
- let(:end_date) { Date.parse('2019-12-31') }
749
+ context "quarter" do
750
+ let(:start_date) { Date.parse("2019-10-01") }
751
+ let(:end_date) { Date.parse("2019-12-31") }
643
752
  let(:subject) { TimeBoss::Calendar::Quarter.new(calendar, 2019, 4, start_date, end_date) }
644
753
 
645
- context 'links' do
646
- it 'can get the next quarter' do
754
+ context "links" do
755
+ it "can get the next quarter" do
647
756
  quarter = subject.next
648
- expect(quarter.to_s).to include('2020Q1', '2020-01-01', '2020-03-31')
757
+ expect(quarter.to_s).to include("2020Q1", "2020-01-01", "2020-03-31")
649
758
  end
650
759
 
651
- it 'can get the next next quarter' do
760
+ it "can get the next next quarter" do
652
761
  quarter = subject.next.next
653
- expect(quarter.to_s).to include('2020Q2', '2020-04-01', '2020-06-30')
762
+ expect(quarter.to_s).to include("2020Q2", "2020-04-01", "2020-06-30")
654
763
  end
655
764
 
656
- it 'can get the next next previous quarter' do
765
+ it "can get the next next previous quarter" do
657
766
  quarter = subject.next.next.previous
658
- expect(quarter.to_s).to include('2020Q1', '2020-01-01', '2020-03-31')
767
+ expect(quarter.to_s).to include("2020Q1", "2020-01-01", "2020-03-31")
659
768
  end
660
769
 
661
- it 'can get the next previous quarter' do
770
+ it "can get the next previous quarter" do
662
771
  quarter = subject.next.previous
663
772
  expect(quarter.to_s).to eq subject.to_s
664
773
  end
665
774
 
666
- it 'can get the previous quarter' do
775
+ it "can get the previous quarter" do
667
776
  quarter = subject.previous
668
- expect(quarter.to_s).to include('2019Q3', '2019-07-01', '2019-09-30')
777
+ expect(quarter.to_s).to include("2019Q3", "2019-07-01", "2019-09-30")
669
778
  end
670
779
 
671
- it 'can offset backwards' do
672
- expect(subject.offset(-4).name).to eq '2018Q4'
673
- expect((subject - 4).name).to eq '2018Q4'
780
+ it "can offset backwards" do
781
+ expect(subject.offset(-4).name).to eq "2018Q4"
782
+ expect((subject - 4).name).to eq "2018Q4"
674
783
  end
675
784
 
676
- it 'can offset forwards' do
677
- expect(subject.offset(2).name).to eq '2020Q2'
678
- expect((subject + 2).name).to eq '2020Q2'
785
+ it "can offset forwards" do
786
+ expect(subject.offset(2).name).to eq "2020Q2"
787
+ expect((subject + 2).name).to eq "2020Q2"
679
788
  end
680
789
  end
681
790
  end