【问题标题】:uninitialized constant Authlogic::TestCase::ControllerAdapters (NameError)未初始化的常量 Authlogic::TestCase::ControllerAdapters (NameError)
【发布时间】:2012-01-19 12:53:16
【问题描述】:

每次我尝试通过运行“rake”来运行测试时都会收到此错误:

/var/lib/gems/1.8/gems/authlogic-2.1.6/lib/authlogic/test_case/rails_request_adapter.rb:5: 未初始化的常量 Authlogic::TestCase::ControllerAdapters (名称错误)

我在 test_helper.rb 的顶部有这些行:

需要“authlogic/test_case” 包括 Authlogic::TestCase

按照here的建议。

我使用 Rails 3.0.6,并且我在 Gemfile 中有 gem authlogic,正如预期的那样:

宝石“authlogic”

我错过了什么?为什么我无法运行测试?

【问题讨论】:

    标签: ruby-on-rails testing authlogic


    【解决方案1】:

    所以我终于解决了这个问题。问题是您的 test_helper.rb 需要像前面所说的那样需要“authlogic/test_case”。但是,由于某种我不完全理解的原因,我还需要在那个之前有一个 require "authlogic"。

    我遇到了另一个问题,因为我有一个自动生成的 user_sessions 固定装置。该解决方案只是删除夹具,因为 authlogic 不会在数据库中为会话创建表。阅读更多关于这个问题here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-19
      • 2015-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-04
      相关资源
      最近更新 更多