Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress/disable "cache miss" messages when running rspec tests in rails 3.1

I'm starting to see the following output when running request rspec specs:

cache: [GET /login] miss
cache: [GET /javascripts/jquery.min.js?1317513028] miss

Normaly I would get green dots for passing tests and red Fs with some info for error messages.

Is there a way to disable the cache miss messages from the output?

like image 943
deb Avatar asked Oct 04 '11 17:10

deb


3 Answers

I think this has nothing to do with rspec and that rspec is just printing out what is in the rails log. I think this post by Brian Weaver on the Phusion Passenger discussion group might answer your question:

Do you have rack-cache installed? I spent a good day+ tracing through Passenger/Rails/Rack and lots of other gems to find out why lines similar to that one was appearing. Add the following to your production.rb or development.rb file to get rid of the 'cache: ....' line

config.action_dispatch.rack_cache = {:metastore => "rails:/", :entitystore => "rails:/", :verbose => false}

I pulled that line from within the "middleware" configuration of Rails an just changed the 'verbose' from true to false.

In your case, I guess you want to add it your your test environment file.

like image 111
ryantm Avatar answered Nov 15 '22 18:11

ryantm


In addition to @RyanTM you also need to turn caching on for the test environment so that DragonFly does not configure its own Rack::Cache (with :verbose => true) but instead uses the one setup by Rails.

# set Rack::Cache verbose to false to prevent logging to rspec output         
config.action_controller.perform_caching = true                               
config.action_dispatch.rack_cache = {:metastore => "rails:/", :entitystore => "rails:/", :verbose => false}
like image 25
Kris Avatar answered Nov 15 '22 18:11

Kris


I couldn't get either of the above workarounds to work for me, but adding this to my 'config/initializers/dragonfly.rb' worked:

if Rails.env.test?
  Rails.application.middleware.delete Rack::Cache
  Rails.application.middleware.insert 0, Rack::Cache, {
    :verbose     => false,
    :metastore   => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
    :entitystore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body")
  }
end
like image 34
scottatron Avatar answered Nov 15 '22 18:11

scottatron