diff options
author | francis <francis> | 2008-02-12 08:42:49 +0000 |
---|---|---|
committer | francis <francis> | 2008-02-12 08:42:49 +0000 |
commit | 1ddb79d6f180581a75895db8d9cd8890cef7cf3d (patch) | |
tree | 9263aceed3a08c5c8973297940957e24a17f7f57 /spec/spec_helper.rb | |
parent | e9783a360d3dd6011103a6aa69923d8acaff3fb2 (diff) |
Give warning, rather than error, if /usr/bin/validate isn't there.
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 360b2f38b..43a67d304 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -31,30 +31,36 @@ def receive_incoming_mail(email_name, email_to) end # Monkeypatch! Validate HTML in tests. +$html_validation_script = "/usr/bin/validate" # from Debian package wdg-html-validator if $tempfilecount.nil? $tempfilecount = 0 - module ActionController - module TestProcess - alias :original_process :process - - def process(action, parameters = nil, session = nil, flash = nil) - # Call original process function - self.original_process(action, parameters, session, flash) - - # And then validate if HTML - if @response.content_type == "text/html" and @response.response_code != 302 - $tempfilecount = $tempfilecount + 1 - tempfilename = File.join(Dir::tmpdir, "railshtmlvalidate."+$$.to_s+"."+$tempfilecount.to_s+".html") - File.open(tempfilename, "w+") do |f| - f.puts @response.body - end - if not system("/usr/bin/validate", tempfilename) - raise "HTML validation error in " + tempfilename + " HTTP status: " + @response.response_code.to_s + if File.exist?($html_validation_script) + module ActionController + module TestProcess + # Hook into the process function, so can automatically get HTML after each request + alias :original_process :process + + def process(action, parameters = nil, session = nil, flash = nil) + # Call original process function + self.original_process(action, parameters, session, flash) + + # And then if HTML, validate it + if @response.content_type == "text/html" and @response.response_code != 302 + $tempfilecount = $tempfilecount + 1 + tempfilename = File.join(Dir::tmpdir, "railshtmlvalidate."+$$.to_s+"."+$tempfilecount.to_s+".html") + File.open(tempfilename, "w+") do |f| + f.puts @response.body + end + if not system($html_validation_script, tempfilename) + raise "HTML validation error in " + tempfilename + " HTTP status: " + @response.response_code.to_s + end + File.unlink(tempfilename) end - File.unlink(tempfilename) end end end + else + puts "WARNING: HTML validation script " + $html_validation_script + " not found" end end |