[rspec-users] Help with w3c html validation on every rspec requests

mix fausto.galli at email.it
Mon Dec 28 18:16:19 EST 2009

Hi, I'm studying rspec in these days (the rspec book is really
great... i'll wait for the missing chapters and a next "rspec advanced
book" :) ). But for now i'm trying to solve a problem.
I'm a kind of w3c validation fanatic, i mean, i like to give my
clients well written code (following "The Standard" when possible....
and we all know that is better having not messed up html to avoid bad
layout....eg a missing closed table tag or stuff like that). So i want
to add an automated w3c check for all the requests (get, post, put and
Currently i'm having a cucumber step, but that's not really something
the client would care about (but i do, as i don't call my variables
"xyz" :) ), and because of this i'd move the check into the controller
specs (using response.body.should be_xhtml_strict).
The problem about this is that i'd do for all the requests another
line after them with the validity check...but that's valid for all of
the requests, and that would be quite a repetition (if i wan't to
change from strict to transitional i'll have to make N changes).. so
the question is...
Which is the easier way?
Should i write a method like:

def check_xhtml_validation(response) do
response.body.should be_xhtml_strict

and then put check_xhtml_validation(response) after every request, or
is there another way to do it? (maybe without having to call everytime
that method....as it would be forgotten, and difficult to track in
that case... but instead having something which is called everytime
after a request that check it, without explicitly call it...in this
case, how would achieve this?)


More information about the rspec-users mailing list