merch_calendar 0.1.0.rc2 → 0.1.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4258c9ca91b7427a13a40d020ea448f7a0bce7d3
4
- data.tar.gz: e5892f68ea348e3901339aebdd186200773333bc
3
+ metadata.gz: 529c719788c4f0aada0e215af345aa00ec9d055f
4
+ data.tar.gz: 79f5749368eff3b9607649efac54ec8a54cacbd8
5
5
  SHA512:
6
- metadata.gz: 50c31a68c19cc6edd3aecf26467788afd0c23d1f688c97d2d08ee1a06ebe2c2ea6cd67445f891a8b6f22371a509a7cb4779023f6d48e6022e54b2c4d1f5e9462
7
- data.tar.gz: d5a02533ff081b5d4fe07b3ad80fd882a62834c19a79023351c3c079664b9b169fd5e7cfb2a8c5026aceb81e25e63637280dd0ed13402212df80530e47283e08
6
+ metadata.gz: 1cbcf6b7df354163f93069a82f9f05a60882cd129be90335777c30b39dd735065fa851dce568c13a986d660654a8e610df81cc1ced035340b7e473f63f1fea41
7
+ data.tar.gz: f363bb9980350ccc5867679301afb2380d67b99a6bd60cf3472122e922ca62b6c07e5ff1a9733223d1ee5f5a60f3d6e191f601ac28c44d4956c3634f0be5853a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- merch_calendar (0.1.0.rc2)
4
+ merch_calendar (0.1.0.rc3)
5
5
 
6
6
  GEM
7
7
  remote: https://www.rubygems.org/
data/README.md CHANGED
@@ -49,82 +49,85 @@ puts merch_week.to_s(:long) # "2013:48 Dec W5"
49
49
  puts merch_week.to_s(:elasticsearch) # "2013-12w05"
50
50
  ```
51
51
 
52
- This can also be used on the `MerchCalendar` module. All `start_` and `end_` methods can be called, along with a few additional ones.
53
52
 
54
- ```ruby
55
- # All examples below return a Date object for the start of May within the 2014 merch year
56
- MerchCalendar.start_of_month(2014, 5)
57
- MerchCalendar.start_of_month(2014, month: 5)
58
- MerchCalendar.start_of_month(2014, julian_month: 5)
59
-
60
- # This is the same as May, because "Merch" months are shifted by 1.
61
- # i.e. month 1 is actually February
62
- # You probably will never use this, but it is available.
63
- MerchCalendar.start_of_month(2014, merch_month: 4)
64
- ```
53
+ ### Merch retail calendar
65
54
 
66
- #### Confusing things to look out for:
67
-
68
- Merch calendars have the first month in February, and the last (12th) month is in January of the following year. In the code block above, each method is *asking* a very different question. This will definitely cause confusion, so here are some explanations.
55
+ Merch calendars have their first month in February, and the last (12th) month is in January of the
56
+ following year.
69
57
 
70
58
  ```ruby
71
- # This is asking "In the Merch year of 2014, where is the month of January?"
72
- # January is the last (12th) month of a merch year, so this date will be in the NEXT
73
- # julian calendar year
74
- MerchCalendar.start_of_month(2014, 1)
75
- MerchCalendar.start_of_month(2014, month: 1)
76
- MerchCalendar.start_of_month(2014, julian_month: 1)
77
- # => 2015-01-04
78
- # ^^^^ - NEXT year
59
+ # This is asking "In the Merch year of 2014, what is the Gregorian calendar date of
60
+ # the start of the first month?"
61
+ retail_calendar = MerchCalendar::RetailCalendar.new
79
62
 
80
- # This is asking "When is the start of the FIRST month of the merch year 2014"
81
- MerchCalendar.start_of_month(2014, merch_month: 1)
63
+ retail_calendar.start_of_month(2014, 1)
82
64
  # => 2014-02-02
83
65
 
