.vbw-planning/milestones/03-coverage-analysis-quick-wins-critical-path-test-co/phases/02-critical-path-test-coverage/PLAN-02.md
Close the coverage gap in lib/source_monitor/items/item_creator.rb (currently 228 uncovered lines out of 601). The existing test file covers basic RSS/Atom/JSON creation, fingerprint generation, guid fallback, readability processing, metadata extraction, and guid/fingerprint deduplication. This plan targets the remaining uncovered branches: URL extraction from link_nodes and links arrays, content extraction fallback chain, concurrent duplicate handling (RecordNotUnique), author extraction from multiple sources, enclosure extraction from Atom link_nodes and JSON attachments, media content extraction, language/copyright/comments extraction, keyword splitting, safe_integer edge cases, and the deep_copy utility.
Decomposition rationale: ItemCreator is the second largest coverage gap. Its uncovered lines cluster into: (1) URL/content/timestamp extraction branches, (2) concurrent duplicate handling, (3) multi-format author/enclosure/media extraction, (4) feed content processing error paths, (5) utility methods. Each task targets a distinct cluster.
Trade-offs considered:
call interface keeps tests realistic, but some deep utility methods (deep_copy, safe_integer, split_keywords) are easier to verify directly.What constrains the structure:
lib/source_monitor/items/item_creator.rb -- (read-only reference)test/lib/source_monitor/items/item_creator_test.rbbin/rails test test/lib/source_monitor/items/item_creator_test.rb -n /url_extraction|content_extraction|updated_timestamp/i exits 0test/lib/source_monitor/items/item_creator_test.rbbin/rails test test/lib/source_monitor/items/item_creator_test.rb -n /concurrent_duplicate|record_not_unique/i exits 0test/lib/source_monitor/items/item_creator_test.rbbin/rails test test/lib/source_monitor/items/item_creator_test.rb -n /authors|enclosure|media_content|media_thumbnail/i exits 0test/lib/source_monitor/items/item_creator_test.rb<p>text</p> and false for plain text
Stub the parser class to raise for the error path test. Use source with feed_content_readability_enabled: true.bin/rails test test/lib/source_monitor/items/item_creator_test.rb -n /processing_error|html_fragment|deep_copy|readability_metadata/i exits 0test/lib/source_monitor/items/item_creator_test.rbbin/rails test test/lib/source_monitor/items/item_creator_test.rb -n /safe_integer|split_keywords|extract_guid_edge|language|copyright|normalize_metadata|comments_count/i exits 0bin/rails test test/lib/source_monitor/items/item_creator_test.rb exits 0COVERAGE=1 bin/rails test test/lib/source_monitor/items/item_creator_test.rb shows item_creator.rb with >80% branch coveragebin/rails test exits 0 (no regressions)