我尝试在控制器中添加assigns
到我的update
操作规范
it "update the content" do
Answer.should_receive(:find).with(answer.id.to_s).and_return(answer)
answer.should_receive(:update_attributes).with("content" => "Changed content")
put :update, id: answer.id, app_id: app.id, answer: {content: "Changed content"}
assigns(:answer).content.should eq('Changed content') # explicitly permitted
response.status.should eq 406
end
但我得到错误:
Failure/Error: assigns(:answer).content.should eq('Changed content') # explicitly permitted
expected: "Changed content"
got: "base content"
(compared using ==)
但是当我评论时:
#answer.should_receive(:update_attributes).with("content" => "Changed content")
规范通过。为什么?