Webrat is a lovely testing tool, particularly when used with Cucumber. But every time I put it aside for a few weeks, when I come back to it, I forget about this…
And I fill in "name" with "John Doe" Could not find field: "name" (Webrat::NotFoundError)
but when I go to the .html.erb file, I see the field, plainly defined:
<%= f.text_field :name %>
So why doesn’t webrat find the field? Because the field is NOT named "name". It is named "user_name". This is because it is wrapped inside
<% form_for :user, :url => users_path do |f| -%>
Because of the form_for, all field names get prefixed with the form name.