Scott Raymond wrote:> Hey all-
>
> A while ago I posted my custom assertion that validates (X)HTML. Now
> I''ve packaged it as a plugin:
>
> http://wiki.rubyonrails.com/rails/pages/Plugins#avm
>
> You can install it by entering this from your project directory:
>
> svn export http://redgreenblu.com/svn/projects/assert_valid_markup \
> vendor/plugins/assert_valid_markup
>
> To use it, assuming you have a FooController and actions Bar and Baz,
> add this to your foo_controller_test.rb:
>
> assert_valid_markup :bar, :baz
>
> Now, if something changes to invalidate the markup of those actions,
> you''ll know right away -- any validation errors will be listed
when
> the tests are run. Responses from the web service are cached, so your
> tests won''t be slowed by duplicate requests. See the README for
more
> examples.
Hi Scott,
This looks great.
I''ve done something similar, but using the builtin HTML validator
instead, to do
a simple check, and that was just to intercept all the gets, puts, and posts
with the HTML checker:
class Test::Unit::TestCase
# For each of the HTTP request methods, run assert_tag over the
# response, which will at least print warnings about incorrect
# closing tags to the terminal.
%w( get post put delete head ).each do |method|
method_without_assert_tag = "#{method}_without_assert_tag".to_sym
unless method_defined?(method_without_assert_tag)
alias_method "#{method}_without_assert_tag".to_sym,
method.to_sym
class_eval <<-EOV
def #{method}(action, parameters = nil, session = nil, flash = nil)
#{method}_without_assert_tag(action, parameters, session, flash)
assert_tag :tag => ''html''
end
EOV
end
end
end
It would be handy if you had an easy way of having your plugin doing that to
every request made via some class method, or maybe when you include the module.
Regards,
Blair
--
Blair Zajac, Ph.D.
<blair-szbw9MROnEZWk0Htik3J/w@public.gmane.org>
Subversion and Orca training and consulting
http://www.orcaware.com/svn/