Topic: When I fill the form properly

This particular step is giving me problems as its unreliable some time it works and then i can run the test 10s later and it passes

When /^I fill the form properly$/ do
  @f_test = Fabricate(:test)
  @service = Service.where("account_id = ?" , 1).order("LOWER(name)")
  @staff = Staff.where("account_id = ?" , 1).order("LOWER(first_name)")
  fill_in('test_name', :with =>
  fill_in('test_description', :with => @f_test.description)
  select(, :from => "test_service_id")
  select(@staff.last.first_name, :from => "test_staff_id")

When I fill the form properly # features/step_definitions/test.rb:1
      cannot select option, no option with text 'Mason' in select box 'test_staff_id' (Capybara::ElementNotFound)
      (eval):2:in `select'
      ./features/step_definitions/test.rb:33:in `/^I fill the form properly$/'
      features/test.feature:26:in `When I fill form properly'

How can i write this test so that it works better

Last edited by moiseszaragoza (2012-06-25 16:29:07)

Re: When I fill the form properly

Is right?
Should it be last_name?

Last edited by jasnow (2012-06-25 18:27:33)

Re: When I fill the form properly

the problem i am having is in the these 2 lines but its random

select(, :from => "test_service_id")
  select(@staff.last.first_name, :from => "test_staff_id")