2011-12-28 4 views
6

私は、コントローラを持っています。Railsの機能テスト:次のように管理をテストする方法:: PostsControllerの

私は作品を次のように期待していた:

# 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. 

答えて

10

あなたは正しい場所を持っています。試してみてください:

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

これは間違いありません!ありがとう@miked – Marcelo