尝试包含辅助模块时未初始化的常量

Viv*_*vek 2 ruby ruby-on-rails padrino

我想要包含的模块位于:test/unit/helpers/test_helpers.rb

好像:

module TestHelpers
end
Run Code Online (Sandbox Code Playgroud)

我想把它包含在:test/unit/app/models/abc.rb中

class Abc < ActiveSupport::TestCase
include TestHelpers
end
Run Code Online (Sandbox Code Playgroud)

给出以下错误:

执行test/unit/app/models/abc.rb未初始化的常量Abc :: TestHelpers时出错

任何想法为什么会这样?

Kun*_*dit 6

要在您的类中包含模块,您需要该文件.

require 'test_helpers'

在模型类的顶部添加此行.