[rspec-users] Can cucumber/webrat set a value on a hidden field

Tom Hoen lists at ruby-forum.com
Wed Feb 4 13:49:02 EST 2009


I am using auto_complete to provide a list of persons from which the
user can select one. On selection from the auto_complete list, a hidden
field is updated with the id of the selected person. This is all wrapped
in a form, that then can be submitted by the user (by clicking the
provided submit button). On submission, the person (based on the id in
the hidden field) is added to a group.

I assume I can’t use the auto_complete ajax calls from within Cucumber.
But I wondered if I could make a step that would update the value of the
hidden field (as if I had selected the user from the auto_complete
field).

According to this documentation
(http://gitrdoc.com/brynary/webrat/tree/master/classes/Webrat/Scope.html)
there should be a set_hidden_field method. But the method no longer
appears to be in the webrat/core/scope.rb file

Based on the above documentation the method should be
# File lib/webrat/core/scope.rb, line 53
    def set_hidden_field(field_locator, options = {})
      field = locate_field(field_locator, HiddenField)
      field.set(options[:to])
    end

but adding this into the scope.rb file, still gives me
undefined method `set_hidden_field' for
#<ActionController::Integration::Session:0xb72c191c> (NoMethodError)
when I try to call it in a step.

Any help would be greatly appreciated.

Tom
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list