Stub Rails Logger
If you use Rails logger for production, you should do the following to make your test work:
let(:logger_mock) { double("Rails.logger").as_null_object }
it "should ..." do
Rails.stub_chain(:logger, :info).and_return(logger_mock)
# code to be mocked
#
Rails.unstub(:logger)
end
Written by David Paluy
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#