1

无法弄清楚为什么这个功能不会通过......我知道它是通过手动测试工作的,但我不断收到这个错误

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

问题步骤定义:

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

我知道问题与模型未保存在数据库中有关,因为如果我在测试控制台中手动添加该艺术家,该功能就会通过。

也许我搞砸了一些数据库配置?

4

1 回答 1

2

我不知道您实际访问该页面的时间点,但我怀疑您在创建艺术家记录之前就已经这样做了,因此下拉菜单将为空。

于 2012-06-14T10:20:08.503 回答