Load rails fixtures before classes are loaded

644 Views Asked by At

I have classes in my Rails project that are 'registered' with attributes read from the database. However, when I run 'rake test', the classes are loaded before the fixtures are created in SQLLite. As a result, the classes are 'registered' with null values, causing my tests to fail.

Manually testing by running my rails server works perfectly fine, so I don't think there is a problem with my code logic. Also, my fixtures are correct.

How can I change the order of loading the fixtures before the classes and models are instantiated.

1

There are 1 best solutions below

3
mhaseeb On

rake test loads fixtures if you specify fixtures :all. Run rake test --trace to see what happens behind the scenes. I dont think the fixtures are loaded without mentioning fixtures :all Try to rake db:fixtures:load and see if it raises any error.