Skip to content

Commit

Permalink
Add spec for DOB formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgumberg committed Nov 8, 2023
1 parent ecf5697 commit d6a98ac
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/decorators/user_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,32 @@
expect(decorated_user.formatted_invitation_sent_at).to eq expected_date
end
end

describe "#formatted_birthday" do
context "when a user has no date of birth set"
it "returns a blank string" do
user.update(date_of_birth: nil)
expect(decorated_user.formatted_birthday).to eq ""
end

context "when a user has a valid date of birth"
it "returns the month and ordinal of their birthday" do
user.update(date_of_birth: Date.new(1991, 7, 8))
expect(decorated_user.formatted_birthday).to eq "July 8th"
end
end

describe "#formatted_date_of_birth" do
context "when a user has no date of birth set"
it "returns a blank string" do
user.update(date_of_birth: nil)
expect(decorated_user.formatted_date_of_birth).to eq ""
end

context "when a user has a valid date of birth"
it "returns the YYYY/MM/DD of their date of birth" do
user.update(date_of_birth: Date.new(1991, 7, 8))
expect(decorated_user.formatted_date_of_birth).to eq "1991/07/08"
end
end
end

0 comments on commit d6a98ac

Please sign in to comment.