lib/assert_valid_asset.rb
# Assert that css is valid according the W3C validator web service.
# You pass the css as a string to the method. 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 css file standard.css you can add the following test;
#
#   def test_standard_css
#     assert_valid_css(File.open("#{RAILS_ROOT}/public/stylesheets/standard.css",'rb').read)
#   end
#
Assert that css is valid according the W3C validator web service.
You pass the css as a string to the method. 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 css file standard.css you can add the following test.


Assert that css is valid according the W3C validator web service . You pass the css as a string to the method . 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 css file standard . css you can add the following test .
def assert_valid_css(css = @response.body)
    return if Validator.instance.disabled?
    id = self.class.name.gsub(/\:\:/,'/').gsub(/Controllers\//,'') + '.' + method_name
    errors = Validator.instance.validate_css(css, id)
    assert errors.empty?, errors.join("\n")
  end
def assert_valid_css ( css = @response . body ) return if Validator . instance . disabled? id = self . class . name . gsub ( / \: \: / , '/' ) . gsub ( / Controllers \/ / , '' ) + '.' + method_name errors = Validator . instance . validate_css ( css , id ) assert errors . empty? , errors . join ( "\n" ) end
Assert that css is valid according the W3C validator web service.
Assert that css is valid according the W3C validator web service .
css
<not_specific>
body
<not_specific>