Created
December 29, 2008 03:41
-
-
Save kangax/41163 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'net/http' | |
| require 'uri' | |
| require 'w3c_validators' | |
| include W3CValidators | |
| base_path = 'http://localhost:3000/' | |
| uris = [ | |
| 'login', | |
| 'register', | |
| 'designs', | |
| 'cart', | |
| 'browse', | |
| 'items', | |
| 'orders', | |
| 'settings' | |
| # TODO: figure out why service responds with 414 for "home" and "editor" pages | |
| #'home' | |
| #'editor' | |
| ] | |
| # transform paths to absolute | |
| uris = uris.map { |uri| base_path + uri } | |
| uris.each { |uri| | |
| separator = '.' * (50 - uri.size) | |
| url = URI.parse(uri) | |
| req = Net::HTTP::Get.new(url.path) | |
| res = Net::HTTP.start(url.host, url.port) { |http| | |
| http.request(req) | |
| } | |
| @validator = MarkupValidator.new | |
| results = @validator.validate_text(res.body) | |
| if results.errors.length > 0 | |
| puts "#{uri} #{separator} Error!\n" | |
| results.errors.each do |err| | |
| puts "#{err.to_s}\n" | |
| end | |
| else | |
| puts "#{uri} #{separator} Valid!" | |
| end | |
| # take it easy since requests are sent to a free public service | |
| sleep 1 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment