[rspec-users] webrat cannot find label?

Barry Mitchelson barry.mitchelson at gmail.com
Fri Nov 14 13:54:07 EST 2008


On Thu, Nov 13, 2008 at 7:41 PM, James B. Byrne <byrnejb at harte-lyne.ca>wrote:

>
> On Thu, November 13, 2008 14:02, James B. Byrne wrote:
>
> >
> > What is the correct syntax to test selecting from a range of values
> > present in an input box?  ...
>

> The webrat API specifies this:
>
>  selects(option_text, options = {})
>
> Verifies that a an option element exists on the current page with the
> specified text. You can optionally restrict the search to a specific
> select list by assigning options[:from] the value of the select list's
> name or a label. Stores the option's value to be sent when the form is
> submitted.
>

The API says to use the option text, not the value.


>
> But when I try to use something like:
>
>    And I select "CORP" from "Legal Form"
>        # features/step_definitions/webrat_steps.rb:16
>

CORP is the value of the option, the text is "CORP - Corporation"

Does this work?

Barry


>
> This is what happens:
>
>      You have a nil object when you didn't expect it!
>      The error occurred while evaluating nil.choose (NoMethodError)
>
>  /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/core/scope.rb:91:in
> `selects'
>      /usr/lib/ruby/gems/1.8/gems/webrat-0.3.2/lib/webrat/rails.rb:88:in
> `send'
>
>
> So, checking out webrat.steps I see this:
>
> When /^I select "(.*)" from "(.*)"$/ do |value, field|
>  selects(value, :from => field)
> end
>
> So, as far as I can make out, given the webrat API specifies that a label
> is an acceptable target, this should work.  But it evidently does not.  Is
> this a webrat problem then?
>
>
> --
> ***          E-Mail is NOT a SECURE channel          ***
> James B. Byrne                mailto:ByrneJB at Harte-Lyne.ca
> Harte & Lyne Limited          http://www.harte-lyne.ca
> 9 Brockley Drive              vox: +1 905 561 1241
> Hamilton, Ontario             fax: +1 905 561 0757
> Canada  L8E 3C3
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081114/a18ca413/attachment.html>


More information about the rspec-users mailing list