aboutsummaryrefslogtreecommitdiffstats
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
authortony <tony>2009-03-22 17:00:03 +0000
committertony <tony>2009-03-22 17:00:03 +0000
commita12609a059fe3d8235427f7dbd4721c06d529180 (patch)
tree0e53210803090d1e1585b2af150ae7ccf309213d /spec/spec_helper.rb
parent299029c0d626ea190f995773f9337dd54b595b5e (diff)
add a validate_as_body helper method for tests
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index b61eec4df..c56e15f4c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -35,6 +35,7 @@ def rebuild_xapian_index
Kernel.system(rebuild_name) or raise "failed to launch rebuild-xapian-index"
end
+# Validate an entire HTML page
def validate_html(html)
$tempfilecount = $tempfilecount + 1
tempfilename = File.join(Dir::tmpdir, "railshtmlvalidate."+$$.to_s+"."+$tempfilecount.to_s+".html")
@@ -48,6 +49,12 @@ def validate_html(html)
return true
end
+# Validate HTML fragment by wrapping it as the <body> of a page
+def validate_as_body(html)
+ validate_html('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' +
+ "<html><head><title>Test</title></head><body>#{html}</body></html>")
+end
+
# Monkeypatch! Validate HTML in tests.
$html_validation_script = "/usr/bin/validate" # from Debian package wdg-html-validator
if $tempfilecount.nil?