Test the html in your functional tests using the wicked Hpricot CSS / XPath selectors. Requires Hpricot. Designed for use with ActiveSupport::TestCase (Test/Unit)
gem install should_pricot (or use bundler)
I want to test something appears on the page:
I want to test something does not appear:
I want to check an elements contents:
element('.intro p').should_be 'Welcome'
I want to count the number of times something appears:
count('ol#girlfriends li').should_be 6
You can also pass a regex
element("div.wicked").should_be /containg this/
You can also pass in html
Please refer to the Hpricot library for more examples of the kind of selectors available.
Designed to be used with the funktional testing library which provides contexts and class level assertions on top of Test:Unit.
Mad props to Kid80 for the regex matching patch.
Copyright © 2009 [Brent Greeff], released under the MIT license