repla 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: addea698961d0d433594235b23367754bb856791
4
- data.tar.gz: cc9b8dec45d41a68dc98e3399b0426a87c662897
3
+ metadata.gz: 9bc5ea00c4045bb8df6ebcbeefbe1a54905be15c
4
+ data.tar.gz: 9a4875dbab09f1b149051eec2454a1d9ee73ec20
5
5
  SHA512:
6
- metadata.gz: a309d37ca6e26474f40abaac84be6fd3ebd566d527c9d2fe8fb145e76fa2430c7c75c6c7ea8644fd5c5762b9e46848a1e04eabffd6b67d9ee96ea3c6befccc3e
7
- data.tar.gz: 457a79f04227251a93fa0d0e8411eacc990dbdd0eea41904b639364b06f6069b20cd7aa59d13bbd9dc4d5c61db32c45ce28975553ac516900fe9d028c185f751
6
+ metadata.gz: f905eed133394f281173023f31ad3a3819d5193a52b7d989e15e4dfe9133128daacc85c6b184094508326a4fdc72fe31e453ea008150de16358522558ca60200
7
+ data.tar.gz: 58834673b618dffd99d320dfa280819e164393d2cea849b24cd4778712eee6a8585f0bea372d8e7bbf52b6834e8c14833e8ce8eba35bea7aacfd5a3167f3e08d
@@ -0,0 +1,37 @@
1
+ require_relative 'test_setup'
2
+
3
+ module Repla
4
+ module Test
5
+ # Log helper
6
+ class LogHelper
7
+ TEST_CLASS_JAVASCRIPT = 'document.body.lastChild.classList[0]'.freeze
8
+ TEST_MESSAGE_JAVASCRIPT = 'document.body.lastChild.innerText'.freeze
9
+ TEST_MESSAGE_COUNT_JAVASCRIPT = 'document.body.children.length'.freeze
10
+
11
+ TEST_JAVASCRIPT_DIRECTORY = File.join(File.dirname(__FILE__), '..', 'js')
12
+ TEST_JAVASCRIPT_FILE = File.join(TEST_JAVASCRIPT_DIRECTORY,
13
+ 'test_view_helper.js')
14
+ def initialize(window_id, view_id)
15
+ @view = Repla::View.new(window_id, view_id)
16
+ javascript = File.read(TEST_JAVASCRIPT_FILE)
17
+ @view.do_javascript(javascript)
18
+ end
19
+
20
+ def log_message_at_index(index)
21
+ @view.do_javascript_function('innerTextOfBodyChildAtIndex', [index])
22
+ end
23
+
24
+ def number_of_log_messages
25
+ @view.do_javascript(TEST_MESSAGE_COUNT_JAVASCRIPT)
26
+ end
27
+
28
+ def last_log_message
29
+ @view.do_javascript(TEST_MESSAGE_JAVASCRIPT)
30
+ end
31
+
32
+ def last_log_class
33
+ @view.do_javascript(TEST_CLASS_JAVASCRIPT)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,11 +1,4 @@
1
1
  require_relative '../../../test'
2
- require Repla::Test::HELPER_FILE
3
2
  require Repla::Test::REPLA_FILE
4
-
5
- TEST_CLASS_JAVASCRIPT = 'document.body.lastChild.classList[0]'.freeze
6
- TEST_MESSAGE_JAVASCRIPT = 'document.body.lastChild.innerText'.freeze
7
- TEST_MESSAGE_COUNT_JAVASCRIPT = 'document.body.children.length'.freeze
8
-
9
- TEST_JAVASCRIPT_DIRECTORY = File.join(File.dirname(__FILE__), '..', 'js')
10
- TEST_JAVASCRIPT_FILE = File.join(TEST_JAVASCRIPT_DIRECTORY,
11
- 'test_view_helper.js')
3
+ require Repla::Test::HELPER_FILE
4
+ require Repla::Test::LOG_HELPER_FILE
@@ -3,8 +3,6 @@
3
3
  require 'minitest/autorun'
4
4
 
5
5
  require_relative 'lib/test_setup'
6
-
7
- require_relative 'lib/test_log_helper'
8
6
  require_relative '../../logger'
9
7
 
10
8
  # Test constants
@@ -38,11 +36,11 @@ class TestUnintializedLogger < Minitest::Test
38
36
  # `window_id` because those run the logger. This test should test logging a
