I am learning how to write tests with cucumber/webrat. One of my test scenarios is set to test form validation (leaving field(s) empty). Strangely enough, fields that I do not fill-in with fill_in
are set to the field's name
attribute. This only happens when I run cucumber, when using a browser this does not happen.
The step I'm using is straight forward:
When /^I submit the form$/ do
# Not filling in the 'Name' field here
fill_in 'Description', :with => 'This is a description'
click_button 'Save'
end
After running the scenario that uses the step above, I can see that the text field "Name" is set to "name" instead of being empty. This is also the case if I fill in that field with an empty space or nil
:
fill_in 'Name', :with => ''
The form I'm testing on is simple enough:
<form action="/item/create" method="post">
<div>
<label for="ItemName">Name</label>
<input type="text" name="name" id="ItemName" />
</div>
<div>
<label for="ItemDescription">Description</label>
<textarea name="description" id="ItemDescription"></textarea>
</div>
<input type="submit" value="Save" />
</form>
Any idea why this is happening?