Rails Page Cache Test Plugin 0.2 reviewDownload
Rails Page Cache Test Plugin adds two assertions to the Test::Units::TestCase class of Ruby on Rails to check the caching and expirin
Rails Page Cache Test Plugin adds two assertions to the Test::Units::TestCase class of Ruby on Rails to check the caching and expiring of pages in integration tests.
Unpack into the vendor/plugin and that should be it.
First create an integration test. Then, to test caching of the "/pages/about" and "/pages/contact" pages, add a method like this:
The assert_cache method will
first make sure that the urls are not cached,
execute a get on each request,
assert that the corresponding cache files have been created.
You can also give a block to the assert_cache method. Instead of executing a get on each url, it will yield the urls. For example:
"/pages/contact") do |url_about, url_contact|
You will also certainly want (and that's really the most interesting part) to check if your cached pages expires when the user is doing some action. For that, here is the assert_expire method:
assert_expire("/news/list", "/news/show/1") do |*urls|
Here the assert_expire method will
check that the urls are cached,
execute the post request,
and assert that the urls are no more cached.
This is great for testing your cache sweepers logic.
What's New in This Release:
This release adds a test for action and fragment caching.
The plugin does not look at the filesystem anymore to see if page are cached or not.
It hijacks the ActionController::Base page caching methods to store which pages are cached and expired, and uses that information for the assertions.
Rails Page Cache Test Plugin 0.2 search tags