HttpTest

A plugin for HTML validation and link checking over HTTP. Can be used for monitoring of production servers as well as acceptance testing against staging and development servers.

Usage

Use the link validator to validate your homepage:
  • ./vendor/plugins/http_test/script/validate http://my.blog.com—validators tidy,xmllint
Add validation to your controller or integration tests:
  • get :some_action
  • assert_response :success

The following validates using all three validators: tidy, w3c, xmllint. To use a specific validator, use one of assert_tidy, assert_w3c, and assert_xmllint. assert_validates

Validate all requests in your controller, integration, and http tests by adding these lines to your RAILS_ROOT/test/test_helper.rb file:

1 ApplicationController.validate_all = true
2 ApplicationController.validators = [:tidy]

Validators and Dependencies

To use Tidy for HTML validation you need the rails_tidy plugin. The xmllint validation option requires xmllint to be available on the command line. The xmllint validator is part of libxml2. The W3C validator has no dependencies since we access it via the web.

I recommend using both tidy and either w3c (slow) or xmllint (slightly faster) for validation. Tidy gives useful warnings for example about empty tags, but it misses obvious validation failures such as lack of HTML quoting or unclosed tags.

Tests

If you make changes to this plugin, remember to run the tests with rake. The tests require the rails_tidy and mocha plugins as well as xmllint.

Tags

Currently tagged with: testing
You need to Login to tag this item.