I just converted my client’s site to use Rails 4, and then added fragment caching. It’s simply awesome in terms of ease and effectiveness. The migration was relatively painless due to having a very large suite of unit tests before I started.
I’d like to get input from the other members in terms of how much effort they put into adding automated tests when adding fragment caching to views.
Is it worth the client’s money?
Is manual testing good enough?
What’s the most effective technique for testing caching? Maybe Capybara integration tests? Other options?
In terms of the flow, I’d imagine maybe Capybara tests that go like this:
- Turn caching on for the test
- Clear the cache
- Visit the page that will be cached
- (Maybe) confirm that page was added to cache
- (Mabye) revisit page and confirm cache was used
- Take action that breaks the cache, either by direct api access or via Capybara UI interaction
- Revisit page that will have had cache busted and confirm that the page displays the correct, new information