0
我有这个模块在我的lib文件夹中使用模块:在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
如何在测试中包含模块异常?