Uninitialized constant while trying to include helper module

旧城冷巷雨未停 提交于 2019-12-11 01:12:32

问题


The module that I am trying to include is located here: test/unit/helpers/test_helpers.rb

Looks like:

module TestHelpers
end

I am trying to include it in: test/unit/app/models/abc.rb

class Abc < ActiveSupport::TestCase
include TestHelpers
end

gives the following error:

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

Any ideas why this might be happening?


回答1:


To include a module into your class, you need to require that file.

require 'test_helpers'

Add this line at the top of your model class.



来源:https://stackoverflow.com/questions/21472979/uninitialized-constant-while-trying-to-include-helper-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!