From 3d1f82c459e184379f7cc617ffe38b6b63594620 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 14 Aug 2026 01:55:10 +0200 Subject: Check rendered markup for balance in controller tests Every successful HTML response is parsed, as a document or a fragment depending on whether it carries a doctype, and parse errors fail the test. New actions inherit the check. --- test/test_helper.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test') diff --git a/test/test_helper.rb b/test/test_helper.rb index b7fe2b58..ec9b18b3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -78,4 +78,25 @@ class ActiveSupport::TestCase node.lock_for_editing!(user) node.draft || node.create_new_draft(user) end + + def assert_well_formed + body = @response.body + doc = if body.lstrip.start_with?("