[rspec-users] webrat cannot find label?

James B. Byrne byrnejb at harte-lyne.ca
Thu Nov 13 14:41:02 EST 2008


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.

Examples:

  selects "January"
  selects "February", :from => "event_month"
  selects "February", :from => "Event Month"



But when I try to use something like:

    And I select "CORP" from "Legal Form"
        # features/step_definitions/webrat_steps.rb:16

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



More information about the rspec-users mailing list