问题
I've got source of Diaspora cloned and I've got a working local pod that seems to run without a hitch. But when I run $ rake spec
some initial tests pass and then all of them start failing. Also, what I found interesting was that they fail at different points each time rake spec
is run.
They all fail with the error:
An error occurred in an after hook
ActiveRecord::StatementInvalid: PG::ConnectionBad: PQsocket() can't get socket descriptor: ROLLBACK
occurred at /home/darshan/.rvm/gems/ruby-2.0.0-p353@diaspora/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:650:in `async_exec'
Postgres' log said:
could not receive data from client: Connection reset by peer
unexpected EOF on client connection
回答1:
I ran into the same problem and found that by using the local unix socket file, rather than accessing the Postgres server via localhost, the problem seems to have gone away.
To achieve this, remove the host: localhost
from your database.yml file, and re-run rake spec
. This defaults back to the local socket file (usually .s.PGSQL.5432 in /tmp or /var/run/postgres, depending on your platform.)
回答2:
I ran into the same problem. I tried reverting to pg
version 0.18.0
instead of 0.18.1
, and that seems to fix it for me.
回答3:
Go to postgres.conf
and change ssl = true
to ssl = false
I found the fix for this issue here and it worked for me.
来源:https://stackoverflow.com/questions/21736107/rake-spec-failing-most-tests-but-rails-s-working-fine-on-diaspora-source