We cache id/path mapping using Rails.cache in a Rails 3.2 app. On some machines it works OK, but on the others values are wrong. The cause is hard to track so I have some questions about the Rails.cache itself. Is it purged between tests? Is it possible that values cached in development mode is used in test mode? If it’s not purged, how could I do it before running specs?
My cache store is configuration is:
#in: config/environments/development.rb
config.cache_store = :memory_store, {:size => 64.megabytes}
#in: config/environments/production.rb
# config.cache_store = :mem_cache_store
Add:
to have the cache cleared before each spec file is run.
Add:
to have the cache cleared before each spec.
You can put this inside
spec/spec_helper.rbwithin theRSpec.configureblock to have it applied globally (recommended over scattering it per spec file or case).RSpec by default does not clear that cache automatically.