Why is the "rake test" trying to connect to my development database?

I have my config / database.yml like this:

development:
  adapter: postgresql
  database: psql_dev
  username: postgres
  min_messages: WARNING

test:
  adapter: sqlite3
  database: db/test.sqlite3
  min_messages: WARNING

When I run rake test: units, it reports an error:

rake aborted!

Failed to connect to the server: there is no such file or directory. The server runs locally and accepts connections to the Unix domain for the "/tmp/.s.PGSQL.5432" domains?

Why it did not connect to my test database (db / test.sqlite3).

and if I run a test like this rake test RAILS_ENV=test, it works well.

Isn't the RAILS_ENV=testdefault value for the rake test?

I run rails 2.3.5with ruby 1.8.7, and mine is $RAILS_ENVnot defined in my shell.

+5
source share
2

, rake test rake db:test:prepare, development. , ,

+3

: unit rake task? Run:

rake test

? :

rake -T | grep tests
+1

All Articles