Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions custom_holidays.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ months:
type: :informal
regions: [us]
12:
- name: Christmas Eve
regions: [us]
mday: 24
type: :informal
- name: New Year's Eve
regions: [us]
mday: 31
Expand All @@ -23,6 +27,11 @@ tests:
regions: ["us"]
expect:
name: "New Year's Eve"
- given:
date: ['2017-12-24']
regions: ["us"]
expect:
name: "Christmas Eve"
- given:
date: ['2017-11-24']
regions: ["us"]
Expand Down
2 changes: 1 addition & 1 deletion lib/offbot/off_days.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class OffDays
"Labor Day",
"Thanksgiving",
"Thanksgiving Friday", # in custom_holidays.yaml
"Christmas Eve",
"Christmas Eve", # in custom_holidays.yaml
"Christmas Day"
].freeze

Expand Down
14 changes: 14 additions & 0 deletions spec/offbot/off_days_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,26 @@
name: "Thanksgiving Friday",
regions: array_including(:us)
},
{
date: Date.new(2017, 12, 24),
name: "Christmas Eve",
regions: array_including(:us)
},
{
date: Date.new(2017, 12, 25),
name: "Christmas Day",
regions: array_including(:us)
}
])
end

it "returns Christmas Eve, which the holidays gem does not define" do
holidays = described_class.new.days_off(Date.new(2026, 12, 21), Date.new(2026, 12, 27))

expect(holidays.map { |holiday| [holiday[:date], holiday[:name]] }).to eq([
[Date.new(2026, 12, 24), "Christmas Eve"],
[Date.new(2026, 12, 25), "Christmas Day"]
])
end
end
end