Я хотел бы задать свой вопрос более подробно с базовым примером.
1) I have UsersController
2) I have show method in it
3) But I don't have any templates for this method(either - show.html.erb/show.xml.erb etc)
4) So currently, I just wanted to write a spec for just checking whether my method is returning an object or not
5) it is working, but as it is CRUD related method, it is expecting a Template for it.
6) ActionView::MissingTemplate
Я пытался таким образом
it "should show the user record" do
get :show, :id => 1
User.should_receive(:find).at_least(:once).with(1).and_return(mock_user)
end
class UsersController
def show
# params = {}
# params = {:id => 1}
@user_obj = User.find(params[:id]) # ActiveRecord::Relation
end
end
require 'spec_helper'
describe UsersController do
def mock_user(stubs={})
@mock_user ||= mock_model(User, stubs).as_null_object
end
it "should show the user record" do
expect(assigns(:user_obj)).to eq(mock_user) # How to stop execution here only.
end
end
ActionView:: MissingTemplate: Пропавшие пользователи шаблона / показать с {: handlers => [: erb,: rjs,: builder,: rhtml,: rxml],: format => [: html],: locale => [: en,: en]} в путях просмотра "#"