Created
April 8, 2015 22:31
-
-
Save ybur-yug/5cf8b24356afee13f971 to your computer and use it in GitHub Desktop.
halp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Volt | |
class VoltLogger < Logger | |
... # removing unneeded parts from the module/classes | |
def log_dispatch(class_name, method_name, run_time, args) | |
@current = { | |
args: args, | |
class_name: class_name, | |
method_name: method_name, | |
run_time: run_time | |
} | |
log(Logger::INFO, task_dispatch_message) | |
end | |
... # removing unneeded parts from the module/classes | |
private | |
def task_dispatch_message | |
msg = "task #{class_name}##{method_name} in #{run_time}\n" | |
if args.size > 0 | |
arg_str = parse_args(args) | |
msg += "with args: #{arg_str}\n" | |
end | |
msg | |
end | |
def parse_args(args, filters = ['password']) | |
args.map { |arg| arg.inspect unless filters.include?(arg.to_s) }.compact!.join(', ') | |
end | |
... | |
end | |
end | |
# What I need to test is this: | |
# When the logger called `log_dispatch` and its `args` arr contains 'password' or anything else passed | |
# in the parameter `filters` in parse_args, it removes it. It then logs the remaining stuff to STDOUT | |
# if we were to call log_dispatch(some_class, some_method, some_time, ['password', '1', '1']) | |
# We get: | |
# [INFO] task ClassName#method_name in 50ms | |
# with args: "1", "2" | |
# printed to STDOUT. How da fuq should I test this? I was trying to do recieve :write above_msg -> execute block | |
# but I am not sure what do to. | |
# Source specs here: | |
# https://github.com/voltrb/volt/blob/master/spec/extra_core/logger_spec.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment