Skip to content

Instantly share code, notes, and snippets.

@miharekar
Created March 24, 2023 11:09
Show Gist options
  • Save miharekar/62692ec10ae7ab0d5e99de3b487c5d81 to your computer and use it in GitHub Desktop.
Save miharekar/62692ec10ae7ab0d5e99de3b487c5d81 to your computer and use it in GitHub Desktop.
Enable Rails cache for one unit test.md

#rails #minitest #testing

Add to test/test_helper.rb

    def with_cache
      @original_cache_store = Rails.cache
      Rails.cache = ActiveSupport::Cache::MemoryStore.new
      yield
    ensure
      Rails.cache = @original_cache_store
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment