How to test Rails logger message expectation in Rails


This is a how to test Rails logger message expectation in Rails:

expect(Rails.logger).to receive(:info).with("some message")

Note: In controller and model specs, you have to put this line before the message is logged.

🗽 Special Thanks

logging - RSpec: how to test Rails logger message expectations? - Stack Overflow

🖥 Recommended VPS Service

VULTR provides high performance cloud compute environment for you. Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour). In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!