Forum: RSpec Oddness with fieldnames containing an underscore

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
473ccf0938761e73a3017356291c6eda?d=identicon&s=25 John Meredith (Guest)
on 2008-12-11 00:37
(Received via mailing list)
Hi all,

I'm not sure if this is a cucumber or webrat thing given that I only
starting tinkering with both last night for the first time (testing
newb as well), but I've come across an oddity when trying to write a
scenario to create a user.

   Scenario: Register new user
     Given I am on the new user page
     And I fill in "login" with "fredf"
     And I fill in "password" with "somepassword"
     And I fill in "password_confirmation" with "somepassword"
     And I select "Mr" from "title"
     And I fill in "given_names" with "Fred"
     And I fill in "surname" with "Flintstone"
     And I fill in "email" with "fredf@rocks.com"
     And I press "Create"
     Then there should be 1 more user

When I 'rake features' it halts at the password_confirmation line...

   Scenario: Register new user                             # features/
manage_users.feature:16
     Given I am on the new user page                       # features/
step_definitions/user_steps.rb:5
     And I fill in "login" with "johnm"                    # features/
step_definitions/webrat_steps.rb:12
     And I fill in "password" with "Lmmsoht"               # features/
step_definitions/webrat_steps.rb:12
     And I fill in "password_confirmation" with "Lmmsoht"  # features/
step_definitions/webrat_steps.rb:12
       Could not find field:
"password_confirmation" (Webrat::NotFoundError)

The test passes if I prepend "user_" to the field name ie.
"user_password_confirmation". Same applies to the 'given_names' field.

Is this a bug or am I making an incorrect assumption on how things are
supposed to work?

TIA,

   JohnM

--

"I'm not dumb. I just have a command of thoroughly useless information"
   - Calvin & Hobbes
85d99e7678d8720f6e00ab0f60fe6ea9?d=identicon&s=25 Andrew Premdas (Guest)
on 2008-12-11 05:36
(Received via mailing list)
Probably not a bug, if you look at the id's of the fields your matching
by
viewing source in your browser you'll see that they have an id that
begins
with 'user'. So when webrat fails to match on the label text it then
tries
to match on the id. You can use the debugger to step into the webrat
code
and see this yourself if you want
HTH

2008/12/10 John Meredith <johnm@psynix.com>
This topic is locked and can not be replied to.