Provides a cache store for recording and matchers for testing cache events in Rails controller tests.
Add this line to your application's Gemfile:
gem 'rspec-rails-caching'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rspec-rails-caching
Set config.action_controller.perform_caching = true in config/environments/test.rb
This gem captures the actual cache events for each request. In a controller example group, use a proc or a lambda around the action for matching:
describe WidgetsController, type: :controller do
it "should cache the show action" do
->{ get :show, id: 123 }.should cache_page('/widgets/123')
end
it "should expire the update action" do
->{ put :update, id: 123 }.should expire_page('/widgets/123')
end
end
cache_page/expire_pagecache_fragment/expire_fragmentcache_action/expire_action
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request