質問

I just recently update my Rails application to use Authlogic. The authentication works fine in development mode, but the test is no longer working. Each time I launch rspec using bundle exec rake spec, the application throws the following error message (trimmed):

/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'

I know it has something to do with database connection not being established, but I don't know what do I have to do to fix it. It works in development.

By the way, this is my database configuration:

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

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

Can anyone provide me with a guidance on what I have to do to fix the problem? Any help would be appreciated. Thanks!

役に立ちましたか?

解決

Sorry, answering my own question. I should have discovered this earlier. Changing the database config for test environment to this fix the problem:

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

Still, I don't know why Authlogic doesn't work with in memory sqlite3 database.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top