Last Updated: February 25, 2016
·
846
· benackles

Database "sample_app_test" does not exist (PG::Error)

Every time Michael Hartl releases a new version of the Rails Tutorial book I sieze on the opportunity to learn the new features of the latest version of Ruby on Rails. The first time, I didn't do any of the optional exercises. The second time, I did one or two. This go around I'm diving headfirst into all the exercises.

The first challenge I ran into was an error while doing the exercise using PostgreSQL as an alternative to SQLite. Normally, when I run into an error I just do a quick “Google the error message” algorithm to figure out what went wrong. However, sometimes you run into a brick wall and this was one of those moments. Since someone offline helped me, I thought I'd share what I learned.

Like most issues with the console, the answer required only a few simple commands.

  1. Define a new PostgreSQL user account $ createuser sample_app
  2. Create a new PostgreSQL database $ createdb sample_app_test -O sample_app
  3. Run bundle exec $ bundle exec rspec spec/requests/static_pages_spec.rb

Bammm!! My tests are failing! Failure never felt so good! ;)