Automatic Markup Validation

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Automatic Markup Validation - Presentation Transcript

    1. Automatic Markup Validation Aron Atkins aron@spotstory.com 617.335.2871 Boston Ruby Group April 10, 2007 1
    2. What’s the story? • Mechanical validation of many formats • XHTML/HTML • CSS • RSS • etc. • Checking for legal markup reduces risk • Dangling div, td, etc. 2
    3. Available Plugins • assert_valid_markup • Uses W3 Validator to check XHTML/HTML • A local server can improve performance • assert_valid_asset • Built upon assert_valid_markup • Adds CSS validation using W3 • RSS parser built into Ruby • Future could use public validators (ATOM, etc) • Other XML formats? DTD? 3
    4. Give a little helper ... • Install assert_valid_markup • Install the test_validation_helper.rb • http://blog.spotstory.com/2007/04/09/ automatic-markup-validation • test/test_helper.rb require File.expand_path( File.dirname(__FILE__) + "/test/test_validation_helper.rb") 4
    5. Don’t be shy ... • test/test_validation_helper.rb alias :non_validating_get :get alias :non_validating_post :post def get(path, parameters=nil, headers={}, flash=nil) non_validating_get path, parameters, headers, flash check_markup end def post(path,parameters=nil,headers={}, flash=nil) non_validating_post path, parameters, headers, flash check_markup end 5
    6. Validation Dispatch • test/test_validation_helper.rb def check_markup return if ! ENV['NO_VALIDATION'].nil? if @response.redirect? elsif javascript_response? || json_response? || kml_response? elsif xml_response? assert_rss_valid print "+" else assert_html_valid print "+" end end 6
    7. HTML Validation • test/test_validation_helper.rb def assert_html_valid begin assert_valid_markup rescue print " VALIDATION FAILED: HEADERS: " @response.headers.each { |hdr,val| print " #{hdr}: #{val} " } print "BODY: " print @response.body + " " raise # re-raise after showing the failing body. end end 7
    8. RSS Validation • Using the Ruby builtin module def assert_rss_valid assert_not_nil @response.body # Ignore unknown elements because the built-in Ruby RSS # support doesn't fully understand extensions. RSS::Parser.parse(@response.body, true, true) # Make sure all the objects have been processed. assert_no_match /cannot be processed/, @response.body end 8
    9. Get the code • Posted on the Spotstory Blog: http://blog.spotstory.com/2007/04/09/ automatic-markup-validation/ • • Email: aron@spotstory.com 9

    + Aron AtkinsAron Atkins, 3 years ago

    custom

    2360 views, 1 favs, 1 embeds more stats

    A short presentation explaining how to automaticall more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2360
      • 2350 on SlideShare
      • 10 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 0
    Most viewed embeds
    • 10 views on http://blog.spotstory.com

    more

    All embeds
    • 10 views on http://blog.spotstory.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories