[rspec-users] webrat cannot find label?

Bart Zonneveld zuperinfinite at gmail.com
Fri Nov 14 07:51:15 EST 2008


On 13-nov-2008, at 20:41, James B. Byrne 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.
>
> 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'

Are you 100% sure the thing you are selecting exists in the select  
box? That has bitten me in the butt a few times..

cheers,
bartz


More information about the rspec-users mailing list