Searching for empty form fields using rspec

Posted by Andrew Premdas Tue, 21 Jul 2009 10:05:00 GMT

Took me far to long to work out how to do this!

To find an empty input field we can look for

"input[type=text][value='']"

e.g.

response.body.should have_tag("input[type=text][value='']")

This is useful when filling in forms badly to make sure your bad values still remain when you return to the form to edit them.