I have an embedded resource for user reading lists (User has_many Reading Lists). I try to make fun of everything in my controller specifications, but I can not restrain it. Here is the code before the #show action:
@reading_lists = mock("Reading lists")
@reading_lists.stub!(:find).with("1").and_return(@reading_list)
@user = mock_model(User, :reading_lists => @reading_lists)
User.stub!(:find).with("1").and_return(@user)
get :show, :user_id => "1", :id => "1"
which is being tested:
def show
@user = User.find(params[:user_id])
@reading_list = @user.reading_lists.find params[:id]
end
This seems like a crazy amount of templates - is there a better way to mock this?
source
share