Skip to content

Instantly share code, notes, and snippets.

@jgn
Created March 6, 2014 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgn/9380671 to your computer and use it in GitHub Desktop.
Save jgn/9380671 to your computer and use it in GitHub Desktop.
require 'logger'
def get_logger
logger = Logger.new(STDOUT)
def logger.info(s)
@log_output ||= ""
@log_output << s << "\n"
end
def logger.log_output
@log_output
end
logger
end
a, b, c, s = examples[0]
expected_logging = <<LOG
augend: 0
addend: 0
carry: 0
sum: 0
LOG
logger = get_logger # setup
half_adder = HalfAdder.new(a, b, logger) # setup
half_adder.compute # exercise
assert_equality("verifying logging",
logger.log_output,
expected_logging) # verify
adder = nil # teardown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment