Is there a way to test caching in ur app?

Rails gives use page,action and fragment caching. Is there anyway to
write tests to make sure the cache is being expired properly? I'm
interested to know what other developers out there feel about this.

For example, I was thinkin maybe I could enable caching in test mode,
clear the cache on unittest setup and then after certain actions, load
other pages and test the contents (to make sure that stale fragments
aren't being used, etc).

You could easily do this with Selenium:

With Selenium you can write a simple DSL to click through the app via
one or more browsers with tests in ruby code e.g.

def test_expire_name_div
  login_as a
  open user_profile_url
  assert_equal, get_text('name') = "bob"! #should expire fragment
  assert_equal, get_text('name')

This is a good way to test across browsers, to test ajax, and can
provide easier ways to test some aspects of your app from the
browser(s) to the db. Think of it as programmatic acceptance testing
(write the DSL with the client even). They're also an impressive
client demo (i.e. shiny whilst in operation).


This might be helpful: