[rspec-users] custom, nested HTML matchers in RSpec

Phlip phlip2005 at gmail.com
Sun Mar 15 14:47:39 EDT 2009

Zach Dennis wrote:

> I didn't have the expectation that they were peers of each other, just
> that they both existed somewhere in a fieldset tag. Any helper or
> matchers used for spec'ing views should be as liberal as possible
> while still communicating enough about the semantics of the page for
> the example to be meaningful.
> I would not expect nor want a matcher to default to verifying direct
> descendant, sibling, or adjacent nodes. Those are best verified by a
> person looking at the page. What I do care about is that fields in are
> within a fieldset (but not necessarily immediately next to each
> other).

However, I constantly must write extra test code just to check things are in the 
right order. Specifically, I could not use my original assert_xhtml to replace 
tests that checked some <option> values appeared in collating order. (Yes, tests 
on the model also checked those fields appeared in collating order, AND tests on 
the controller checked thru the "assigns" that those fields were in collating 

I am not going to target strict relationships, just the general order. But I 
have to draw the line somewhere!

More information about the rspec-users mailing list