0

libフォルダーにこのモジュールがあります:

module Exceptions
   class NotAuthorized < StandardError
   end
end

次に、次のようなコントローラーのテストがあります。

class Admin::ApplicationControllerTest < ActionController::TestCase

   test "should not be authorized" do
      assert_raise(Exceptions::NotAuthorized) {
        get :index
      }
   end
end

また、この行を自分の環境/test.rbに配置しようとしています

config.autoload_paths +=%W(#{config.root}/lib)

しかし、テストを実行すると、常に次のようになります。

NameError: unitialized constant Admin::ApplicationControllerTest::Exceptions

モジュール Exceptions をテストに含める方法は?

4

1 に答える 1

0

移動中

config.autoload_paths +=%W(#{config.root}/lib)

application.rb に修正します。

于 2013-10-16T10:28:16.883 に答える