关于使用Capybara& Rspec进行轨道测试...未找到capybara元素

时间:2013-10-10 18:45:10

标签: ruby-on-rails-4

我在我的rails应用程序中有两个模型让我们说公司模型和领导模型来添加潜在客户。我必须在添加新铅的同时测试铅形式。所以我使用了集成测试。我在我的表单上有字段,通过它我也更新了数据库,但没有找到capybara errors元素。我的代码为folows

新的潜在客户表格

<title>Add Contact</title>
<h1> Enter Lead information</h1>
<%= form_for @lead, :url => lead_path(@lead.id), :html => { :multipart =>true } do|f|%>                                                                                      
<p>
<%= f.label :Name %><br>
<%= f.text_field :name %>
</p>
<p>
<%= f.label :Linkedln_Address, 'Linkedln_Address' %><br>
<%= f.text_field :linkedln_address %>
</p>
<p>
<%= f.label :Twitter_Feed, 'Twitter_Feed'%><br>
<%= f.text_field :twitter_feed %>
</p>
<p>
<%= f.label :avatar, "Image File" %>
<%= f.file_field :avatar %>
</p>
<p>
<%= f.label :Notes, 'Notes' %><br>
<%= f.text_area :notes %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>'`

我的规格是 规格/请求/ leads_spec.rb

`require 'spec_helper'
 describe "POST /lead", type: :feature do
  it 'creates and saves valid lead' do
      visit "/lead/new" 
     fill_in 'Name', :with => "abcdefg"
        fill_in 'linkedln_address', with: 'lmnop@gmail.com'
    fill_in 'twitter_feed', with: 'www.twiitter.com/microsoft'
     fill_in 'notes', with: 'ajkhd akjf \n alskdfh alsjdfh'
     click_button 'create Lead'


    current_path.should ==lead_path
    page.should have_content 'The Lead is Successfully Added'
    within 'h1' do
     page.should have_content "abcdefg"
    end
    page.should have_content "lmnop@gmail.com"
     page.should have_content "www.twiitter.com/microsoft"
      page.should have_content "ajkhd akjf \n alskdfh alsjdfh"
  end
    end

`

1 个答案:

答案 0 :(得分:0)

Capybara区分大小写,您的按钮可能是“创建潜在客户”而不是“创建潜在客户”(还应验证其他字段)