Sunday, July 30, 2006

Testing with CSS selectors

Posted by David

If you have trouble wrapping your head around assert_tag and its options, you might want to give CSS selectors a chance instead. There are currently two plugins for handling that: assert_select and hpricot helper.

The hpricot style gives you something like assert element('title').should_contain('Funky Chicken Title') and the assert_select gives you something like assert_select "title", "Welcome".

From a brief cursory overview, I tend to like the assert_select style better. But I have yet to use either for real stuff. Please do shoot a comment with your experiences. One of these methods could well make it into core.