Watch for persistent caches between test runs

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the testing category.

Last Updated: 2024-03-02

I had failures on circle CI regarding "live web connections" (I disallow them in my test suite) but not locally.

The issue was that I was caching the test runs against a geocoding database in my local file-system (i.e. when testing locally but no on CI) and this state persisted between runs. I should have called Rails.cache.clear before each run of the suite (or, better yet, force an in-memory cache) that simply got deleted between each test.

This surprised me because I didn't expect the geocoding system to save its own cache... there are so many pockets of state to think about.