Class: Repla::Test::LogHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/repla/logger/test/lib/log_helper.rb

Overview

Log helper

Constant Summary collapse

TEST_CLASS_JAVASCRIPT =
'document.body.lastChild.classList[0]'.freeze
TEST_MESSAGE_JAVASCRIPT =
'document.body.lastChild.innerText'.freeze
TEST_MESSAGE_COUNT_JAVASCRIPT =
'document.body.children.length'.freeze
TEST_JAVASCRIPT_DIRECTORY =
File.join(File.dirname(__FILE__), '..', 'js')
TEST_JAVASCRIPT_FILE =
File.join(TEST_JAVASCRIPT_DIRECTORY,
'test_view_helper.js')

Instance Method Summary collapse

Constructor Details

#initialize(window_id, view_id) ⇒ LogHelper



14
15
16
17
18
# File 'lib/repla/logger/test/lib/log_helper.rb', line 14

def initialize(window_id, view_id)
  @view = Repla::View.new(window_id, view_id)
  javascript = File.read(TEST_JAVASCRIPT_FILE)
  @view.do_javascript(javascript)
end

Instance Method Details

#last_log_classObject



32
33
34
# File 'lib/repla/logger/test/lib/log_helper.rb', line 32

def last_log_class
  @view.do_javascript(TEST_CLASS_JAVASCRIPT)
end

#last_log_messageObject



28
29
30
# File 'lib/repla/logger/test/lib/log_helper.rb', line 28

def last_log_message
  @view.do_javascript(TEST_MESSAGE_JAVASCRIPT)
end

#log_message_at_index(index) ⇒ Object



20
21
22
# File 'lib/repla/logger/test/lib/log_helper.rb', line 20

def log_message_at_index(index)
  @view.do_javascript_function('innerTextOfBodyChildAtIndex', [index])
end

#number_of_log_messagesObject



24
25
26
# File 'lib/repla/logger/test/lib/log_helper.rb', line 24

def number_of_log_messages
  @view.do_javascript(TEST_MESSAGE_COUNT_JAVASCRIPT)
end