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

Zach Dennis zach.dennis at gmail.com
Tue Nov 4 11:46:12 EST 2008


On Tue, Nov 4, 2008 at 11:33 AM, Fernando Perez <lists at ruby-forum.com> wrote:
> 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.

I am going to go out on a limb and say that I don't think this is an
RSpec problem. Outside of the spec, if you launch script/console in
both development and test environments, when you do Product.new, do
you have any issues?


-- 
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com


More information about the rspec-users mailing list