[rspec-users] How to write a step for a feature with a select control

Damian Jones lists at ruby-forum.com
Tue Sep 16 10:55:23 EDT 2008

David Chelimsky wrote:

> 2. add the data in the current step
> When(/^I pick "(.*)" from (.*)$/) do |option_value, field_name|
>   field_name.gsub(' 
> ','').constantize.find_or_create_by_name(option_value)
>   selects option_value, :from => field_name
> end

HI David, I tried the method above but I am getting "You have a nil 
object when you didn't expect it"

I can see that the following line is creating a new ArticleCategory with 
:name => "My article category" (BTW is it just coincidence that I have 
the field :name in my Article category table or is this a convention I 
should be following anyway?)

field_name.gsub(' ','').constantize.find_or_create_by_name(option_value)

But I don't see where this new ArticleCategory is getting bound to the 
select control.

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list