The tutorial docs I’ve looked at don’t mention this, but there is a handy new test utility for your response objects.
response.should include_text("blah blah")
which tests to see if “blah blah” is anywhere on the page.
This compares favorably to
response.should have_text("blah blah")
which tests if the entire text of the page == “blah blah”
If you’re not using them yet, I’d strongly recommend looking at the webrat matchers for rspec. There is a contain matcher (response.should contain(“blah blah”)) that works like have_text, and the have_selector and have_xpath matchers are really expressive and powerful. That, and the rspec equivalents will likely be deprecated and removed when we release a rails-3 compatible version.
Comment by David Chelimsky — October 23, 2009 @ 10:59 am
Good to know, thanks!
Comment by jb — October 30, 2009 @ 1:56 pm