2013-10-10 169 views
2

我有兩個模型在我的導軌應用程序讓我們說公司模型和鉛模型添加線索。我必須在添加新鉛時測試鉛形式。所以我使用集成測試。我有我的窗體上的字段,通過它我更新了DB過,但水豚錯誤元素不found.my代碼folows關於使用水豚&Rspec的欄杆測試...沒有發現水豚元件

新的領導形式

<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: '[email protected]' 
    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 "[email protected]" 
    page.should have_content "www.twiitter.com/microsoft" 
     page.should have_content "ajkhd akjf \n alskdfh alsjdfh" 
    end 
    end 

`

+1

你知道Capybara在尋找哪個元素時遇到困難嗎?什麼是提出的實際錯誤? – JeremyS

回答

0

水豚是大小寫敏感的,你的按鈕可能是「創建線索」而不是「創建銷售線索」(還應該驗證等領域)