Replies: 1 comment 2 replies
-
I thought this seemed like an important tip, thanks for mentioning! I went to look at my spec_helper... and saw I already had it there! Git blame says 5 years ago. I wonder where I got the advice initially, perhaps it's already documented somewhere? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When testing with the memory storage, it's easy to forget that without specifically deleting Shrine resources between tests, the store will likely retain every cached and stored file for the duration of the entire test suite, which can grow to a significant memory footprint.
Obviously, one can handle this manually per test or try to remember which classes of tests use Shrine.
But if you prefer to just make sure it "works", this will do the trick for RSpec users (sorry, don't know the equivalent mini-test functionality):
Since the memory store is just as hash, the performance penalty for doing this indiscriminately per test rather than only for the tests that use Shrine is hardly noticeable. But if that is a concern, the line above can be optimized with:
and then one just has to annotate tests / test classes that use Shrine with:
Beta Was this translation helpful? Give feedback.
All reactions