Check that a text field is empty with Cucumber

Posted Over 13 years ago. Visible to the public.

This will not work (it always passes):

Then the "Title" field should contain ""

The value is turned into a regular expression, and an empty regular expression matches any string!

Do this instead for Capybara:

Then the "Title" field should contain "^$"

And do this step for Webrat:

Then /^the "([^"]*)" field should( not)? be empty$/ do |field, negate|
  expectation = negate ? :should_not : :should
  field_labeled(field).value.send(expectation, be_blank)
end
Henning Koch
Last edit
Almost 13 years ago
Keywords
cucumber
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2010-09-15 17:21)