2012-03-01 4 views
0

Authlogicが私のユニットテストを台無しにしているようです。私は任意のユニットテストを実行しようとすると、私が手:Authlogicでのユニットテスト3.2

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 

は、誰がこの問題を抱えてますか?私は何をすべきかわからない。

+0

RSpecを使用するエンジンで同じ問題が発生します。 – Kris

答えて

0

私のために私は非名前空間のテーブルにリンクされているところのモデル、例えばQwerty::Userを、名前空間していたので、それはないqwerty_users、すなわちusers、だった、と私は新しいモデルを作るためにRailsの発電機を使用する場合、例えばQwerty::Postそれはまた、作成しましたこれは、その後、それゆえ「あなたは、データベース接続を確立する必要があります」というエラーが間違っていたqwerty_usersのための私のQwerty::Userモデルの外観を作っていた

def self.table_name_prefix 
'qwerty_' 
end 

:含まQwertyモジュールを作成しました。テーブルは存在しませんでした。

おそらく、このエラーを取得する方法はいくつかありますが、いずれもauthlogic自体に直接関係するものはありません。