2014-01-31 46 views
2

,我想包括位於此處的模塊: 測試/單位/助理/ test_helpers.rb未初始化的常量,而試圖包括幫助模塊

的樣子:

module TestHelpers 
end 

我想把它列入: 測試/單元/應用/模型/ abc.rb

class Abc < ActiveSupport::TestCase 
include TestHelpers 
end 

提供了以下錯誤:

Error executing test/unit/app/models/abc.rb uninitialized constant Abc::TestHelpers

任何想法,爲什麼會發生這種情況?

+1

幫助程序不包含在ruby包含樹中......用':: require'包含它 –

回答

5

要將模塊包含到您的課堂中,您需要提供該文件。

require 'test_helpers'

將此行添加到模型類的頂部。

相關問題