How to use Cucumber in forms with custom labels

cucumber, ruby-on-rails

Solution

Webrat uses the label text to locate the field to fill in. In your first example, are you not setting this label to "Nome"?

Does `And I fill in "Nome" with "Reitoria do Porto"` work?

Problem

I'm trying to learn how to use cucumber and got this issue: I have a form that as: ``` <p> <%= f.label :name, "Nome" %><br /> <%= f.text_field :name %> </p> ``` And in my cucumber feature I have: ``` And I fill in "name" with "Reitoria do Porto" ``` This make the test fail with: ``` And I fill in "name" with "Reitoria do Porto" # features/step_definitions/web_steps.rb:34 Could not find field: "name" (Webrat::NotFoundError) (eval):2:in `fill_in' ./features/step_definitions/web_steps.rb:35:in `/^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/' features/manage_institutions.feature:10:in `And I fill in "name" with "Reitoria do Porto"' ``` However if I just make the form like this: ``` <p> <%= f.label :name %><br /> <%= f.text_field :name %> </p> ``` The test passes. How can I keep my custom label name and make the test pass?

Original source