So I saw this recently in a CI config:
- name: Run tests
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@localhost:5432
# REDIS_URL: redis://localhost:6379/0
run: bin/rails db:test:prepare test:all
Now, for some reason I can’t remember now, I went down the rabbit hole wether calling db:test:prepare is needed at all.
On the one hand, we have the Rails Guides on testing in CI say that the only command we need is rails test because rails itself takes care of making sure the database has an updated schema. Naturally, you need to set it up in a previous step.
On the other hand, although I found evidence that rails db:test:prepare had been deprecated, it doesn’t seem to be the case since the task is still there and I get no warnings for using it in CI.
So I wanted to know from the community: any reason to or not to use this task? Is it deprecated? Or is it, as of now, considered just as fine a way to make sure your test db is there in CI as setting it up separately?