39
37
  # message and running the logger itself simultaneously. This is why the
40
38
  # `LogHelper` is intialized after logging the message.
41
- test_view_helper = LogHelper.new(@logger.window_id, @logger.view_id)
42
-
43
- test_message = test_view_helper.last_log_message
39
+ test_log_helper = Repla::Test::LogHelper.new(@logger.window_id,
40
+ @logger.view_id)
41
+ test_message = test_log_helper.last_log_message
44
42
  assert_equal(message, test_message, 'The messages should match')
45
- test_class = test_view_helper.last_log_class
43
+ test_class = test_log_helper.last_log_class
46
44
  assert_equal('message', test_class, 'The classes should match')
47
45
  end
48
46
  end
@@ -52,7 +50,8 @@ class TestLogger < Minitest::Test
52
50
  def setup
53
51
  @logger = Repla::Logger.new
54
52
  @logger.show
55
- @test_view_helper = LogHelper.new(@logger.window_id, @logger.view_id)
53
+ @test_log_helper = Repla::Test::LogHelper.new(@logger.window_id,
54
+ @logger.view_id)
56
55
  end
57
56
 
58
57
  def teardown
@@ -67,11 +66,11 @@ class TestLogger < Minitest::Test
67
66
  message = 'Testing log error'
68
67
  @logger.error(message)
69
68
  sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
70
- test_message = @test_view_helper.last_log_message
69
+ test_message = @test_log_helper.last_log_message
71
70
  assert_equal(message, test_message)
72
- test_class = @test_view_helper.last_log_class
71
+ test_class = @test_log_helper.last_log_class
73
72
  assert_equal('error', test_class)
74
- result_count = @test_view_helper.number_of_log_messages
73
+ result_count = @test_log_helper.number_of_log_messages
75
74
  test_count += 1
76
75
  assert_equal(test_count, result_count)
77
76
 
@@ -79,11 +78,11 @@ class TestLogger < Minitest::Test
79
78
  message = 'Testing log message'
80
79
  @logger.info(message)
81
80
  sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
82
- test_message = @test_view_helper.last_log_message
81
+ test_message = @test_log_helper.last_log_message
83
82
  assert_equal(message, test_message)
84
- test_class = @test_view_helper.last_log_class
83
+ test_class = @test_log_helper.last_log_class
85
84
  assert_equal('message', test_class)
86
- result_count = @test_view_helper.number_of_log_messages
85
+ result_count = @test_log_helper.number_of_log_messages
87
86
  test_count += 1
88
87
  assert_equal(test_count, result_count)
89
88
 
@@ -92,11 +91,11 @@ class TestLogger < Minitest::Test
92
91
  message = Repla::Logger::ERROR_PREFIX.rstrip
93
92
  @logger.info(message)
94
93
  sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
95
- test_message = @test_view_helper.last_log_message
94
+ test_message = @test_log_helper.last_log_message
96
95
  assert_equal(message, test_message)
97
- test_class = @test_view_helper.last_log_class
96
+ test_class = @test_log_helper.last_log_class
98
97
  assert_equal('message', test_class)
99
- result_count = @test_view_helper.number_of_log_messages
98
+ result_count = @test_log_helper.number_of_log_messages
100
99
  test_count += 1
101
100
  assert_equal(test_count, result_count)
102
101
 
@@ -105,28 +104,28 @@ class TestLogger < Minitest::Test
105
104
  message = Repla::Logger::MESSAGE_PREFIX.rstrip
106
105
  @logger.info(message)
107
106
  sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
108
- test_message = @test_view_helper.last_log_message
107
+ test_message = @test_log_helper.last_log_message
109
108
  assert_equal(message, test_message)
110
- test_class = @test_view_helper.last_log_class
109
+ test_class = @test_log_helper.last_log_class
111
110
  assert_equal('message', test_class)
112
- result_count = @test_view_helper.number_of_log_messages
111
+ result_count = @test_log_helper.number_of_log_messages
113
112
  test_count += 1
114
113
  assert_equal(test_count, result_count)
115
114
 
116
115
  # Test Blank Spaces
117
116
  @logger.info(" \t")
118
117
  sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
119
- test_message = @test_view_helper.last_log_message
118
+ test_message = @test_log_helper.last_log_message
120
119
  assert_equal(message, test_message)
