キャッシュが無効な場合とキャッシュが有効な場合のアクション キャッシュをテストする仕様があります。テストの実行順序が合格するかどうかに影響するようです。
it "should not cache the index page when we're not caching" do
ActionController::Base.perform_caching = false
HomeController.caches_action :index
Rails.cache.clear
ActionController::Base.cache_store.exist?(:index_cache_path).should be_false
get :index
ActionController::Base.cache_store.exist?(:index_cache_path).should be_false
end
it "should cache the index page when we're caching" do
ActionController::Base.perform_caching = true
HomeController.caches_action :index
Rails.cache.clear
ActionController::Base.cache_store.exist?(:index_cache_path).should be_false
get :index
ActionController::Base.cache_store.exist?(:index_cache_path).should be_true
end
上記の順序でテストを実行すると、最後の期待値に cache_store が存在しないため、最後のテストが失敗します。キャッシングなしのテストがキャッシングのテストに影響を与えている理由に困惑しています。誰が何が悪いのか知っていますか?