[rspec-users] rspec and set_table_name?

Matt Allen matt at iseekgolf.com
Sun Jan 14 02:40:49 EST 2007

Hi Richard;

I use set_table_name too.

Here is my set-up.

class Product < ActiveRecord::Base
 set_table_name "cart_products"

context "A product with fixtures loaded" do
 set_fixture_class :cart_products => 'Product'
 fixtures :cart_products

Your fixtures should be the same name as you table, so in my case 


Richard Sandilands did write the following on 14/01/2007 1:51 PM:
> Hi there
> I have a Value class in my Rails app; however 'values' is a reserved  
> word in MySQL so in my value.rb file, I've declared set_table_name as  
> 'vals'.
> However, in setting up my specs for this model, I'm hitting errors  
> that seem to be resulting from rspec not seeing the set_table_name  
> declaration in my model file.
> For instance, rspec is throwing a MySQL error as it is attempting to  
> delete records from a table named 'values' which of course does not  
> exist - the table is 'vals' but the model is Value.
> Is this an issue with rspec? If so, is there a way around this? I  
> want to keep using rspec and am prepared to rename my class so as to  
> not need the set_table_name declaration but want to be clear that  
> this is the source of the problem.
> Any clues would be appreciated.
> Richard
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
> .

Matt Allen
1300 663 813

More information about the rspec-users mailing list