Tom Hoen
2009-Feb-04 18:49 UTC
[rspec-users] Can cucumber/webrat set a value on a hidden field
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/.
Bart Zonneveld
2009-Feb-05 15:34 UTC
[rspec-users] Can cucumber/webrat set a value on a hidden field
On 4-feb-2009, at 19:49, Tom Hoen wrote:> 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 fileProbably 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
Tom Hoen
2009-Feb-05 19:04 UTC
[rspec-users] Can cucumber/webrat set a value on a hidden field
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 -- Posted via http://www.ruby-forum.com/.