通常,我希望我的功能测试不执行动作缓存.轨道似乎是在我身边,默认为config.action_controller.perform_caching = false在environment/test.rb.这导致正常的功能测试没有测试缓存.
那么我如何在Rails 3中测试缓存.
这个线程中提出的解决方案似乎相当hacky或者对Rails 2: 如何在rails中的功能测试中启用页面缓存?
我想做的事情如下:
test "caching of index method" do
with_caching do
get :index
assert_template 'index'
get :index
assert_template ''
end
end
Run Code Online (Sandbox Code Playgroud)
也许还有更好的方法来测试缓存是否被击中?