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

相关问题