Http Test plugin
Plugin details
Documentation
ruby script/plugin install http://svn.marklunds.com/plugins/http_test/
== Usage
- 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 and integration tests by adding these lines to your RAILS_ROOT/test/test_helper.rb file:
ApplicationController.validate_all = true ApplicationController.validators = [:tidy, :w3c]
- Check for broken URLs (URLs that don't resolve to a route, a controller, and an action) in your links, images, forms, and redirects. Works both in your controller and integration tests. Add these lines to your RAILS_ROOT/test/test_helper.rb file:
ApplicationController.check_urls = true ApplicationController.check_redirects = true
- Follow links in your controller or integration tests:
include Http::Test::UrlSelector
def clicks_around
page_url = request.request_uri
anchor_urls.reject { |url| external_http?(url) || skip_url?(url) || url == page_url }.
reject { |url| url =~ /(logout|signout)/ }.uniq.each do |url|
get url
assert(@response.redirect? || @response.success?,
"Invalid response code #{@response.response_code} for url #{url}")
end
end
- Use the link validator to validate your staging or production server over HTTP:
./vendor/plugins/http_test/script/validate http://my.blog.com --validators tidy,xmllint
- Configuration options for your tests
Here is a list of configuration options to use in test/test_helper.rb:
# # Validates all controller and integration test requests if set to true:
# ApplicationController.validate_all = true # Default: false.
# ApplicationController.validators = [:tidy, :w3c, :xmllint] # Default: [:tidy]. Which validators to use.
# # A list of regular expressions for Tidy warnings to ignore:
# Http::Test::Validator.tidy_ignore_list = [/ lacks "summary" attribute/] # Default: [].
# # Set the URL of a locally installed W3C validator here:
# Http::Test::Validator.w3c_url = "http://localhost/validator/htdocs/check" # Default: "http://validator.w3.org/check"
# Http::Test::Validator.w3c_show_source = "0" # Default: "1". Whether to list HTML document in the W3C report
# ApplicationController.check_urls = true # Default: false. Whether to check URLs in all links
# ApplicationController.check_redirects = true # Default: false. Whether to check URLs in all redirects
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: hardway, 9 months ago

