Check that a text field is empty with Cucumber

Updated . Posted . 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
Profile picture of Henning Koch
Henning Koch
Last edit
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)