ref: refs/heads/master
commit 4422c795f2b871128f2befc51462dab6bb48abcc
Author: Josef Reidinger
Date: Mon Jul 13 13:35:53 2009 +0200
add test for validation of generated page
---
webclient/test/validation_assert.rb | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/webclient/test/validation_assert.rb b/webclient/test/validation_assert.rb
new file mode 100644
index 0000000..80bc2af
--- /dev/null
+++ b/webclient/test/validation_assert.rb
@@ -0,0 +1,20 @@
+
+class ActionController::TestCase
+ def assert_valid_markup(markup=@response.body)
+ if @response.redirect?
+ return
+ end
+
+ fail("Tidy is not available") unless system("which tidy &>/dev/null")
+
+ validate_temp = File.new("#{RAILS_ROOT}/tmp/validate.html", 'w')
+ validate_temp.puts markup
+ validate_temp.close
+
+ system("tidy #{RAILS_ROOT}/tmp/validate.html 1>/dev/null 2>#{RAILS_ROOT}/tmp/validate.result")
+ result = `grep '^[0-9]\\+ warnings, [0-9]\\+ errors' #{RAILS_ROOT}/tmp/validate.result`
+ count = result.match(/(\d+)\D+(\d+)\D+/)
+ count = count[0]+count[1]
+ assert count == 0, "Find validation problems: "+`cat #{RAILS_ROOT}/tmp/validate.result`
+ end
+end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org