I am trying to test that the Rails logger receives messages in some of my specs. I am using the Logging gem.
Let\'s say that I have a class like this:
Even I had very similar error:
Failure/Error: expect(Rails.logger).to receive(:info).with("some message")
(#).info("some message")
expected: 1 time with arguments: ("some message")
received: 0 times
The below worked for me,
expect { my_method }.
to output(/error messsage/).to_stdout_from_any_process
Reference: https://relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/output-matcher