【发布时间】:2012-03-01 14:25:07
【问题描述】:
Authlogic 似乎弄乱了我的单元测试。当我尝试运行任何单元测试时,我得到:
authlogic/acts_as_authentic/base.rb:31:in `acts_as_authentic': You must establish a database connection before using acts_as_authentic (StandardError)
我的单元测试是什么并不重要。即使我所有的单元测试文件包含require 'test_helper',我仍然会收到错误消息。当然,这告诉我问题可能出在我的test/test_helper.rb 文件中。
这是我的test/test_helper.rb(基于示例here):
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'authlogic/test_case'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
class ActionController::TestCase
setup :activate_authlogic
end
还有其他人有这个问题吗?我不知道该怎么办。
【问题讨论】:
-
我遇到了同样的问题,但在使用 RSpec 的引擎中。
标签: ruby-on-rails-3 unit-testing authlogic