121
- test_class = @test_view_helper.last_log_class
120
+ test_class = @test_log_helper.last_log_class
122
121
  assert_equal('message', test_class)
123
122
 
124
123
  # Test Empty String
125
124
  @logger.info('')
126
125
  sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
127
- test_message = @test_view_helper.last_log_message
126
+ test_message = @test_log_helper.last_log_message
128
127
  assert_equal(message, test_message)
129
- test_class = @test_view_helper.last_log_class
128
+ test_class = @test_log_helper.last_log_class
130
129
  assert_equal('message', test_class)
131
130
 
132
131
  # TODO: Also add the following tests the `Log.replabundle`
@@ -139,11 +138,11 @@ class TestLogger < Minitest::Test
139
138
  # message = "\t Testing log message"
140
139
  # @logger.info(message + "\t ")
141
140
  # sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
142
- # test_message = @test_view_helper.last_log_message
141
+ # test_message = @test_log_helper.last_log_message
143
142
  # assert_equal(message, test_message, "The messages should match")
144
- # test_class = @test_view_helper.last_log_class
143
+ # test_class = @test_log_helper.last_log_class
145
144
  # assert_equal("message", test_class, "The classes should match")
146
- # result_count = @test_view_helper.number_of_log_messages
145
+ # result_count = @test_log_helper.number_of_log_messages
147
146
  # test_count += 1
148
147
  # assert_equal(test_count, result_count)
149
148
  end
@@ -157,11 +156,11 @@ Line 3
157
156
  '
158
157
  @logger.info(message)
159
158
  sleep Repla::Test::TEST_PAUSE_TIME * 2 # Pause for output to be processed
160
- result_count = @test_view_helper.number_of_log_messages
159
+ result_count = @test_log_helper.number_of_log_messages
161
160
  assert_equal(result_count, 3, 'The number of log messages should match')
162
161
 
163
162
  (1..3).each do |i|
164
- result = @test_view_helper.log_message_at_index(i - 1)
163
+ result = @test_log_helper.log_message_at_index(i - 1)
165
164
  test_result = "Line #{i}"
166
165
  assert_equal(result,
167
166
  test_result,
@@ -10,6 +10,8 @@ module Repla
10
10
  LIB_DIRECTORY = File.join(TEST_DIRECTORY, 'lib')
11
11
  HELPER_FILE = File.join(LIB_DIRECTORY, 'helper')
12
12
  VIEW_HELPER_FILE = File.join(LIB_DIRECTORY, 'view_helper')
13
+ LOG_HELPER_FILE = File.join(File.dirname(__FILE__),
14
+ 'logger/test/lib/log_helper')
13
15
 
14
16
  # Test Assets
15
17
  def self.html_file(filename)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roben Kleene
@@ -55,7 +55,7 @@ files:
55
55
  - lib/repla/logger.rb
56
56
  - lib/repla/logger/test/Rakefile
57
57
  - lib/repla/logger/test/js/test_view_helper.js
58
- - lib/repla/logger/test/lib/test_log_helper.rb
58
+ - lib/repla/logger/test/lib/log_helper.rb
59
59
  - lib/repla/logger/test/lib/test_setup.rb
60
60
  - lib/repla/logger/test/run_tests.sh
61
61
  - lib/repla/logger/test/tc_logger.rb
@@ -1,26 +0,0 @@
1
- require_relative 'test_setup'
2
-
3
- # Helper for testing view class
4
- class LogHelper
5
- def initialize(window_id, view_id)
6
- @view = Repla::View.new(window_id, view_id)
7
- javascript = File.read(TEST_JAVASCRIPT_FILE)
8
- @view.do_javascript(javascript)
9
- end
10
-
11
- def log_message_at_index(index)
12
- @view.do_javascript_function('innerTextOfBodyChildAtIndex', [index])
13
- end
14
-
15
- def number_of_log_messages
16
- @view.do_javascript(TEST_MESSAGE_COUNT_JAVASCRIPT)
17
- end
18
-
19
- def last_log_message
20
- @view.do_javascript(TEST_MESSAGE_JAVASCRIPT)
21
- end
22
-
23
- def last_log_class
24
- @view.do_javascript(TEST_CLASS_JAVASCRIPT)
25
- end
26
- end