NameError: undefined local variable or method `logger'
The logger
method isn't available to test cases instance methods.
You have defined a local variable in your class definition but this isn't enough. The logger variable falls out of scope once the class is initialized. You may be looking for a class variable (@@logger
). But a cleaner solution would be wrapping it in a method like this.
class Test::Unit::TestCase def logger RAILS_DEFAULT_LOGGER ||= Logger.new(STDOUT) endend
Notice this code will use the default logger if it is available (which it should be). If this isn't desired, you can make your own just as easily.
def logger @logger ||= Logger.new(STDOUT)end
you should use RAILS_DEFAULT_LOGGER.debug the constant in your test case is_valid_checksum? not the variable logger(class level variable ) which cannot be used in a instance method.
I would suggest to wrap the code in a instance method something like
def logger logger = Logger.new(STDOUT) logger.level = Logger::WARN loggerend
and then use logger