Using the logger in your tests / Usando el logger en tus test
Posted by The Turing Machine Wed, 07 May 2008 10:43:00 GMT
This morning I was working on some tests and i wanted to use the logger inside them. My first surprise, was that when i called logger.debug “SOMETHING”, this raised an exception, because logger is not a defined variable. So my solution was really simple, I modified the test_helper.rb and added the following method:
def logger
RAILS_DEFAULT_LOGGER
end
Now everything works fine, and I get my outputs to the application log.
Para mis amigos hispanoparlantes:
Esta mañana estaba trabajando en algunos test y quería usar el logger para ir viendo la ejecución de los mismos. La solución, en el fichero test_helper.rb creamos el siguiente método:
def logger
RAILS_DEFAULT_LOGGER
end
De esta forma podemos llamar al logger desde nuestros test, de la misma manera que lo hacemos desde cualquier otra parte de la aplicación. Y así tenemos nuestra salida por el log de la aplicación.





