如何解决Rails Minitest 包含到 test_helper - 未初始化的常量 ActiveSupport::TestCase
我想将 test/helpers/auth_request_helpers.rb
中的 helper 添加到 test/test_helper.rb
中,使其在所有测试中都可用。我以为我所要做的就是将这个助手包含在 test_helper
中,如下所示:
module ActiveSupport
class TestCase
include AuthRequestHelpers
# some other things
end
end
但是当我运行 minitest 时出现错误:
uninitialized constant ActiveSupport::TestCase::AuthRequestHelpers (NameError)
我错过了什么吗?我没有使用 RSpec
我尝试在下面添加的帮助程序:
module AuthRequestHelpers
def hmac_code(data,secret_key)
Base64.strict_encode64(OpenSSL::HMAC.digest('sha256',secret_key,data))
end
end
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。