Toggle Rails Caching in RSpec Suites
In spec_helper
or another support file required by your spec:
RSpec.configure do |config|
config.around(:each, :caching) do |example|
caching = ActionController::Base.perform_caching
ActionController::Base.perform_caching = example.metadata[:caching]
example.run
ActionController::Base.perform_caching = caching
end
end
In your spec:
ruby
describe "visit the homepage", :caching => true do
# test cached stuff
end
Written by Ross Kaffenberger
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#