Assert Valid Asset plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install http://www.realityforge.org/svn/public/code/assert-valid-asset/trunk/
HowTo Validate (X)HTML
# Calling the assertion with no parameters validates # whatever is in @request.body, which is automatically # set by the existing get/post/etc helpers. For example: class FooControllerTest < Test::Unit::TestCase def test_bar_markup get :bar assert_valid_markup end end # Add a string parameter to the assertion to validate # any random fragment. For example: class FooControllerTest < Test::Unit::TestCase def test_bar_markup assert_valid_markup "Hello, world." end end # For the ultimate in convenience, use the class-level # method to validate a number of actions in one line. class FooControllerTest < Test::Unit::TestCase assert_valid_markup :bar, :baz, :qux end
HowTo Validate CSS
# Pass a string parameter to the assertion to validate # a css fragment. For example: class FooControllerTest < Test::Unit::TestCase def test_bar_css filename = "#{RAILS_ROOT}/public/stylesheets/bar.css" assert_valid_css(File.open(filename ,'rb').read) end end # For the ultimate in convenience, use the class-level # method to validate a bunch of css files in one line. # Assumes that the CSS files are relative to # $RAILS_ROOT/public/stylesheets/ and end with '.css'. # The following example validates # $RAILS_ROOT/public/stylesheets/layout.css, # $RAILS_ROOT/public/stylesheets/standard.css and # $RAILS_ROOT/public/stylesheets/theme.css class FooControllerTest < Test::Unit::TestCase assert_valid_css_files 'layout', 'standard', 'theme' end
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: hardway, about 1 year ago

