Parent

ScrubytLoggingTestCase

Public Instance Methods

setup_logger_with_faux_output_stream!(*logger_args) click to toggle source
# File lib/scrubyt/logging.rb, line 113
def setup_logger_with_faux_output_stream!(*logger_args)
  @stream = FauxOutputStream.new
  logger = Scrubyt::Logger.new(*logger_args)
  logger.output_stream = @stream
  Scrubyt.logger = logger
end
test_simple_messages_are_output_correctly() click to toggle source
# File lib/scrubyt/logging.rb, line 125
def test_simple_messages_are_output_correctly
  setup_logger_with_faux_output_stream!

  Scrubyt.log :ACTION, 'i just did something'

  assert_equal 1, @stream.size
  assert_equal '[ACTION] i just did something', @stream.first
end
test_that_loggers_can_be_limited_to_specfied_message_levels() click to toggle source
# File lib/scrubyt/logging.rb, line 143
def test_that_loggers_can_be_limited_to_specfied_message_levels
  setup_logger_with_faux_output_stream! :ERROR

  Scrubyt.log :ACTION, 'i just did something'
  Scrubyt.log :ERROR, 'something bad happened'

  assert_equal 1, @stream.size
  assert_equal '[ERROR] something bad happened', @stream.first
end
test_that_logging_works_with_nil_logger() click to toggle source
# File lib/scrubyt/logging.rb, line 120
def test_that_logging_works_with_nil_logger
  Scrubyt.logger = nil
  assert_nothing_raised { Scrubyt.log(:ERROR, 'message') }
end
test_that_multiline_messages_are_output_correctly() click to toggle source
# File lib/scrubyt/logging.rb, line 134
def test_that_multiline_messages_are_output_correctly
  setup_logger_with_faux_output_stream!

  Scrubyt.log :ERROR, ['something bad happened', 'dear oh dear']

  assert_equal 1, @stream.size
  assert_equal "[ERROR] something bad happened\n        dear oh dear", @stream.first
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.