[rspec-users] RSpec and PostgreSQL not playing nicely together

Fernando Perez lists at ruby-forum.com
Tue Nov 4 11:33:17 EST 2008

Here is a very simple spec:
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Product, "The Product model" do

  describe "When a new blank product object gets created" do
    before(:each) do
      @product = Product.new

    it "should not be valid" do
      @product.should_not be_valid
      @product.errors.on(:title).should_not be_nil
      # plenty other errors to display...

And here is the error message when I run this spec:
spec product_spec.rb

ActiveRecord::StatementInvalid in 'Product The Product model When a new
blank product object gets created should not be valid'
PGError: ERROR:  relation "products" does not exist
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = 'products'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
./product_spec.rb:7:in `new'

Finished in 1.025511 seconds

1 example, 1 failure

I don't understand why RSpec is trying to look for some kind of
relation. In the spec I am simply calling Product.new

This spec worked perfectly with MySQL.
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list