我有一个如下控制器:
namespace :admin do resources :posts end # app/controllers/admin_posts_controller.rb module Admin class PostsController < ApplicationController end end
问题是我不知道Admin :: PostsControllerTest去了哪里.
我期待以下作品:
# test/functional/admin/posts_controller_test.rb module Admin class PostsControllerTest < ActionController::TestCase end end
但是如果我这样做,当我运行rake test时会出现以下错误:functionals:
RuntimeError: @controller is nil: make sure you set it in your test's setup method.
解决方法
你有合适的位置.试试这个:
class Admin::PostsControllerTest < ActionController::TestCase #put your tests here end