如何在RSpec测试中为ActiveRecord打开SQL调试日志记录? [英] How do I turn on SQL debug logging for ActiveRecord in RSpec tests?
本文介绍了如何在RSpec测试中为ActiveRecord打开SQL调试日志记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对我的模型进行了一些RSpec测试,我想像在Rails服务器模式下一样打开SQL ActiveRecord日志记录。
I have some RSpec tests for my models and I would like to turn on SQL ActiveRecord logging just like I see in the Rails server mode. How to do that?
我以
RAILS_ENV=test bundle exec rspec my/test_spec.rb
谢谢
推荐答案
默认情况下,所有数据库查询都已在测试模式下记录。它们将位于 log / test.log
。
By default, all your db queries will be logged already in test mode. They'll be in log/test.log
.
这篇关于如何在RSpec测试中为ActiveRecord打开SQL调试日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文