lib/assert_valid_asset.rb
# Assert that markup (html/xhtml) is valid according the W3C validator web service.
# By default, it validates the contents of @response.body, which is set after calling
# one of the get/post/etc helper methods. You can also pass it a string to be validated.
# Validation errors, if any, will be included in the output. The input fragment and
# response from the validator service will be cached in the $RAILS_ROOT/tmp directory to
# minimize network calls.
#
# For example, if you have a FooController with an action Bar, put this in foo_controller_test.rb:
#
#   def test_bar_valid_markup
#     get :bar
#     assert_valid_markup
#   end
#
Assert that markup (html/xhtml) is valid according the W3C validator web service.
By default, it validates the contents of @response.body, which is set after calling
one of the get/post/etc helper methods. You can also pass it a string to be validated.
Validation errors, if any, will be included in the output. The input fragment and
response from the validator service will be cached in the $RAILS_ROOT/tmp directory to
minimize network calls.

For example, if you have a FooController with an action Bar, put this in foo_controller_test.rb.


Assert that markup ( html / xhtml ) is valid according the W3C validator web service . By default it validates the contents of @response . body which is set after calling one of the get / post / etc helper methods . You can also pass it a string to be validated . Validation errors if any will be included in the output . The input fragment and response from the validator service will be cached in the $RAILS_ROOT / tmp directory to minimize network calls . For example if you have a FooController with an action Bar put this in foo_controller_test . rb .
def assert_valid_markup(fragment = @response.body, message = nil)
    return if Validator.instance.disabled?
    id = self.class.name.gsub(/\:\:/,'/').gsub(/Controllers\//,'') + '.' + method_name
    template = "? markup errors\n?\n#{'-' * 80}\n?"
    errors = Validator.instance.validate_markup(fragment, id)
    index = 0
    content = display_invalid_content ? AssertionMessage.literal(fragment.split($/).map{|line| "#{'%04i' % (index += 1)} : #{line}"}.join($/)) : ""
    assert_block(build_message(message, template, errors.size, AssertionMessage.literal(errors.join("\n")), content)) { errors.empty? }
  end
def assert_valid_markup ( fragment = @response . body , message = nil ) return if Validator . instance . disabled? id = self . class . name . gsub ( / \: \: / , '/' ) . gsub ( / Controllers \/ / , '' ) + '.' + method_name template = "? markup errors\n?\n#{'-' * 80}\n?" errors = Validator . instance . validate_markup ( fragment , id ) index = 0 content = display_invalid_content ? AssertionMessage . literal ( fragment . split ( $/ ) . map { | line | "#{'%04i' % (index += 1)} : #{line}" } . join ( $/ ) ) : "" assert_block ( build_message ( message , template , errors . size , AssertionMessage . literal ( errors . join ( "\n" ) ) , content ) ) { errors . empty? } end
Assert that markup (html/xhtml) is valid according the W3C validator web service.
Assert that markup ( html / xhtml ) is valid according the W3C validator web service .
fragment
<not_specific>
body
<not_specific>
message
<not_specific>