2016-12-07 69 views
1

我正在處理Rails API Tutorial並面臨錯誤。每當我跑我的測試中,我得到RSpec測試失敗,未定義的方法`respond_with'

1) Api::V1::UsersController PUT/PATCH #update when is not created 
    Failure/Error: it { should respond_with 422 } 

    NoMethodError: 
     undefined method `respond_with' for #<RSpec::ExampleGroups::ApiV1UsersController::PUTPATCH 
Update::WhenIsNotCreated:0x007f860e070eb8> 
     Did you mean? respond_to 

我發現,都指向一個非常類似的問題另外兩個職位(thisthis),但他們兩人都沒有解決。有沒有人有解決這個問題?謝謝!

回答

2

如前所述here,試試這個:的

it { expect(response).to have_http_status(422) } 

代替

it { should respond_with 422 } 
+0

謝謝你這麼多! – alpaca

相關問題