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

后端 未结 5 1045
梦谈多话
梦谈多话 2021-01-30 05:16

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?

I start my tests wit

5条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 05:18

    In your test.rb:

    Rails.application.configure do
      ...
      config.logger = ActiveSupport::Logger.new(STDOUT)
    end
    

提交回复
热议问题