Class: Repla::Test::LogHelper
- Inherits:
-
Object
- Object
- Repla::Test::LogHelper
- 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(__dir__, '..', 'js')
- TEST_JAVASCRIPT_FILE =
File.join(TEST_JAVASCRIPT_DIRECTORY, 'test_view_helper.js')
Instance Method Summary collapse
-
#initialize(window_id, view_id = nil) ⇒ LogHelper
constructor
A new instance of LogHelper.
- #last_log_class ⇒ Object
- #last_log_message ⇒ Object
- #log_class_at(index) ⇒ Object
- #log_message_at(index) ⇒ Object
- #number_of_log_messages ⇒ Object
Constructor Details
#initialize(window_id, view_id = nil) ⇒ LogHelper
Returns a new instance of LogHelper.
14 15 16 17 18 19 |
# File 'lib/repla/logger/test/lib/log_helper.rb', line 14 def initialize(window_id, view_id = nil) view_id ||= Repla.split_id_in_window_last(window_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_class ⇒ Object
37 38 39 |
# File 'lib/repla/logger/test/lib/log_helper.rb', line 37 def last_log_class @view.do_javascript(TEST_CLASS_JAVASCRIPT) end |
#last_log_message ⇒ Object
33 34 35 |
# File 'lib/repla/logger/test/lib/log_helper.rb', line 33 def @view.do_javascript(TEST_MESSAGE_JAVASCRIPT) end |
#log_class_at(index) ⇒ Object
25 26 27 |
# File 'lib/repla/logger/test/lib/log_helper.rb', line 25 def log_class_at(index) @view.do_javascript_function('classOfBodyChildAtIndex', [index]) end |
#log_message_at(index) ⇒ Object
21 22 23 |
# File 'lib/repla/logger/test/lib/log_helper.rb', line 21 def (index) @view.do_javascript_function('innerTextOfBodyChildAtIndex', [index]) end |
#number_of_log_messages ⇒ Object
29 30 31 |
# File 'lib/repla/logger/test/lib/log_helper.rb', line 29 def @view.do_javascript(TEST_MESSAGE_COUNT_JAVASCRIPT) end |