Rails 3 functional optionally testing caching
- by Stephan
Generally, I want my functional tests to not perform action caching. Rails seems to be on my side, defaulting to config.action_controller.perform_caching = false in environment/test.rb. This leads to normal functional tests not testing the caching.
So how do I test caching in Rails 3.
The solutions proposed in this thread seem rather hacky or taylored towards Rails 2:
How to enable page caching in a functional test in rails?
I want to do something like:
test "caching of index method" do
with_caching do
get :index
assert_template 'index'
get :index
assert_template ''
end
end
Maybe there is also a better way of testing that the cache was hit?