3

使用 rails 3.2.11,并运行验收规范:

bundle exec rspec ./spec/acceptance/sparkmaps_spec.rb:429

在运行时,标准输出会显示一长串资产,例如:

cache: [GET /users/sign_up] miss
cache: [GET /assets/head.js] miss, store
cache: [GET /assets/application.css] miss, store
cache: [GET /assets/application.js] miss, store
cache: [GET /assets/bt-signin-from-signup.png] miss, store
cache: [GET /assets/sparkon-logo.png] miss, store
cache: [GET /assets/MyriadPro-Regular.otf] miss, store
cache: [POST /users] invalidate, pass
cache: [GET /home] miss
cache: [GET /sparkmaps/new?solo=true&type=student] miss
cache: [GET /assets/sparkmap_images/overview_picture_frame.png] miss, store
cache: [GET /assets/sparkmap_images/checkbox_off.jpg] miss, store
cache: [GET /assets/down_arrow.png] miss, store
cache: [GET /media/W1siZiIsIjEtM2NkZTJmMTItOGU4NC00MjE0LWE4YzktNDU2ZTRlMzZkMTdiLTE1MHgxNTAucG5nIl0sWyJwIiwidGh1bWIiLCIzNHgzNCJdXQ?sha=16599154] miss, store

追踪时太痛苦了。

如何关闭它?

4

2 回答 2

2

您可以在 environment.rb 文件中禁用缓存日志到您的终端:

config.cache_store.silence!

或者您可以使用:

Try calling #silence! on Rails.cache

怎么叫沉默!在 dalli cache_store 上?

希望能帮助到你 !

于 2013-07-26T08:31:33.163 回答
1

你试过这个来自@macournoyer 的rails/issues/2639 评论吗

这是链接中的代码:

把它放在 config/enviroment/test.rb

# Usage: in development.rb
#
#   config.middleware.insert_before Rails::Rack::Logger, DisableAssetsLogger
#
class DisableAssetsLogger
  def initialize(app)
    @app = app
    Rails.application.assets.logger = Logger.new('/dev/null')
  end

  def call(env)
    previous_level = Rails.logger.level
    Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
    @app.call(env)
  ensure
    Rails.logger.level = previous_level
  end
 end

我发现了一篇关于黄瓜和 rack_cache 的帖子,它是rack_cache 和 cucumber

他提到的片段:

require 'rack/cache'
config.middleware.delete ::Rack::Cache
rack_cache_already_inserted = Rails.application.config.action_controller.perform_caching && Rails.application.config.action_dispatch.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")
} unless rack_cache_already_inserted
于 2013-07-23T08:40:17.310 回答