On Jul 3, 2011, at 1:08 AM, John Hinnegan wrote: > So, maybe I need to go to the rails list with this, but I hit my error while > testing so I figured I'd ask here first. > > Basically, Rails.cache.fetch is being persisted by default in my rails > project between rspec runs. I've illustrated what I'm observing here: > > https://github.com/softwaregravy/rspec-troubleshoot/commit/c63b4b09fa6e70c2312e0aa2f7ba0ce078322ccc > > Furthermore, if you run that once, and then take out the test that doesn't > raise the error, its still in the cache. > > So, to get at the 'issue' I'm describing specifically. If you first run > 'rspec spec/controllers/application_controller_spec.rb' with the following: > https://github.com/softwaregravy/rspec-troubleshoot/blob/0e22ce887cde602e49dc9bf7fa25406882b038f0/spec/controllers/application_controller_spec.rb > you seed the cache. And then run it again without the happy case: > https://github.com/softwaregravy/rspec-troubleshoot/blob/1e36222e64bfd9c473be06fba0a5fa102d4bf0f6/spec/controllers/application_controller_spec.rb > > You continue to get the failing test because the results of that block are > cached. > > Now, I'm not that familiar with Rails caching. But it appears that there > might be an issue in which Rails is not respecting the perform_caching flag.
Looks like the perform_caching config option only impacts page caching. See http://pivotallabs.com/users/spierson/blog/articles/818-standup-04-30-2009-perform-caching-and-rails-cache-w3c-dtds-and-ie-range-min-max for a brief discussion of options (that's the first hit in a google search for "perform_caching", btw). > If that's not the root cause, then it seems to be that rspec could be doing a > Rails.cache.clear and/or overriding a memory cache to be used during tests. You can definitely do this yourself in a global before hook, but I don't know how people use Rails.cache in the wild and wouldn't want to do anything implicit that might break existing suites. I'd recommend using a global before hook or raising an issue in the rails tracker. HTH, David
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users