66
+ retail_calendar.start_of_month(2014, 12)
67
+ # => 2015-01-04
84
68
  ```
85
69
 
86
70
  This table should describe the progression of dates:
87
71
 
88
- | N | `start_of_month(2014, N)` | `start_of_month(2014, merch_month: N)` |
89
- | ------------- | ------------- | ------------- |
90
- | 1 | **2015-01-04** | 2014-02-02 |
91
- | 2 | 2014-02-02 | 2014-03-02 |
92
- | 3 | 2014-03-02 | 2014-04-06 |
93
- | 4 | 2014-04-06 | 2014-05-04 |
94
- | 5 | 2014-05-04 | 2014-06-01 |
95
- | 6 | 2014-06-01 | 2014-07-06 |
96
- | 7 | 2014-07-06 | 2014-08-03 |
97
- | 8 | 2014-08-03 | 2014-08-31 |
98
- | 9 | 2014-08-31 | 2014-10-05 |
99
- | 10 | 2014-10-05 | 2014-11-02 |
100
- | 11 | 2014-11-02 | 2014-11-30 |
101
- | 12 | 2014-11-30 | **2015-01-04** |
72
+ | N | `start_of_month(2014, N)` |
73
+ | ------------- | ------------- |
74
+ | 1 | 2014-02-02 |
75
+ | 2 | 2014-03-02 |
76
+ | 3 | 2014-04-06 |
77
+ | 4 | 2014-05-04 |
78
+ | 5 | 2014-06-01 |
79
+ | 6 | 2014-07-06 |
80
+ | 7 | 2014-08-03 |
81
+ | 8 | 2014-08-31 |
82
+ | 9 | 2014-10-05 |
83
+ | 10 | 2014-11-02 |
84
+ | 11 | 2014-11-30 |
85
+ | 12 | 2015-01-04 |
102
86
 
103
87
 
104
88
  Other useful methods:
105
89
 
106
90
  ```ruby
107
91
  # 52 or 53 (depending on leap year)
108
- MerchCalendar.weeks_in_year(2015)
92
+ retail_calendar.weeks_in_year(2016)
93
+ # => 52
94
+ retail_calendar.weeks_in_year(2017)
95
+ # => 53
96
+
97
+ # get the start date of a given merch week
98
+ retail_calendar.start_of_week(2017, 4, 1)
99
+ # => #<Date: 2017-04-30 ((2457874j,0s,0n),+0s,2299161j)>
100
+
101
+ # get the end date of a given merch week
102
+ retail_calendar.end_of_week(2017, 4, 1)
103
+ #=> #<Date: 2017-05-06 ((2457880j,0s,0n),+0s,2299161j)>
104
+ ```
105
+
106
+ ### Offset fiscal year calendars
107
+ Some companies, one of which being Stitch Fix, operate on a fiscal year calendar that is offset of
108
+ the traditional retail calendar. The `MerchCalendar::FiscalYearCalendar` class allows you to easily
109
+ offset the start of year to match your fiscal calendar.
110
+
111
+ ```ruby
112
+ fiscal_calendar = MerchCalendar::FiscalYearCalendar.new
109
113
 
110
- # returns an array of MerchWeek objects for each week within the provided month
111
- MerchCalendar.weeks_for_month(2014, 1)
114
+ # 52 or 53 (depending on leap year)
115
+ fiscal_calendar.weeks_in_year(2017)
116
+ # => 52
117
+ fiscal_calendar.weeks_in_year(2018)
118
+ # => 53
112
119
 
113
120
  # get the start date of a given merch week
114
- MerchCalendar.start_of_week(2017, 4, 1)
115
- # => #<Date: 2017-04-02 ((2457846j,0s,0n),+0s,2299161j)>
121
+ fiscal_calendar.start_of_week(2017, 1, 1)
122
+ # => #<Date: 2016-07-31 ((2457601j,0s,0n),+0s,2299161j)>
116
123
 
