Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug "database does not exist" error in test suite?

I recently set up a Rails dev environment on a new machine. I'm now trying to run an app's test suite, but keep getting database errors.

Failure/Error: user = FactoryGirl.create(:user)
PG::ConnectionBad:
FATAL:  database "test-db" does not exist

My database.yml file is set up correctly. I've run psql -l and test-db does in fact exist, and this is confirmed by running rake db:create where I get an 'already exists' message.

I've run rake db:migrate and rake:test:prepare, but the error still remains.

My test set up is as follows

group :test do
  gem 'rspec-rails'
  gem 'factory_girl_rails'
  gem 'capybara'
  gem 'guard-rspec'
  gem 'spork-rails'
  gem 'guard-spork'
end 

I'm having no trouble with the development database.

Why am I getting a db does not exist error, and what can I do to debug this?

like image 879
Andy Harvey Avatar asked Dec 12 '22 09:12

Andy Harvey


1 Answers

Try running this first:

rake db:create
like image 143
RageCore Avatar answered Dec 30 '22 07:12

RageCore