У меня есть некоторые действия в моем приложении рельсов
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
и тест rspec
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
при попытке запустить следующий тест я вижу ошибку
NoMethodError in 'IssuesController GET show assigns the requested issue as @issue'
undefined method `find' for #<Class:0x105dc4a50>
но без : include => [: answers,: comments] работает нормально. Подскажите пожалуйста - есть ли способ заглушки: включить?