Use Rails logger in tests October 5, 2007

Posted by Slobodan Kovacevic in : Resources and Links, Ruby & Rails , trackback

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

and just use it in tests like this:

logger.info(’performing test now’)

[via Robby on Rails]

Comments»

no comments yet - be the first?