Last Updated: February 25, 2016
·
493
· mrclmrvn

Cleanup settings cache on tests

I have global settings configured. However, even if I unset the value within an after block, when I run the test again, it's getting a default value. I found out it was getting the value from the cache.

RSpec.configure do |config|
  # ...
  config.after(:suite) do
    # ...
    Setting.thing_scoped.each do |r|
      Rails.cache.delete("settings:#{r.var}")
    end
  end
end