So in my app I can disable the cache for all tests, which would be ideal, but apparently there are a number of legacy tests that rely on the cache being functional. Is there a way to enable the Rails cache for a single RSpec test?
Something like:
before(:each) do
@cache_setting = Rails.cache.null_cache
Rails.cache.null_cache = true
end
after(:each) do
Rails.cache.null_cache = @cache_setting
end
it 'does not hit the cache' do
...
end
in
spec_helper.rb
in
xxx_spec.rb
https://www.relishapp.com/rspec/rspec-core/docs/hooks/filters