Peter Marklund

Peter Marklund's Home


Rails Testing: Checking for Broken URLs in Links, Images, Forms, and Redirects

I've added the ability to check for broken URLs in links, images, forms, and redirects to my Http Test plugin. How does this work? Well in your controller and integration tests an ApplicationController after filter is used to extract all the URLs on the page. For each URL we make sure it can be resolved to a route, a controller, and an action and/or template. URLs to files under the public directory will be recognized. The same check is made for redirects.

I haven't used this URL checking in production yet, but I'm hoping it will help me prevent mistyped URLs and params.