[rspec-users] response.body.should be_xml_with -- how to do nested xpath matches
phlip2005 at gmail.com
Mon Mar 9 02:43:05 EDT 2009
Zach Dennis wrote:
> XPath is merely the mechanism in which you're allowed to find
> particular elements on a page. After typing:
> xpath :input, :name => "foo"
> xpath :input, :name => "bar"
> xpath :input, :name => "baz"
> I would probably write my own wrapper so I could omit the redundant
> "xpath" call all over the place. After all, I only care that the input
> is found, if it uses XPath to do it--awesome.
Yet such a wrapper can fit quite comfortably on the application side - not
necessarily on the vendor side. For example, if I care that a given sequence of
inputs have a class keyed to the current user's permissions, then that (and the
naughty xpath) go inside the new custom assertion: assert_input_for(@user). Such
wrappers obviously should not fall on the vendor side.
I like leaving the XPath hanging out because its operators and axes are always
available _without_ more DSLization.
Your remaining points are noted - the answers are either "violent agreement" or
"then don't do it like that". Augmented by my next post!
More information about the rspec-users