Hi, i have some action in my rails application
def show
@issue = Issue.find(params[:id], :include => [:answers, :comments])
@answers = @issue.answers
@comments = @issue.comments
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @issue }
end
end
and rspec test
def mock_issue(stubs={})
@mock_issue ||= mock_model(Issue, stubs)
end
describe "GET show" do
it "assigns the requested issue as @issue" do
@issue = mock_issue
@answers = mock("answers")
@comments = mock("comments")
Issue.stub(:find).with("37").and_return(@issue)
@issue.stub(:answers).and_return([@answers])
@issue.stub(:comments).and_return([@comments])
get :show, :id => "37"
assigns[:issue].should equal(@issue)
end
end
on attempt to run following test i see error
NoMethodError in 'IssuesController GET show assigns the requested issue as @issue'
undefined method `find' for #<Class:0x105dc4a50>
but without :include => [:answers, :comments] it works fine. Could you tell me please - is there any way to stub :include?