This question is a bit old, but, finding my way here, I thought I would answer it, assuming rspec-mocks v3.
Preliminarily completing the object, then the have_received works well when you make sure that the object receives a specific message, and not just that .
Subtle difference between receive(:...) and have_received(:...)
To get to the original question and assuming that it was rewritten in rspec-mocks v3, my solution would be the following:
allow(Logger).to receive(:write) get '/' expect(Logger).to have_received(:write).with('Log message 1')
Note that it is important to put the statement at the end when it checks the state of the stub when called, and not on completion, as is customary.
source share