test: draw only the birthday shapes the editor serves
The round-trip property filtered out every shape no client is sent,
too many for Hegel's health check on some seeds. It now draws a month
and day always and a year or not, every case one that serves.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VAiyEheRBdzbBjZUDWZUPk
diff --git a/test/pro_tacts/admin/test_card_form.rb b/test/pro_tacts/admin/test_card_form.rb
index 7440f8a..3a09390 100644
--- a/test/pro_tacts/admin/test_card_form.rb
+++ b/test/pro_tacts/admin/test_card_form.rb
@@ -96,29 +96,23 @@ class CardFormTest < Minitest::Test
## The birthday row
- # Whatever the birthday row saves, a served birthday reads back from
- # its line as itself: the next sync cannot change what the editor
- # wrote. The year range is drawn around 1604, the sentinel a served
- # full date would lose its year to (Birthday::NO_YEAR).
+ # Whatever the birthday row saves in a shape it serves — a month and
+ # day, with a year or without — reads back from its line as itself:
+ # the next sync cannot change what the editor wrote. The year range is
+ # drawn around 1604, the sentinel a served full date would lose its
+ # year to (Birthday::NO_YEAR).
def test_a_saved_birthday_reads_back_from_the_line_it_serves
- field = ->(range) { optional(integers(min_value: range.min, max_value: range.max).map(&:to_s)) }
+ field = ->(range) { integers(min_value: range.min, max_value: range.max).map(&:to_s) }
Hegel.test(test_cases: 1_000) do |tc|
fields = {
- "year" => tc.draw(one_of(field.(1600..1610), field.(0..9999))),
+ "year" => tc.draw(optional(one_of(field.(1600..1610), field.(0..9999)))),
"month" => tc.draw(field.(1..12)),
"day" => tc.draw(field.(1..31)),
}
- # A shape the grammar refuses is the row's refusal, no save at all.
- birthday = begin
- ProTacts::Admin::CardForm.birthday(fields)
- rescue ArgumentError
- nil
- end
- line = birthday&.to_line
- tc.assume(!line.nil?)
+ birthday = ProTacts::Admin::CardForm.birthday(fields)
- read = ProTacts::BirthdayLine.read(ProTacts::VCard.new("#{line}\r\n").lines.fetch(0))
- assert_equal birthday, read.birthday
+ line = ProTacts::VCard.new("#{birthday.to_line}\r\n").lines.fetch(0)
+ assert_equal birthday, ProTacts::BirthdayLine.read(line).birthday
end
end
end