0
Я пытался добавить assigns
к моему update
действия спецификации контроллераПочему я не могу использовать should_receive и присваивает в спецификации одного контроллера?
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")
спецификации пасс. Зачем?
Но после этого OP вызывает 'put: update', не должен ли это изменять содержимое (при условии, что обновление выполнено правильно)? – fmendez
no: 'should_receive' проглатывает метод, он не выполняется – apneadiving