Forum: RSpec Can cucumber/webrat set a value on a hidden field

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.
2f030c2a9e4e1e165a0cb360805951f3?d=identicon&s=25 Tom Hoen (hoenth)
on 2009-02-04 19:49
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/clas...)
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
3880f04333bf8375b44cd6aa135406c7?d=identicon&s=25 Bart Zonneveld (Guest)
on 2009-02-05 16:59
(Received via mailing list)
On 4-feb-2009, at 19:49, Tom Hoen wrote:

> According to this documentation
> (http://gitrdoc.com/brynary/webrat/tree/master/clas...
> 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

Probably because it didn't appear *yet* into that file :).
I got bitten by the fact that I was using the wrong version of webrat
some days ago.
Using version 0.4.1, I can succesfully set hidden field using
set_hidden_field.


hope this helps,
bartz
2f030c2a9e4e1e165a0cb360805951f3?d=identicon&s=25 Tom Hoen (hoenth)
on 2009-02-05 20:04
Bart Zonneveld wrote:

> Using version 0.4.1, I can succesfully set hidden field using
> set_hidden_field.
>

Bart - Thanks for the heads up that 4.1 was released and contained the
set_hidden_field method.

I have updated my webrat plugin to 4.1, but unfortunately, sub-domain
redirects seem to be broken again (which was fixed in zdennis' fork:

git://github.com/zdennis/webrat.git
This topic is locked and can not be replied to.