linkyndy
linkyndy

Reputation: 17920

Rails remove persisted fixtures from tests

I used to have 3 fixtures in my RSpec tests. I have removed them and went with the FactoryGirl approach. The problem is that, when I run my tests, even though I have no trace of fixtures left, they still appear when running the tests.

If I debug the tests, I can see that the fixtures' creation date is old, older than the objects created when running the current test.

I believe fixtures are somewhere cached, how can I clear this cache? Or, if this is not the case, why are the old fixtures there when running the tests?

Upvotes: 1

Views: 1894

Answers (2)

linkyndy
linkyndy

Reputation: 17920

After some deep digging, I found out that some sourced files were setting an env var with the development db, not the test db. Pretty trivial mistake, but so hard to find.

As a conclusion, if others stumble upon weird problems like this one, be sure to check whether you are using the right environment variables/configuration options in your app.

Upvotes: 0

Dan Kohn
Dan Kohn

Reputation: 34337

rake db:setup will reload your test database from your schema.rb, erasing your fixture data.

Upvotes: 1

Related Questions