Class: TestUnintializedLogger

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/repla/logger/test/tc_logger.rb

Overview

Test unitialized logger

Instance Method Summary collapse

Instance Method Details

#setupObject



21
22
23
# File 'lib/repla/logger/test/tc_logger.rb', line 21

def setup
  @logger = Repla::Logger.new
end

#teardownObject



25
26
27
28
# File 'lib/repla/logger/test/tc_logger.rb', line 25

def teardown
  window = Repla::Window.new(@logger.window_id)
  window.close
end

#test_uninitialized_loggerObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/repla/logger/test/tc_logger.rb', line 30

def test_uninitialized_logger
  # Test Message
  message = 'Testing log message'
  @logger.info(message)
  # Make sure the log messages appear before accessing the logger's `view_id`
  # and `window_id` because those run the logger. This test should test
  # logging a message and running the logger itself simultaneously. This is
  # why the `LogHelper` is intialized after logging the message.
  test_log_helper = Repla::Test::LogHelper.new(@logger.window_id,
                                               @logger.view_id)
  test_message = nil
  Repla::Test.block_until do
    test_message = test_log_helper.last_log_message
    test_message == message
  end

  assert_equal(message, test_message, 'The messages should match')
  test_class = test_log_helper.last_log_class
  assert_equal('message', test_class, 'The classes should match')
end