dimanche 10 janvier 2021

Ruby on Rails - Understanding Database Dependencies in Test

I've got some model code that calls to the database with a simple find():

@thing = Thing.find(id)

I have data seeded in the database for the test environment. If I open the console in test (rails c -e test), I can run Thing.find(1) and get a result fine, however when I run a test that calls the method shown above, it reports that it cannot find a record with the id of 1.

I assume I am misunderstanding the relationship between test seed data and the tests being run against that database. Why do I see seed sin the test DB but the test doesn't?

Aucun commentaire:

Enregistrer un commentaire