2012-07-13 44 views
0

我刚刚更新我的Rails应用程序以使用Authlogic。验证在开发模式下正常工作,但测试不再有效。每次我启动rspec的使用bundle exec rake spec,应用程序会引发以下错误消息(修整):使用RSpec 2.10和Rails 3.2测试Authlogic 3.1

/home/user/.rvm/gems/ruby-1.9.3-p194/gems/authlogic-3.1.3/lib/authlogic/acts_as_authentic/base.rb:31:in `acts_as_authentic': You must establish a database connection before using acts_as_authentic (StandardError) 
    from /home/user/Documents/projects/rails_demo/app/models/user.rb:6:in `<class:User>' 
    from /home/user/Documents/projects/rails_demo/app/models/user.rb:2:in `<top (required)>' 
    from /home/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require' 

我知道它是与数据库的连接没有被建立起来,但我不知道我有什么要解决它。它在开发中工作。

顺便说一句,这是我的数据库配置:

test: 
    adapter: sqlite3 
    database: ":memory:" 

production: 
    adapter: sqlite3 
    database: db/production.sqlite3 
    pool: 5 
    timeout: 5000 

谁能为我提供什么我必须做的来解决这个问题一个指导? 任何帮助,将不胜感激。谢谢!

回答

0

对不起,回答我自己的问题。我应该早点发现它。 更改为测试环境中的数据库配置,以问题解决了:

test: 
    adapter: sqlite3 
    database: db/test.sqlite3 
    pool: 5 
    timeout: 5000 

不过,我不知道为什么Authlogic不会在内存中的sqlite3数据库一起工作。