Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Functional Test: How to test Admin::PostsController

I have a controller like follows:

namespace :admin do
  resources :posts
end


# app/controllers/admin_posts_controller.rb
module Admin
  class PostsController < ApplicationController
  end
end

The problem is I don't know where Admin::PostsControllerTest goes.

I was expecting something like following works:

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

But if I do that I get the following error when I run rake test:functionals :

RuntimeError: @controller is nil: make sure you set it in your test's setup method.
like image 889
Marcelo Avatar asked Dec 28 '11 18:12

Marcelo


1 Answers

You've got the right location. Try this:

class Admin::PostsControllerTest < ActionController::TestCase
  #put your tests here
end
like image 181
miked Avatar answered Sep 27 '22 23:09

miked