Rails Functional Test: How to Test Admin :: PostsController

I have a controller like:

namespace :admin do resources :posts end # app/controllers/admin_posts_controller.rb module Admin class PostsController < ApplicationController end end 

The problem is that I do not know where Admin::PostsControllerTest is going.

I was expecting something like the following work:

 # test/functional/admin/posts_controller_test.rb module Admin class PostsControllerTest < ActionController::TestCase end end 

But if I do this, I get the following error when running rake test:functionals :

 RuntimeError: @controller is nil: make sure you set it in your test setup method. 
+6
source share
1 answer

You have a suitable place. Try the following:

 class Admin::PostsControllerTest < ActionController::TestCase #put your tests here end 
+10
source

Source: https://habr.com/ru/post/904619/


All Articles