Version 0.2 of the Cache Test plugin
Par Dam le mardi 17 octobre 2006, 18:03 - Lien permanent
As the title implies, I have released a new version of my cache logic test plugin.
Ok, I must admit I have been a bit motivated by that post =P, but anyway, here you are with some new features.
First you are now able to check the actions and fragments caching logic: there are four new methods:
- assert\_cache\_actions - assert\_expire\_actions - assert\_cache\_fragments - assert\_expire\_fragments
They work quite like the corresponding page method, see the documentation for code and examples.
I also changed the way page caching test works. The API is still the same, just the internals have changed. Instead of checking that the page’s cache files are created or removed, I now hijack the ActionController::Base methods so that they records which page are cached or expired. I then use this information in the assertions. No more fiddling with the file system to know if a file is cached or not.
And finally, this release comes with some unit test cases.
The fragment code seems to be working, but I have no application that makes heavy use of fragments so if you find bug in it or have suggestions, don’t hesitate to tell me!
update: I think I have a better idea for the API something along the line of
1 2 3 4 5 6 7 8 9 10 11 12 13 14
def test_caching assert_caching do get "/my/page" assert_page_cached "/my/page" get "/my/action" assert_action_cached :controller => "my", :action => "action" get "/my/fragment" assert_fragment_cached :controller => "my", :action => "fragment", :fragment => "foo" end end
I’ve already implemented it, I’ll wait for some feedback before releasing a new version.