October 21, 2009

RSpec have_text vs include_text

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”