Use Rails logger in tests
Posted By Slobodan Kovacevic on January 5, 2007
For some debugging in Rails test we wanted to be able to log data via Rails logger. Unfortunately, as it turns out you cannot directly access logger from tests (which is strange). Since we needed to add information to test.log we used this small piece of code (added to test_helper.rb):
def logger
RAILS_DEFAULT_LOGGER
end
RAILS_DEFAULT_LOGGER
end
and just use it in tests like this:
logger.info(’performing test now’)
[via Robby on Rails]
Comments
Olia says:
One Response to “Use Rails logger in tests”
July 31st, 2008 at 10:04 pm
thanks for the tip, just exactly what I needed.