So I have recently migrated to postgresql, and have been having issues with my test database creation. Whenever I run a rake task it seems to destroy my ability to access the test database that I have created. For example, if I run the following command
createdb -Ouser -Eutf8 example_test
I can run tests perfectly, however if I run a rake task I will get the following error:
.rvm/gems/ruby-1.9.2-p180@standard/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:991:in `initialize’: FATAL: database “example_test” does not exist (PGError)
If I create a new test database like so:
createdb -Ouser -Eutf8 example2_test
Everything will work again, until I have to run a rake task. Does anyone know what this issue could be?
Fixed the bug, by finding the following blog post about the topic: http://katrinaowen.com/2011/01/05/using-postgresql-with-rails-3-cucumber-and-rspec
In short, this was a bug with creating databases with rspec installed, view the link and run the commands to get it to work on your system.