views:

90

answers:

2

I am wondering if there is such a plugin or gem for Ruby on Rails that includes HTML validation (SGML or Tidy) in a testing cycle.

I am aware only about this plugin. Looking for alternatives...

+1  A: 

I use be_valid_asset with rspec and cucumber. It uses the public W3C validator. It does not have the link checking that html_test has.

I use it in these two steps in cucumber's webrat_steps.rb:

Given /^(?:|I )am on (.+)$/ do |page_name|
  visit path_to(page_name)
  response.should be_valid_xhtml if ENV['VALIDATE_HTML']
end

When /^(?:|I )go to (.+)$/ do |page_name|
  visit path_to(page_name)
  response.should be_valid_xhtml if ENV['VALIDATE_HTML']
end

Then I can run rake VALIDATE_HTML=1 cucumber to validate all pages visited by my cucumber feature files.

ScottJ
Thanks, Scott.It worked well for me.And I like your trick with env variable :)
Konstantin
A: 

Here's a Rack-based validator that can be used live: http://coderack.org/users/nerdEd/entries/95-rackvalidate

Jonathan Julian