2011-10-20 3 views
0

せずにアクセスすることができますショーのページに失敗したRSpecのエラーメッセージです:RSpecのは、ここでエラー

5) CustomersController GET customer page 'show' should be successful 
    Failure/Error: get 'show' , :id => customer.id 
    ActionView::Template::Error: 
     undefined method `name' for nil:NilClass 
    # ./app/views/customers/show.html.erb:43:in `_app_views_customers_show_html_erb___16283441_33497004' 
    # ./spec/controllers/customers_controller_spec.rb:41:in `block (3 levels) in <top (required)>' 

名は、顧客モデル内の1つの列です。顧客のコントローラの仕様コードによって引き起こされる上記

エラー:

it "'show' should be successful" do 
    customer = Factory(:customer) 
    get 'show' , :id => customer.id 
    response.should be_success 
end 

顧客コントローラの「ショー」は次のとおりです。エラーに関する

def show 
    @customer = Customer.find(params[:id]) 
    end 

任意の考え?ありがとう。

答えて

0

エラー(​​が)あなたのショービューから来ている、ライン43

 # ./app/views/customers/show.html.erb:43:in 

somethingnilあるときにsomething.nameを呼び出しているためです。

+0

問題を指摘しました。ありがとう。 – user938363