-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only render Monday-specific chores on Mondays
- Loading branch information
1 parent
e0c6ed4
commit 8931bfb
Showing
4 changed files
with
68 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,70 @@ | ||
require "rails_helper" | ||
|
||
describe DailyPacket::PdfView do | ||
it "renders the document" do | ||
warm_fuzzy = FactoryBot.create(:warm_fuzzy, received_at: Time.at(0)) | ||
daily_packet = FactoryBot.create(:daily_packet, warm_fuzzy: warm_fuzzy) | ||
view = DailyPacket::PdfView.new(daily_packet) | ||
inspector = PDF::Inspector::Page.analyze(view.pdf_data) | ||
|
||
expect(inspector.pages.size).to eq 3 | ||
|
||
page_one_strings, page_two_strings, page_three_strings = inspector.pages.map { |page| page[:strings] } | ||
|
||
expect(page_one_strings).to eq([ | ||
"Daily Packet ##{daily_packet.id}", | ||
"07/07/2007", | ||
"week 27", | ||
"Random Warm Fuzzy", | ||
"Alright Haircut", | ||
"Your haircut is adequate.", | ||
"- Wife, 01/01/1970", | ||
"Reading Pace", | ||
"7.7 pages/day", | ||
"Feedbin Stats", | ||
"unread: 9", | ||
"oldest: 14 days ago" | ||
]) | ||
|
||
expect(page_two_strings).to eq([ | ||
"Top Three", | ||
"Personal", | ||
"1. #{"_" * 40}", | ||
"2. #{"_" * 40}", | ||
"3. #{"_" * 40}", | ||
"Work", | ||
"1. #{"_" * 40}", | ||
"2. #{"_" * 40}", | ||
"3. #{"_" * 40}" | ||
]) | ||
|
||
expect(page_three_strings).to eq([ | ||
"Chore List", | ||
"unload dishwasher", | ||
"collect laundry", | ||
"defrost meat", | ||
"poop patrol", | ||
"mow front", | ||
"mow back", | ||
"mow way back", | ||
"put out garbage cans", | ||
"wipe off kitchen table", | ||
"run dishwasher" | ||
]) | ||
let(:warm_fuzzy) { FactoryBot.create(:warm_fuzzy, received_at: Time.at(0)) } | ||
let(:daily_packet) { FactoryBot.create(:daily_packet, built_on: built_on, warm_fuzzy: warm_fuzzy) } | ||
|
||
context "on a Tuesday" do | ||
let(:built_on) { Date.parse("2024-11-05") } | ||
|
||
it "renders the document" do | ||
inspector = PDF::Inspector::Page.analyze(daily_packet.pdf_data) | ||
|
||
expect(inspector.pages.size).to eq 3 | ||
|
||
page_one_strings, page_two_strings, page_three_strings = inspector.pages.map { |page| page[:strings] } | ||
|
||
expect(page_one_strings).to eq([ | ||
"Daily Packet ##{daily_packet.id}", | ||
"11/05/2024", | ||
"week 45", | ||
"Random Warm Fuzzy", | ||
"Alright Haircut", | ||
"Your haircut is adequate.", | ||
"- Wife, 01/01/1970", | ||
"Reading Pace", | ||
"7.7 pages/day", | ||
"Feedbin Stats", | ||
"unread: 9", | ||
"oldest: 14 days ago" | ||
]) | ||
|
||
expect(page_two_strings).to eq([ | ||
"Top Three", | ||
"Personal", | ||
"1. #{"_" * 40}", | ||
"2. #{"_" * 40}", | ||
"3. #{"_" * 40}", | ||
"Work", | ||
"1. #{"_" * 40}", | ||
"2. #{"_" * 40}", | ||
"3. #{"_" * 40}" | ||
]) | ||
|
||
expect(page_three_strings).to eq([ | ||
"Chore List", | ||
"unload dishwasher", | ||
"collect laundry", | ||
"defrost meat", | ||
"poop patrol", | ||
"mow front", | ||
"mow back", | ||
"mow way back", | ||
"wipe off kitchen table", | ||
"run dishwasher" | ||
]) | ||
end | ||
end | ||
|
||
context "on a Monday" do | ||
let(:built_on) { Date.parse("2024-11-04") } | ||
|
||
it "renders the Monday-specific chore" do | ||
inspector = PDF::Inspector::Page.analyze(daily_packet.pdf_data) | ||
|
||
_, _, page_three_strings = inspector.pages.map { |page| page[:strings] } | ||
|
||
expect(page_three_strings).to include "put out garbage cans" | ||
end | ||
end | ||
end |