capybara Rails3'无法填写'

时间:2012-02-13 21:29:18

标签: ruby-on-rails-3 cucumber capybara

这是非常令人沮丧的,在检查了相关主题的所有stackoverflow查询之后,看起来似乎已经通过了测试,我无法让这个简单的事情排队并通过。它无法在form_for(@price)中找到标签“quality”。

 And I fill in "good" in Quality
 cannot fill in, no text field, text area or password field with id, name, or label    'price[quality]' found (Capybara::ElementNotFound)

我的功能(删节)

 Scenario: Adding corn price
  And I fill in "good" in Quality

我的步骤(删节)

  When /^I fill in "([^"]*)" in Quality$/ do |text|
   fill_in('price[quality]', :with => text)
  end

我的表格:

 <%= form_for (@price), :url => prices_path  do |f| %>
   <div class="field">
    <%= f.label :quality %><br />
     <%= f.text_field :quality %>
   </div>

我的来源:

 <div class="field">
   <label for="price_quality">Quality</label><br />
   <input id="price_quality" name="price[quality]" size="30" type="text" />
   </div>

我已经尝试了很多组合来让它通过,而且我已经用尽了组合尝试,山姆

1 个答案:

答案 0 :(得分:0)

下一步使用:

When /^I fill in "([^"]*)" in Quality$/ do |text|
  fill_in('price_quality', :with => text)
end