Search code examples
htmlruby-on-railsvalidationrubygemsruby-on-rails-plugins

RoR plugin/gem for html validation


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...


Solution

  • 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.