0
컨트롤러에서 업데이트 작업의 실패한 분기를 테스트하려고하는데 테스트에 문제가 있습니다. 이것은 내가 가진 것이며 마지막에는 실패합니다.Rspec을 사용하여 컨트롤러의 업데이트 작업을 테스트하는 데 문제가 있습니다. 무엇을 잘못하고 있습니까?
describe "PUT 'article/:id'" do
.
.
.
describe "with invalid params" do
it "should find the article and return the object" do
Article.stub(:find).with("1").and_return(@article)
end
it "should update the article with new attributes" do
Article.stub(:update_attributes).and_return(false)
end
it "should render the edit form" do
response.should render_template("edit")
end
end
end
왜 마지막 부분이 템플릿 렌더링에 실패했는지에 대한 아이디어가 있습니까?
응답 해 주셔서 감사합니다. 그래서 제가 그것들을 하나로 합치면 더 나아질 것입니다. 이것을 테스트하는 올바른 방법입니까? 'it "은 기사를 찾아서"do " ' Article.stub (: find) .with ("1 ") and_return (@article)' 'Article.stub (: update_attributes) 객체를 반환해야합니다. and_return (false)를' '넣어 : 업데이트 {: ID => "1": 기사 => {: 제목 => 전무}}' 'response.should는 render_template ("편집")' ' 끝 ' –
@luis : 예, 그렇게 할 수 있습니다. –