117
124
  # get the end date of a given merch week
118
- MerchCalendar.end_of_week(2017, 4, 1)
119
- # => #<Date: 2017-04-08 ((2457852j,0s,0n),+0s,2299161j)>
125
+ fiscal_calendar.end_of_week(2017, 4, 1)
126
+ #=> #<Date: 2017-05-06 ((2457880j,0s,0n),+0s,2299161j)>
120
127
  ```
121
128
 
122
129
  ## Documentation
123
130
  You can view the documentation for this gem on [RubyDoc.info](http://www.rubydoc.info/github/stitchfix/merch_calendar/master).
124
131
 
125
-
126
- ## Roadmap
127
- * Support for 4-4-5 calendars
128
-
129
132
  ## License
130
133
  MerchCalendar is released under the [MIT License](http://www.opensource.org/licenses/MIT).
@@ -2,17 +2,38 @@ require "merch_calendar/retail_calendar"
2
2
 
3
3
  module MerchCalendar
4
4
  class FiscalYearCalendar
5
- def initialize
5
+ # Stitch Fix's fiscal year starts two quarters *before* (hence the negative number) the start of the
6
+ # merch/retail calendar year.
7
+ STITCH_FIX_FY_QUARTER_OFFSET = -2
8
+
9
+ QUARTER_1 = 1
10
+ QUARTER_4 = 4
11
+
12
+ # @param fy_quarter_offset [Fixnum]
13
+ # The number of quarters before or after the start of the traditional NRF retail calendar that the year
14
+ # should begin.
15
+ # ex) Stitch Fix's fiscal year calendar starts in August of the prior gregorian calendar year.
16
+ # February 2017 = Traditional retail month 1, year 2017
17
+ # August 2016 = Offset retail month 1, year 2017 (2 quarters earlier)
18
+ def initialize(fy_quarter_offset = STITCH_FIX_FY_QUARTER_OFFSET)
19
+ @fy_quarter_offset = fy_quarter_offset
20
+
21
+ # TODO: support other fiscal year offsets
22
+ if fy_quarter_offset != STITCH_FIX_FY_QUARTER_OFFSET
23
+ raise NotImplementedError.new("FY quarter offset of #{fy_quarter_offset} not yet supported")
24
+ end
25
+
6
26
  @retail_calendar = RetailCalendar.new
7
27
  end
8
28
 
9
- # The day after last years' end date
29
+ # The date of the first day of the year
10
30
  def start_of_year(year)
11
- start_of_quarter(year, 1)
31
+ start_of_quarter(year, QUARTER_1)
12
32
  end
13
33
 
34
+ # The date of the last day of the year
14
35
  def end_of_year(year)
15
- end_of_quarter(year, 4)
36
+ end_of_quarter(year, QUARTER_4)
16
37
  end
17
38
 
18
39
  # Return the starting date for a particular quarter
@@ -25,10 +46,18 @@ module MerchCalendar
25
46
  @retail_calendar.end_of_quarter(*offset_quarter(year, quarter))
26
47
  end
27
48
 
49
+ # The date of the first day of the merch month
50
+ # @param [Fixnum] year - the fiscal year
51
+ # @param [Fixnum] merch_month - the nth month of the offset calendar
52
+ # ex) for an offset of +/- 2 quarters, month 1 = August
28
53
  def start_of_month(year, merch_month)
29
54
  @retail_calendar.start_of_month(*offset_month(year, merch_month))
30
55
  end
31
56
 
57
+ # The date of the last day of the merch month
58
+ # @param [Fixnum] year - the fiscal year
59
+ # @param [Fixnum] merch_month - the nth month of the offset calendar
60
+ # ex) for an offset of +/- 2 quarters, month 1 = August
32
61
  def end_of_month(year, merch_month)
33
62
  @retail_calendar.end_of_month(*offset_month(year, merch_month))
34
63
  end
@@ -43,20 +72,47 @@ module MerchCalendar
43
72
  @retail_calendar.end_of_week(*offset_month(year, merch_month), merch_week)
44
73
  end
45
74
 
75
+ # Returns the number of weeks in the fiscal year
46
76
  def weeks_in_year(year)
47
- @retail_calendar.weeks_in_year(year - 1)
77
+ @retail_calendar.weeks_in_year(offset_year(year))
48
78
  end
49
79
 
50
80
  private
51
81
 
82
+ # Offsets the quarter based on the fiscal year quarter offset
83
+ # returns: ofset [year, quarter]
52
84
  def offset_quarter(year, quarter)
53
85
  # first quarter in fiscal calendar is Q3 of retail calendar of previous year
54
- yr, qt = quarter >= 3 ? [year, quarter - 2] : [year - 1, quarter + 2]
86
+ if quarter >= 1 + @fy_quarter_offset.abs
87
+ [year, quarter + @fy_quarter_offset]
88
+ else
89
+ [year - 1, quarter - @fy_quarter_offset]
90
+ end
55
91
  end
56
92
 
93
+ # Offsets the month based on the fiscal year quarter offset
94
+ # returns: ofset [year, month]
57
95
  def offset_month(year, month)
58
- # first month in fiscal calendar is the sixth month in the retail calendar
59
- yr, mn = month >= 7 ? [year, month - 6] : [year - 1, month + 6]
96
+ # 3 - number of months in a quarter
97
+ month_offset = @fy_quarter_offset * 3
98
+
99
+ if month >= (month_offset.abs + 1)
100
+ [year, month + month_offset]
101
+ else
102
+ [year - 1, month - month_offset]
103
+ end
104
+ end
105
+
106
+ # Offsets the year based on the fiscal year quarter offset
107
+ # returns: ofset year
108
+ def offset_year(year)
109
+ if @fy_quarter_offset < 0
110
+ year -= 1
111
+ elsif @fy_quarter_offset > 0
112
+ year += 1
113
+ else
114
+ year
115
+ end
60
116
  end
61
117
  end
62
118
  end
@@ -2,6 +2,11 @@ require "date"
2
2
 
3
3
  module MerchCalendar
4
4
  class RetailCalendar
5
+ QUARTER_1 = 1
6
+ QUARTER_2 = 2
7
+ QUARTER_3 = 3
8
+ QUARTER_4 = 4
9
+
5
10
  def end_of_year(year)
6
11
  year_end = Date.new((year + 1), 1, -1)
7
12
  wday = (year_end.wday + 1) % 7
@@ -61,13 +66,13 @@ module MerchCalendar
61
66
  # Return the starting date for a particular quarter
62
67
  def start_of_quarter(year, quarter)
63
68
  case quarter
64
- when 1
69
+ when QUARTER_1
65
70
  start_of_month(year, 1)
66
- when 2
71
+ when QUARTER_2
67
72
  start_of_month(year, 4)
68
- when 3
73
+ when QUARTER_3
69
74
  start_of_month(year, 7)
70
- when 4
75
+ when QUARTER_4
71
76
  start_of_month(year, 10)
72
77
  end
73
78
  end
@@ -75,13 +80,13 @@ module MerchCalendar
75
80
  # Return the ending date for a particular quarter
76
81
  def end_of_quarter(year, quarter)
77
82
  case quarter
78
- when 1
83
+ when QUARTER_1
79
84
  end_of_month(year, 3)
80
- when 2
85
+ when QUARTER_2
81
86
  end_of_month(year, 6)
82
- when 3
87
+ when QUARTER_3
83
88
  end_of_month(year, 9)
84
- when 4
89
+ when QUARTER_4
85
90
  end_of_month(year, 12)
86
91
  end
87
92
  end
@@ -1,3 +1,3 @@
1
1
  module MerchCalendar
2
- VERSION = '0.1.0.rc2'
2
+ VERSION = '0.1.0.rc3'
3
3
  end
@@ -1,133 +1,145 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe MerchCalendar::FiscalYearCalendar do
4
- describe "#weeks_in_year" do
5
- it "returns 53 for a leap year - 2013" do
6
- expect(subject.weeks_in_year(2013)).to eq 53
7
- end
4
+ context "the default fy_offset - 2 quarters earlier" do
5
+ describe "#weeks_in_year" do
6
+ it "returns 53 for a leap year - 2013" do
7
+ expect(subject.weeks_in_year(2013)).to eq 53
8
+ end
8
9
 
9
- it "returns 52 for a normal year" do
10
- expect(subject.weeks_in_year(2014)).to eq 52
11
- end
10
+ it "returns 52 for a normal year" do
11
+ expect(subject.weeks_in_year(2014)).to eq 52
12
+ end
12
13
 
13
- it "returns 52 for a normal year" do
14
- expect(subject.weeks_in_year(2015)).to eq 52
15
- end
14
+ it "returns 52 for a normal year" do
15
+ expect(subject.weeks_in_year(2015)).to eq 52
16
+ end
16
17
 
17
- it "returns 52 for a normal year" do
18
- expect(subject.weeks_in_year(2016)).to eq 52
19
- end
18
+ it "returns 52 for a normal year" do
19
+ expect(subject.weeks_in_year(2016)).to eq 52
20
+ end
20
21
 
21
- it "returns 52 for a normal year" do
22
- expect(subject.weeks_in_year(2017)).to eq 52
23
- end
22
+ it "returns 52 for a normal year" do
23
+ expect(subject.weeks_in_year(2017)).to eq 52
24
+ end
24
25
 
25
- it "returns 53 for a leap year - 2018" do
26
- expect(subject.weeks_in_year(2018)).to eq 53
27
- end
26
+ it "returns 53 for a leap year - 2018" do
27
+ expect(subject.weeks_in_year(2018)).to eq 53
28
+ end
28
29
 
29
- it "returns 52 for a normal year" do
30
- expect(subject.weeks_in_year(2019)).to eq 52
30
+ it "returns 52 for a normal year" do
31
+ expect(subject.weeks_in_year(2019)).to eq 52
32
+ end
31
33
  end
32
- end
33
34
 
34
- describe "#start_of_week" do
35
- it "returns the correct date for 2017-1-1 (2017-Aug-wk1)" do
36
- expect(subject.start_of_week(2017, 1, 1)).to eq Date.new(2016, 7, 31)
37
- end
35
+ describe "#start_of_week" do
36
+ it "returns the correct date for 2017-1-1 (2017-Aug-wk1)" do
37
+ expect(subject.start_of_week(2017, 1, 1)).to eq Date.new(2016, 7, 31)
38
+ end
38
39
 
39
- it "returns the correct Date for 2018-1-1 (2018-Aug-wk1)" do
40
- expect(subject.start_of_week(2018, 1, 1)).to eq Date.new(2017, 7, 30)
41
- end
40
+ it "returns the correct Date for 2018-1-1 (2018-Aug-wk1)" do
41
+ expect(subject.start_of_week(2018, 1, 1)).to eq Date.new(2017, 7, 30)
42
+ end
42
43
 
43
- it "returns the correct Date for 2019-1-1 (2019-Aug-wk1)" do
44
- expect(subject.start_of_week(2019, 1, 1)).to eq Date.new(2018, 8, 5)
44
+ it "returns the correct Date for 2019-1-1 (2019-Aug-wk1)" do
45
+ expect(subject.start_of_week(2019, 1, 1)).to eq Date.new(2018, 8, 5)
46
+ end
45
47
  end
46
- end
47
48
 
48
- describe "#end_of_week" do
49
- it "returns the correct date for 2017-6-1 (2017-Jan-wk1)" do
50
- expect(subject.end_of_week(2017, 6, 1)).to eq Date.new(2017, 1, 7)
51
- end
49
+ describe "#end_of_week" do
50
+ it "returns the correct date for 2017-6-1 (2017-Jan-wk1)" do
51
+ expect(subject.end_of_week(2017, 6, 1)).to eq Date.new(2017, 1, 7)
52
+ end
52
53
 
53
- it "returns the correct Date for 2018-6-5 (2018-Jan-wk5)" do
54
- expect(subject.end_of_week(2018, 6, 5)).to eq Date.new(2018, 2, 3)
55
- end
54
+ it "returns the correct Date for 2018-6-5 (2018-Jan-wk5)" do
55
+ expect(subject.end_of_week(2018, 6, 5)).to eq Date.new(2018, 2, 3)
56
+ end
56
57
 
57
- it "returns the correct Date for 2019-10-3 (2019-May-wk3)" do
58
- expect(subject.end_of_week(2019, 10, 3)).to eq Date.new(2019, 5, 25)
58
+ it "returns the correct Date for 2019-10-3 (2019-May-wk3)" do
59
+ expect(subject.end_of_week(2019, 10, 3)).to eq Date.new(2019, 5, 25)
60
+ end
59
61
  end
60
- end
61
62
 
62
- describe "#start_of_month" do
63
- it "returns the correct date for 2018-1 AKA 2018-Aug" do
64
- expect(subject.start_of_month(2018, 1)).to eq Date.new(2017, 7, 30)
65
- end
63
+ describe "#start_of_month" do
64
+ it "returns the correct date for 2018-1 AKA 2018-Aug" do
65
+ expect(subject.start_of_month(2018, 1)).to eq Date.new(2017, 7, 30)
66
+ end
66
67
 
67
- it "returns the correct date for 2019-1 AKA 2019-Aug" do
68
- expect(subject.start_of_month(2019, 1)).to eq Date.new(2018, 8, 5)
68
+ it "returns the correct date for 2019-1 AKA 2019-Aug" do
69
+ expect(subject.start_of_month(2019, 1)).to eq Date.new(2018, 8, 5)
70
+ end
69
71
  end
70
- end
71
72
 
72
- describe "#end_of_month" do
73
- it "returns the correct date for 2018-1 AKA 2018-Aug" do
74
- expect(subject.end_of_month(2018, 1)).to eq Date.new(2017, 8, 26)
75
- end
73
+ describe "#end_of_month" do
74
+ it "returns the correct date for 2018-1 AKA 2018-Aug" do
75
+ expect(subject.end_of_month(2018, 1)).to eq Date.new(2017, 8, 26)
76
+ end
76
77
 
77
- it "returns the correct date for 2019-1 AKA 2019-Aug" do
78
- expect(subject.end_of_month(2019, 1)).to eq Date.new(2018, 9, 1)
78
+ it "returns the correct date for 2019-1 AKA 2019-Aug" do
79
+ expect(subject.end_of_month(2019, 1)).to eq Date.new(2018, 9, 1)
80
+ end
79
81
  end
80
- end
81
82
 
82
- describe "#start_of_quarter" do
83
- it "returns the correct date for 2018-Q1" do
84
- expect(subject.start_of_quarter(2018, 1)).to eq Date.new(2017, 7, 30)
85
- end
83
+ describe "#start_of_quarter" do
84
+ it "returns the correct date for 2018-Q1" do
85
+ expect(subject.start_of_quarter(2018, 1)).to eq Date.new(2017, 7, 30)
86
+ end
86
87
 
87
- it "returns the correct date for 2018-Q4" do
88
- expect(subject.start_of_quarter(2018, 4)).to eq Date.new(2018, 5, 6)
89
- end
88
+ it "returns the correct date for 2018-Q4" do
89
+ expect(subject.start_of_quarter(2018, 4)).to eq Date.new(2018, 5, 6)
90
+ end
90
91
 
91
- it "returns the correct date for 2019-Q1" do
92
- expect(subject.start_of_quarter(2019, 1)).to eq Date.new(2018, 8, 5)
92
+ it "returns the correct date for 2019-Q1" do
93
+ expect(subject.start_of_quarter(2019, 1)).to eq Date.new(2018, 8, 5)
94
+ end
93
95
  end
94
- end
95
96
 
96
- describe "#end_of_quarter" do
97
- it "returns the correct date for 2018-Q1" do
98
- expect(subject.end_of_quarter(2018, 1)).to eq Date.new(2017, 10, 28)
99
- end
97
+ describe "#end_of_quarter" do
98
+ it "returns the correct date for 2018-Q1" do
99
+ expect(subject.end_of_quarter(2018, 1)).to eq Date.new(2017, 10, 28)
100
+ end
100
101
 
101
- it "returns the correct date for 2018-Q4" do
102
- expect(subject.end_of_quarter(2018, 4)).to eq Date.new(2018, 8, 4)
103
- end
102
+ it "returns the correct date for 2018-Q4" do
103
+ expect(subject.end_of_quarter(2018, 4)).to eq Date.new(2018, 8, 4)
104
+ end
104
105
 
105
- it "returns the correct date for 2019-Q1" do
106
- expect(subject.end_of_quarter(2019, 1)).to eq Date.new(2018, 11, 3)
106
+ it "returns the correct date for 2019-Q1" do
107
+ expect(subject.end_of_quarter(2019, 1)).to eq Date.new(2018, 11, 3)
108
+ end
107
109
  end
108
- end
109
110
 
110
- describe "#start_of_year" do
111
- it "returns the correct date for 2018" do
112
- expect(subject.start_of_year(2018)).to eq Date.new(2017, 7, 30)
113
- end
111
+ describe "#start_of_year" do
112
+ it "returns the correct date for 2018" do
113
+ expect(subject.start_of_year(2018)).to eq Date.new(2017, 7, 30)
114
+ end
114
115
 
115
- it "returns the correct date for 2019" do
116
- expect(subject.start_of_year(2019)).to eq Date.new(2018, 8, 5)
116
+ it "returns the correct date for 2019" do
117
+ expect(subject.start_of_year(2019)).to eq Date.new(2018, 8, 5)
118
+ end
117
119
  end
118
- end
119
120
 
120
- describe "#end_of_year" do
121
- it "returns the correct date for 2017" do
122
- expect(subject.end_of_year(2017)).to eq Date.new(2017, 7, 29)
123
- end
121
+ describe "#end_of_year" do
122
+ it "returns the correct date for 2017" do
123
+ expect(subject.end_of_year(2017)).to eq Date.new(2017, 7, 29)
124
+ end
124
125
 
125
- it "returns the correct date for 2018" do
126
- expect(subject.end_of_year(2018)).to eq Date.new(2018, 8, 4)
126
+ it "returns the correct date for 2018" do
127
+ expect(subject.end_of_year(2018)).to eq Date.new(2018, 8, 4)
128
+ end
129
+
130
+ it "returns the correct date for 2019" do
131
+ expect(subject.end_of_year(2019)).to eq Date.new(2019, 8, 3)
132
+ end
127
133
  end
134
+ end
135
+
136
+ context "an alternative offset - 2 quarters after" do
137
+ subject { described_class.new(2) }
128
138
 
129
- it "returns the correct date for 2019" do
130
- expect(subject.end_of_year(2019)).to eq Date.new(2019, 8, 3)
139
+ it "raises a NotImplementedError - this is still TODO" do
140
+ expect {
141
+ subject
142
+ }.to raise_error(NotImplementedError)
131
143
  end
132
144
  end
133
145
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merch_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc2
4
+ version: 0.1.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitch Dempsey