Cucumber Feature Failing Selecting Option
Can't figure out why this feature won't pass...I know it's working from manual testing, but I'm continually getting this error
cannot select option, no option with text 'Don Moen' in select box 'audio_file[artist_id]' (Capybara::ElementNotFound) (eval):2:in `select' ./features/step_definitions/web_steps.rb:34:in `/^I select "(.*?)" from "(.*?)"$/' features/adding_audio.feature:19:in `When I select "Don Moen" from "audio_file[artist_id]"'
Background: Given I am on the home page And I have an admin account And I submit valid login information And I am in the admin panel And I follow "New Upload" Scenario: Adding Audio with Existing Artist Given the following Artists exist | name | | Don Moen | When I fill in "Title" with "Song Name" When I select "Don Moen" from "audio_file[artist_id]" And I press "Upload" Then I should not see an error message
Problem step definitions:
Given /^the following Artists exist$/ do |table| table.hashes.each do |attributes| Artist.create :name => attributes[:name] end end When /^I select "(.*?)" from "(.*?)"$/ do |option, field| page.select option, :from => field end
I know the problem has something to do with the model not saving in the database, because if I manually add that artist in the test console, the feature passes.
Maybe some db configuration I have screwed up?
I can't tell at which point you actually visit the page, but I suspect you're doing before before the artist records are created, therefore the dropdown will be empty.