mercredi 31 octobre 2018

Rails test fixtures only available when running specific test file

So I have a test set using Minitest (no rspec) with some fixtures and everything is working fine. It still works fine... but only if I run that test file directly rails test <test_file>.rb.

If I just run rails test, one of the fixtures, not all of them, shows up as nil. Again, I know it's specified correctly with no apparent syntax errors because it passes when I run it directly. My test helper already has fixtures :all. Not sure there's any code to paste, since it works under the right conditions and effects all of the tests.

The only other change that was made at the time this error appeared was moving the test file to a subfolder in tests/controllers/ to tests/controllers/api/ since it is an api test. But it can still access all the other fixtures.

What could possible cause a test to fail when not run directly?

Aucun commentaire:

Enregistrer un commentaire