Class: TestLoggerObject

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

Overview

Test logger

Instance Method Summary collapse

Instance Method Details

#setupObject



54
55
56
57
58
59
60
# File 'lib/repla/logger/test/tc_logger.rb', line 54

def setup
  @logger = Repla::Logger.new
  @logger.show
  @test_log_helper = Repla::Test::LogHelper.new(@logger.window_id,
                                                @logger.view_id)
  @window = Repla::Window.new(@logger.window_id)
end

#teardownObject



62
63
64
# File 'lib/repla/logger/test/tc_logger.rb', line 62

def teardown
  @window.close
end

#test_logger_objectObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/repla/logger/test/tc_logger.rb', line 66

def test_logger_object
  # Test Error
  message = 'Testing log error'
  @logger.error(message)
  message = 'Testing log message'
  @logger.info(message)
  message = Repla::Logger::ERROR_PREFIX.rstrip
  @logger.info(message)
  message = Repla::Logger::MESSAGE_PREFIX.rstrip
  @logger.info(message)
  @logger.info('')
  @logger.info("  \t")
  @logger.info('Done')
  result = Repla::Test.test_log(@window)
  assert(result)
  # TODO: Also add the following tests the `Log.replaplugin`

  # Test Whitespace
  # White space to the left should be preserved, whitespace to the right
  # should be removed This test fails because retrieving the `innerText`
  # doesn't preserve whitepace.

  # message = "\t Testing log message"
  # @logger.info(message + "\t ")
  # sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
  # test_message = @test_log_helper.last_log_message
  # 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")
  # result_count = @test_log_helper.number_of_log_messages
  # test_count += 1
  # assert_equal(test_count, result_count)
end

#test_long_inputObject



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/repla/logger/test/tc_logger.rb', line 100

def test_long_input
  message = '
Line 1

Line 2
Line 3
'
  lines = 3
  @logger.info(message)
  result_count = nil
  Repla::Test.block_until do
    result_count = @test_log_helper.number_of_log_messages
    result_count == lines
  end
  assert_equal(result_count, lines)

  (1..lines).each do |i|
    result = @test_log_helper.log_message_at(i - 1)
    test_result = "Line #{i}"
    assert_equal(result,
                 test_result,
                 'The number of log messages should match')
  end
end