2012-02-08 2 views
7

상속 된 리소스 1.3.0이있는 프로젝트에 Rails 3.1.3을 사용하고 있습니다.Rails 3.1.3 및 상속 된 리소스 테스트가 실패했습니다.

내가 지금 같은 컨트롤러가 있습니다

class PostsController < InheritedResources::Base 
end 

을 그리고 나는 내가 다음과 같은 오류 얻을

describe "PUT update" do 
    describe "with invalid params" do 
     it "re-renders the 'edit' template" do 
     post = Post.create! valid_attributes 
     # Trigger the behavior that occurs when invalid params are submitted 
     Post.any_instance.stub(:save).and_return(false) 
     put :update, {:id => post.to_param, :post => {}}, valid_session 
     response.should render_template("edit") 
     end 
    end 
    end 

다음 RSpec에와 테스트 :

3) PostsController PUT update with invalid params re-renders the 'edit' template 
    Failure/Error: response.should render_template("edit") 
     expecting <"edit"> but rendering with <""> 
    # ./spec/controllers/posts_controller_spec.rb:115:in `block (4 levels) in <top (required)>' 

왜이입니다? 다른 것을 뽑아 내야하나요?

답변

13

그냥이 추가

Post.any_instance.stub(:errors).and_return(['error']) 

직후 :

Post.any_instance.stub(:save).and_return(false) 
관련 문제