June 23, 2006
Older: Streamlined
Newer: Martin Fowler Keynote
Assert Valid Markup
Wow, this is pretty cool. Scott Raymond just posted a test helper that posts to the w3c’s validator and asserts that the response is valid. The helper that should go in test/test_helper.rb is …
def assert_valid_markup(markup=@response.body)
require 'net/http'
response = Net::HTTP.start('validator.w3.org') do |w3c|
query = 'fragment=' + CGI.escape(markup) + '&output=xml'
w3c.post2('/check', query)
end
assert_equal 'Valid', response['x-w3c-validator-status']
end
The example use he provided is …
def test_home
get :home
assert_valid_markup
end
For a standards nut like me, this could come in really handy.
0 Comments
Thoughts? Do Tell...