[rspec-users] RSpec and PostgreSQL not playing nicely together
Pat Maddox
pergesu at gmail.com
Tue Nov 4 12:49:31 EST 2008
Fernando Perez <lists at ruby-forum.com> writes:
> 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
> end
>
> it "should not be valid" do
> @product.should_not be_valid
> @product.errors.on(:title).should_not be_nil
> # plenty other errors to display...
> end
> end
> end
> --
>
> And here is the error message when I run this spec:
> --
> spec product_spec.rb
> F
>
> 1)
> 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'
> ./product_spec.rb:7:
>
> 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.
Highly doubt it's an RSpec problem. Just looks like you didn't create
the table. Try "rake db:migrate db:test:prepare"
Pat
More information about the rspec-users
mailing list