I run my rspec and most of the test were failed. I got the same error for them, which is:
Failure/Error: Unable to find matching line from backtrace
ActiveRecord::StatementInvalid:
PG::ConnectionBad: PQsocket() can't get socket descriptor: BEGIN
I found a question that is similar to my problem, but there is no answer yet and I also tried the solution from this link, but it didn't make any differences for me. I opened my test console and run some simplest queries and it worked.