Skip to content

Instantly share code, notes, and snippets.

@joekrump
Created June 6, 2024 22:36
Show Gist options
  • Save joekrump/c294e8afd0d9dfb798ed4b8e7d7813e9 to your computer and use it in GitHub Desktop.
Save joekrump/c294e8afd0d9dfb798ed4b8e7d7813e9 to your computer and use it in GitHub Desktop.
RSpec enable cache conditional on meta data
# allow cache to be used in a test that uses the :with_cache metadata
config.around do |example|
if example.metadata[:with_cache]
Rails.cache = ActiveSupport::Cache.lookup_store(:memory_store)
Rails.cache.clear
end
example.run
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment