How do I turn on SQL debug logging for ActiveRecord in RSpec tests?

被刻印的时光 ゝ 提交于 2019-12-02 14:25:21
idlefingers

By default, all your db queries will be logged already in test mode. They'll be in log/test.log.

You could try setting the ActiveRecord logger to stdout in your test somewhere. If you're using rspec, maybe in the spec helper?

ActiveRecord::Base.logger = Logger.new(STDOUT)

set

config.log_level = :info 

in test environment

if others answers don't work in your case, please check the 'log level' of your test environment.

its default is 'debug', which will output the SQL generated by Rails. if it was set to "info", the SQL will be missing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!