这是我的相关代码的controller_spec文件部分.....
login_user
context 'Update article with valid attributes' do
it 'Update article'do
article = Article.create!(attributes_for(:article))
put :update,
id:article.to_param,
:article => attributes_for(:article, title: "Title Changed")
article.reload
expect(Article.first.title).to eq("Title Changed")
end
end
end
我收到此错误 失败/错误:期待(Article.first.title).to eq(“标题已更改”)
expected: "Title Changed"
got: "My first post"
(compared using ==)
更新的控制器代码
# ..ArticlesController#update
def update
@article = Article.find(params[:id])
if @article.update(article_params)
redirect_to @article
else
render 'edit'
end
end