[rspec-users] Foreign key constraints, fixtures, and rake task

Jay Levitt lists-rspec at shopwatch.org
Sun Aug 26 21:51:27 EDT 2007

I've got a spec that loads a fixture in the "before" block.  This works 
fine running scripts/spec, but when I run rake spec instead, I get:

ActiveRecord::StatementInvalid in 'User in fixture :quentin with an IM 
service but no IM name should be invalid'
Mysql::Error: Cannot delete or update a parent row: a foreign key 
constraint fails (`mediajoint_development/accounts`, CONSTRAINT 
`accounts_opener_id_fk` FOREIGN KEY (`opener_id`) REFERENCES `users` 
(`id`)): DELETE FROM users

I've even manually run the entire "ruby -I" command that rake generates, 
and it works fine.

I can't see that the rake task's doing anything different other than 
db:test:prepare, which I can do manually with no problem.

What's rake doing differently?

Jay Levitt

More information about the rspec-users mailing list