ResponsibleMarkup v0.1: Unit Test Your Way To Responsible Markup
I’m proud to announce a new Rails plugin: ResponsibleMarkup. It allows you to write functional tests for your Rails application which test for things like:
- (X)HTML markup validity
- Backwards-compatible empty HTML elements
- Well-formed doctypes
- Unobtrusive Javascript
- Well-formed XML prologs
- Separation of display and structure in your markup
You can check out the documentation or go ahead and install it:
./script/plugin install http://svn.codahale.com/responsible_markup/trunk
Or, if your application is source-controlled via Subversion:
./script/plugin install -x http://svn.codahale.com/responsible_markup/trunk
May 25th, 2006 at 2:55pm
Nice plugin, I will try it.
I made a similar one to validate feeds (atom, RSS)
http://feedvalidator.rubyforge.org/
BTW, I invite you to register you and your blog in http://rubycorner.com
Regards
June 12th, 2006 at 1:24pm
[...] responsible_markup [...]
December 29th, 2006 at 12:38pm
[...] If you’re not using it already in your RoR projects I can recommend the excellent Responsible Markup plugin that enables us to add assertions such as assert_valid_html into our Functional Tests. [...]
January 26th, 2007 at 2:11am
Since this plugin was created the W3C have made two minor updates to the validator and I’m not sure this plugin works with the latest (0.7.4). I also see from reading the W3C documentation that the XML output format has been deprecated it seems in favour of a SOAP based API. Have you any plans to update the plugin to stay up-to-date with the validator?
February 5th, 2007 at 9:33pm
Rails valid markup testing…
Coda Hale has given the intersection of the Rails and web standards communities a very nice plugin for keeping your markup clean. It is aptly, if slightly pretentiously, named Responsible Markup.
But let’s be honest, do you really want to spend m…
October 4th, 2007 at 1:48pm
I put this in test_helper, hopefully somebody else might find it useful
def validate_each_action
do_not_have_internet = false
def revise_message(action,message)
"For action #{action}, #{message.downcase}"
end
each_action do |action|
get action
follow_redirect if @response.redirect?
next unless @response.success?
assert_doctype(:html_401_strict, revise_message(action, ResponsibleMarkup::MSG_DOCTYPE_ERROR))
assert_content_type({}, revise_message(action, ResponsibleMarkup::MSG_CONTENT_TYPE_ERROR))
assert_unobtrusive_javascript({}, revise_message(action, ResponsibleMarkup::MSG_OBTRUSIVE_JAVASCRIPT))
assert_no_long_style_attributes({}, revise_message(action, ResponsibleMarkup::MSG_LONG_STYLE_ATTRIBUTES))
assert_valid_html rescue ResponsibleMarkup::ConnectionError do_not_have_internet = true
end
flunk 'could not validate HTML, no connection to internet' if do_not_have_internet
end
# returns an array of each template, maybe needs a name change?
def each_action
controller_name = self.class.to_s.gsub('ControllerTest','').downcase
Dir.chdir("app/views/#{controller_name}") do
Dir['[^_]*.rhtml’].collect{|f| File.basename(f, ‘.*’)}.each do |action_name|
yield action_name.to_sym if block_given?
end
end
end