lizarb 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.tool-versions +1 -0
  4. data/Gemfile +1 -0
  5. data/Gemfile.lock +7 -4
  6. data/README.md +23 -64
  7. data/README_SYSTEMS.md +80 -0
  8. data/Rakefile +3 -1
  9. data/app/dev/benches/loops_bench.rb +35 -0
  10. data/app/dev/commands/calculator_command.rb +69 -0
  11. data/app/dev/commands/calculator_command_test.rb +58 -0
  12. data/app/dev/commands/circle_command.rb +70 -0
  13. data/app/dev/commands/circle_command_test.rb +76 -0
  14. data/app/dev/commands/narrative_method_command.rb +60 -0
  15. data/app/dev/commands/narrative_method_command_test.rb +36 -0
  16. data/app/dev/commands/quadratic_command.rb +66 -0
  17. data/app/dev/commands/quadratic_command_test.rb +47 -0
  18. data/app/dev/generators/bench_generator/bench.rb.erb +24 -0
  19. data/app/dev/generators/bench_generator/bench_test.rb.erb +12 -0
  20. data/app/dev/generators/bench_generator.rb +2 -51
  21. data/app/dev/generators/command_generator/command.rb.erb +26 -0
  22. data/app/dev/generators/command_generator/command_test.rb.erb +12 -0
  23. data/app/dev/generators/command_generator.rb +2 -35
  24. data/app/dev/generators/record_generator.rb +46 -0
  25. data/app/dev/generators/{model_generator_test.rb → record_generator_test.rb} +2 -2
  26. data/app/dev_box.rb +24 -4
  27. data/app/happy_box.rb +1 -1
  28. data/app/net/databases/sqlite_db_test.rb +5 -5
  29. data/app/net/{models/app_model.rb → records/app_record.rb} +2 -1
  30. data/app/net/records/app_record_test.rb +8 -0
  31. data/app/net/records/post_record.rb +4 -0
  32. data/app/net/records/post_record_test.rb +8 -0
  33. data/app/net/records/user_record.rb +4 -0
  34. data/app/net/records/user_record_test.rb +8 -0
  35. data/app/net_box.rb +7 -7
  36. data/app/web/requests/api_request.rb +8 -7
  37. data/app/web/requests/assets_request.rb +12 -13
  38. data/app/web/requests/root_request.rb +6 -7
  39. data/app/web/requests/root_request_test.rb +1 -1
  40. data/app/web_box.rb +9 -1
  41. data/exe/lrb +3 -0
  42. data/lib/app.rb +19 -15
  43. data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +27 -0
  44. data/lib/dev_system/dev/controllers/{command/dev_command_test.rb → bench/not_found_bench_test.rb} +3 -5
  45. data/lib/dev_system/dev/controllers/bench.rb +5 -7
  46. data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +37 -39
  47. data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
  48. data/lib/dev_system/dev/controllers/command/bench_command.rb +20 -12
  49. data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
  50. data/lib/dev_system/dev/controllers/command/echo_command.rb +5 -7
  51. data/lib/dev_system/dev/controllers/command/echo_command_test.rb +8 -10
  52. data/lib/dev_system/dev/controllers/command/generate_command.rb +22 -12
  53. data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
  54. data/lib/dev_system/dev/controllers/command/not_found_command.rb +27 -0
  55. data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +12 -0
  56. data/lib/dev_system/dev/controllers/command/terminal_command.rb +22 -0
  57. data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +12 -0
  58. data/lib/dev_system/dev/controllers/command/test_command.rb +64 -49
  59. data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
  60. data/lib/dev_system/dev/controllers/command/version_command.rb +4 -6
  61. data/lib/dev_system/dev/controllers/command/version_command_test.rb +8 -10
  62. data/lib/dev_system/dev/controllers/command.rb +11 -13
  63. data/lib/dev_system/dev/controllers/command_test.rb +8 -10
  64. data/lib/dev_system/dev/controllers/generator.rb +5 -7
  65. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +35 -37
  66. data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
  67. data/lib/dev_system/dev/controllers/generators/app_generator.rb +122 -47
  68. data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +8 -10
  69. data/lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb +18 -0
  70. data/lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb +12 -0
  71. data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +9 -0
  72. data/lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb +12 -0
  73. data/lib/dev_system/dev/controllers/generators/generator_generator.rb +30 -0
  74. data/lib/dev_system/dev/controllers/generators/generator_generator_test.rb +12 -0
  75. data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +27 -0
  76. data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +12 -0
  77. data/lib/dev_system/dev/controllers/shell/bin_shell.rb +22 -0
  78. data/lib/dev_system/dev/controllers/shell/bin_shell_test.rb +87 -0
  79. data/lib/dev_system/dev/controllers/shell/dir_shell.rb +27 -0
  80. data/lib/dev_system/dev/controllers/shell/dir_shell_test.rb +73 -0
  81. data/lib/dev_system/dev/controllers/shell/file_shell.rb +56 -26
  82. data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +143 -7
  83. data/lib/dev_system/dev/controllers/shell/text_shell.rb +23 -0
  84. data/lib/dev_system/dev/controllers/shell/text_shell_test.rb +84 -0
  85. data/lib/dev_system/dev/controllers/shell.rb +26 -14
  86. data/lib/dev_system/dev/controllers/shell_test.rb +42 -9
  87. data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +11 -13
  88. data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
  89. data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
  90. data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
  91. data/lib/dev_system/dev/controllers/terminal.rb +11 -13
  92. data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
  93. data/lib/dev_system/dev/dev_box.rb +33 -16
  94. data/lib/dev_system/dev/dev_box_test.rb +12 -14
  95. data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
  96. data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
  97. data/lib/dev_system/dev/panels/command_panel.rb +24 -6
  98. data/lib/dev_system/dev/panels/command_panel_test.rb +15 -17
  99. data/lib/dev_system/dev/panels/generator_panel.rb +3 -0
  100. data/lib/dev_system/dev/panels/generator_panel_test.rb +12 -0
  101. data/lib/dev_system/dev/panels/log_panel.rb +9 -6
  102. data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
  103. data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
  104. data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
  105. data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
  106. data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
  107. data/lib/happy_system/happy/controllers/axo.rb +4 -5
  108. data/lib/happy_system/happy/happy_box.rb +6 -9
  109. data/lib/happy_system/happy/happy_box_test.rb +11 -13
  110. data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
  111. data/lib/lerb.rb +106 -0
  112. data/lib/liza/base/box.rb +71 -26
  113. data/lib/liza/base/box_test.rb +7 -9
  114. data/lib/liza/base/controller.rb +19 -19
  115. data/lib/liza/base/controller_test.rb +7 -9
  116. data/lib/liza/base/panel.rb +40 -24
  117. data/lib/liza/base/panel_test.rb +10 -12
  118. data/lib/liza/base_parts/controller_renderer_part.rb +140 -0
  119. data/lib/liza/base_parts/controller_renderer_part_test.rb +16 -0
  120. data/lib/liza/meta/part.rb +12 -14
  121. data/lib/liza/meta/part_extension.rb +14 -11
  122. data/lib/liza/meta/part_test.rb +4 -6
  123. data/lib/liza/meta/system.rb +12 -14
  124. data/lib/liza/meta/system_test.rb +8 -10
  125. data/lib/liza/ruby_test.rb +7 -0
  126. data/lib/liza/ruby_tests/module_test.rb +21 -0
  127. data/lib/liza/ruby_tests/string_test.rb +59 -0
  128. data/lib/liza/test/test.rb +7 -8
  129. data/lib/liza/test/test_test.rb +168 -76
  130. data/lib/liza/test_parts/test_assertions_advanced_part.rb +125 -0
  131. data/lib/liza/test_parts/test_assertions_part.rb +81 -82
  132. data/lib/liza/test_parts/test_dsl_part.rb +44 -98
  133. data/lib/liza/test_parts/test_log_part.rb +122 -0
  134. data/lib/liza/test_parts/test_subject_part.rb +16 -18
  135. data/lib/liza/test_parts/test_tree_part.rb +137 -0
  136. data/lib/liza/unit.rb +108 -102
  137. data/lib/liza/unit_parts/unit_procedure_part.rb +17 -0
  138. data/lib/liza/unit_parts/unit_procedure_part_test.rb +65 -0
  139. data/lib/liza/unit_test.rb +69 -71
  140. data/lib/liza.rb +5 -0
  141. data/lib/lizarb/ruby/module.rb +17 -0
  142. data/lib/lizarb/ruby/string.rb +10 -2
  143. data/lib/lizarb/version.rb +1 -1
  144. data/lib/lizarb.rb +24 -2
  145. data/lib/net_system/dev/net_command.rb +10 -12
  146. data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
  147. data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
  148. data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
  149. data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
  150. data/lib/net_system/net/controllers/client.rb +1 -3
  151. data/lib/net_system/net/controllers/client_test.rb +8 -10
  152. data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
  153. data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
  154. data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
  155. data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
  156. data/lib/net_system/net/controllers/database.rb +21 -23
  157. data/lib/net_system/net/controllers/database_test.rb +8 -10
  158. data/lib/net_system/net/controllers/record.rb +29 -0
  159. data/lib/net_system/net/controllers/record_test.rb +12 -0
  160. data/lib/net_system/net/net_box.rb +11 -16
  161. data/lib/net_system/net/net_box_test.rb +12 -14
  162. data/lib/net_system/net/panels/client_panel.rb +1 -3
  163. data/lib/net_system/net/panels/client_panel_test.rb +11 -13
  164. data/lib/net_system/net/panels/database_panel.rb +6 -8
  165. data/lib/net_system/net/panels/database_panel_test.rb +11 -13
  166. data/lib/web_system/dev/rack_command.rb +35 -0
  167. data/lib/web_system/dev/request_command.rb +143 -0
  168. data/lib/web_system/dev/web_command.rb +6 -39
  169. data/lib/web_system/web/controllers/rack.rb +6 -0
  170. data/lib/web_system/web/controllers/rack_test.rb +16 -0
  171. data/lib/web_system/web/controllers/request/client_error_request.rb +9 -12
  172. data/lib/web_system/web/controllers/request/not_found_request.rb +9 -12
  173. data/lib/web_system/web/controllers/request/server_error_request.rb +10 -13
  174. data/lib/web_system/web/controllers/request.rb +1 -3
  175. data/lib/web_system/web/controllers/request_test.rb +11 -13
  176. data/lib/web_system/web/panels/rack_panel.rb +42 -0
  177. data/lib/web_system/web/panels/rack_panel_test.rb +12 -0
  178. data/lib/web_system/web/panels/request_panel.rb +54 -37
  179. data/lib/web_system/web/panels/request_panel_test.rb +28 -9
  180. data/lib/web_system/web/web_box.rb +16 -8
  181. data/lib/web_system/web/web_box_test.rb +11 -13
  182. data/lizarb.gemspec +2 -2
  183. metadata +76 -28
  184. data/app/dev/commands/example_command.rb +0 -57
  185. data/app/dev/commands/example_command_test.rb +0 -43
  186. data/app/dev/commands/macro_child_command.rb +0 -32
  187. data/app/dev/commands/macro_child_command_test.rb +0 -7
  188. data/app/dev/commands/macro_parent_command.rb +0 -70
  189. data/app/dev/commands/macro_parent_command_test.rb +0 -7
  190. data/app/dev/commands/my_command.rb +0 -7
  191. data/app/dev/commands/my_command_test.rb +0 -7
  192. data/app/dev/generators/model_generator.rb +0 -46
  193. data/app/net/models/app_model_test.rb +0 -8
  194. data/app/net/models/post_model.rb +0 -4
  195. data/app/net/models/post_model_test.rb +0 -8
  196. data/app/net/models/user_model.rb +0 -4
  197. data/app/net/models/user_model_test.rb +0 -8
  198. data/app_new/.gitignore +0 -4
  199. data/app_new/Gemfile +0 -31
  200. data/app_new/Procfile +0 -3
  201. data/lib/dev_system/dev/controllers/command/dev_command.rb +0 -24
  202. data/lib/liza/test_parts/test_context_part.rb +0 -81
  203. data/lib/net_system/net/controllers/model.rb +0 -31
  204. data/lib/net_system/net/controllers/model_test.rb +0 -14
@@ -1,108 +1,200 @@
1
- module Liza
2
- class TestTest < Test
3
1
 
4
- test :settings do
5
- assert subject_class.log_level == :normal
6
- assert subject_class.log_color == :white
2
+ class Liza::TestTest < Liza::Test
3
+
4
+ test :settings do
5
+ assert subject_class.log_level == :normal
6
+ assert subject_class.log_color == :white
7
+ end
8
+
9
+ group :basics do
10
+ test :truths do
11
+ assert true
12
+ assert true
13
+ assert true
7
14
  end
8
15
 
9
- group :basics do
10
- test :truths do
11
- assert true
12
- assert true
13
- assert true
16
+ test :falsehoods do
17
+ refute false
18
+ refute false
19
+ refute false
20
+ end
21
+
22
+ test :assertions do
23
+ assert assertions == 0
24
+ refute assertions != 1
25
+ assert assertions == 2
26
+ end
27
+ end
28
+
29
+ group :assertions do
30
+ test :assert do
31
+ assert 0
32
+ assert 1
33
+ assert :a
34
+ assert "a"
35
+ assert ""
36
+ assert []
37
+ assert [1]
38
+ assert({})
39
+ assert({a: 1})
40
+ assert true
41
+ refute false
42
+ refute nil
43
+ end
44
+
45
+ test :assert_equality do
46
+ assert_equality 0, 0
47
+ assert_equality 1, 1
48
+ assert_equality :a, :a
49
+ assert_equality "a", "a"
50
+ assert_equality "", ""
51
+ assert_equality [], []
52
+ assert_equality [1], [1]
53
+ assert_equality({}, {})
54
+ assert_equality({a: 1}, {a: 1})
55
+ assert_equality true, true
56
+ refute_equality false, true
57
+ refute_equality nil, true
58
+ end
59
+
60
+ test :assert_raises do
61
+ assert_raises StandardError do
62
+ raise RuntimeError
14
63
  end
15
64
 
16
- test :falsehoods do
17
- refute false
18
- refute false
19
- refute false
65
+ assert_raises RuntimeError do
66
+ raise RuntimeError
20
67
  end
21
68
 
22
- test :assertions do
23
- assert assertions == 0
24
- refute assertions != 1
25
- assert assertions == 2
69
+ refute_raises RuntimeError do
70
+ raise StandardError
26
71
  end
27
72
  end
73
+ end
74
+
75
+ group :instance_variables do
76
+ test :instance_variables do
77
+ assert_equality instance_variables, [:@test_words, :@before_stack, :@after_stack, :@test_block]
78
+ end
28
79
 
29
- test :instance_groups do
30
- assert assertions == 0
80
+ test :test_block do
81
+ assert_equality @test_block.source_location[1], __LINE__ - 1
82
+ end
83
+ end
31
84
 
32
- group do
33
- assert true
34
- assert true
35
- assert true
36
- end
85
+ group :tree do
86
+ test :test_tree do
87
+ assert_equality self.class.test_tree.class, Liza::TestTreePart::Extension
88
+ assert_equality self.class.test_tree, self.class.test_tree.parent
89
+
90
+ assert_equality 2, self.class.test_tree.tests.count
91
+ assert_equality 5, self.class.test_tree.children.count
37
92
 
38
- assert assertions == 2
93
+ assert_equality self.class.test_tree.tests.map(&:first).flatten, [:settings, :instance_groups]
94
+ end
95
+ end
96
+
97
+ test :instance_groups do
98
+ assert assertions == 0
39
99
 
100
+ group do
101
+ assert true
102
+ assert true
103
+ assert true
104
+ end
105
+
106
+ assert assertions == 2
107
+
108
+ group do
109
+ assert true
40
110
  group do
41
111
  assert true
42
- group do
43
- assert true
44
- end
45
- assert true
46
112
  end
113
+ assert true
114
+ end
115
+
116
+ assert assertions == 4
117
+ end
47
118
 
48
- assert assertions == 4
119
+ group :class_groups do
120
+ before do
121
+ @string = "START"
122
+ assert_equality @string, "START"
49
123
  end
50
124
 
51
- group do
125
+ test :class_groups, :outer_a do
126
+ @string.concat "-123"
127
+ assert_equality @string, "START-123"
128
+ #
129
+ @expectation_outer = "START-123-FINISH"
130
+ end
131
+
132
+ test :class_groups, :outer_b do
133
+ @string.concat "-321"
134
+ assert_equality @string, "START-321"
135
+ #
136
+ @expectation_outer = "START-321-FINISH"
137
+ end
138
+
139
+ group :class_groups_inner do
52
140
  before do
53
- @a = true
54
- assert @a
141
+ @string.concat "-BEGIN"
142
+ assert_equality @string, "START-BEGIN"
55
143
  end
56
144
 
57
- group do
58
- before do
59
- refute @b
60
- @b = true
61
- end
62
-
63
- test :Test, :inner do
64
- assert @a
65
- assert @b
66
- end
145
+ test :class_groups, :inner_a do
146
+ @string.concat "-aaa"
147
+ assert_equality @string, "START-BEGIN-aaa"
148
+ #
149
+ @expectation_inner = "START-BEGIN-aaa-END"
150
+ @expectation_outer = "START-BEGIN-aaa-END-FINISH"
67
151
  end
68
152
 
69
- test :Test, :outer do
70
- assert @a
71
- refute @b
153
+ test :class_groups, :inner_b do
154
+ @string.concat "-bbb"
155
+ assert_equality @string, "START-BEGIN-bbb"
156
+ #
157
+ @expectation_inner = "START-BEGIN-bbb-END"
158
+ @expectation_outer = "START-BEGIN-bbb-END-FINISH"
72
159
  end
73
160
 
74
161
  after do
75
- assert @a
76
- refute @b
162
+ @string.concat "-END"
163
+ assert_equality @string, @expectation_inner
77
164
  end
78
165
  end
79
166
 
80
- # group :throwables do
81
- # test :throw_within_test do
82
- # assert! true
83
- # assert! false
84
- # raise "it should not have reached this line"
85
- # end
86
-
87
- # group :throw_within_before do
88
- # before do
89
- # assert! false
90
- # end
91
-
92
- # test :that_will_not_run do
93
- # raise "it should not have reached this line"
94
- # end
95
- # end
96
-
97
- # group :throw_within_after do
98
- # test :that_will_not_run do
99
- # assert! false
100
- # end
101
-
102
- # after do
103
- # raise "it should not have reached this line"
104
- # end
105
- # end
106
- # end
167
+ after do
168
+ @string << "-FINISH"
169
+ assert_equality @string, @expectation_outer
170
+ end
107
171
  end
172
+
173
+ # group :throwables do
174
+ # test :throw_within_test do
175
+ # assert! true
176
+ # assert! false
177
+ # raise "it should not have reached this line"
178
+ # end
179
+
180
+ # group :throw_within_before do
181
+ # before do
182
+ # assert! false
183
+ # end
184
+
185
+ # test :that_will_not_run do
186
+ # raise "it should not have reached this line"
187
+ # end
188
+ # end
189
+
190
+ # group :throw_within_after do
191
+ # test :that_will_not_run do
192
+ # assert! false
193
+ # end
194
+
195
+ # after do
196
+ # raise "it should not have reached this line"
197
+ # end
198
+ # end
199
+ # end
108
200
  end
@@ -0,0 +1,125 @@
1
+ class Liza::TestAssertionsAdvancedPart < Liza::Part
2
+ insertion do
3
+
4
+ def assert_equality a, b, msg = nil, kaller: nil
5
+ ret = a == b
6
+
7
+ if ret
8
+ self.class._assertion_passed
9
+ @last_result = :passed
10
+ else
11
+ self.class._assertion_failed msg
12
+ @last_result = :failed
13
+ end
14
+
15
+ kaller ||= caller
16
+ log_test_assertion __method__, kaller if _groups.empty?
17
+
18
+ if log_test_assertion_message?
19
+ msg ||= "#{__method__} #{a}, #{b} (== equality)"
20
+ log_test_assertion_message ret, msg
21
+ end
22
+
23
+ ret
24
+ end
25
+
26
+ def refute_equality a, b, msg = nil, kaller: nil
27
+ ret = a == b
28
+
29
+ if ret
30
+ self.class._assertion_failed msg
31
+ @last_result = :failed
32
+ else
33
+ self.class._assertion_passed
34
+ @last_result = :passed
35
+ end
36
+
37
+ kaller ||= caller
38
+ log_test_assertion __method__, kaller if _groups.empty?
39
+
40
+ if log_test_assertion_message?
41
+ msg ||= "#{__method__} #{a}, #{b} (== equality)"
42
+ log_test_assertion_message !ret, msg
43
+ end
44
+
45
+ ret
46
+ end
47
+
48
+ def assert_equality! a, b, msg = nil
49
+ critical assert_equality a, b, msg, kaller: caller
50
+ end
51
+
52
+ def refute_equality! a, b, msg = nil
53
+ critical refute_equality a, b, msg, kaller: caller
54
+ end
55
+
56
+ def assert_raises exception_klass, msg = nil, kaller: nil, &block
57
+ raise ArgumentError, "No block given" unless block_given?
58
+
59
+ ret = false
60
+ begin
61
+ yield
62
+ rescue => e
63
+ ret = exception_klass === e
64
+ error = e
65
+ end
66
+
67
+ if ret
68
+ self.class._assertion_passed
69
+ @last_result = :passed
70
+ else
71
+ self.class._assertion_failed msg
72
+ @last_result = :failed
73
+ end
74
+
75
+ kaller ||= caller
76
+ log_test_assertion __method__, kaller if _groups.empty?
77
+
78
+ if log_test_assertion_message?
79
+ msg ||= "#{__method__} (#{exception_klass}) #{error.inspect}"
80
+ log_test_assertion_message ret, msg
81
+ end
82
+
83
+ ret
84
+ end
85
+
86
+ def refute_raises exception_klass, msg = nil, kaller: nil, &block
87
+ raise ArgumentError, "No block given" unless block_given?
88
+
89
+ ret = false
90
+ begin
91
+ yield
92
+ rescue => e
93
+ ret = !exception_klass === e
94
+ error = e
95
+ end
96
+
97
+ if ret
98
+ self.class._assertion_failed msg
99
+ @last_result = :failed
100
+ else
101
+ self.class._assertion_passed
102
+ @last_result = :passed
103
+ end
104
+
105
+ kaller ||= caller
106
+ log_test_assertion __method__, kaller if _groups.empty?
107
+
108
+ if log_test_assertion_message?
109
+ msg ||= "#{__method__} (#{exception_klass}) #{error.inspect}"
110
+ log_test_assertion_message !ret, msg
111
+ end
112
+
113
+ ret
114
+ end
115
+
116
+ def assert_raises! e, msg = nil
117
+ critical assert_raises e, msg, kaller: caller
118
+ end
119
+
120
+ def refute_raises! e, msg = nil
121
+ critical refute_raises e, msg, kaller: caller
122
+ end
123
+
124
+ end
125
+ end
@@ -1,110 +1,109 @@
1
- module Liza
2
- class TestAssertionsPart < Part
3
- insertion do
4
- # CLASS
5
-
6
- def self.totals
7
- @totals ||= {
8
- todos: [],
9
- passes: [],
10
- fails: [],
11
- errors: [],
12
- }
13
- end
1
+ class Liza::TestAssertionsPart < Liza::Part
2
+ insertion do
3
+ # CLASS
4
+
5
+ def self.totals
6
+ @totals ||= {
7
+ errors: [],
8
+ todos: [],
9
+ fails: [],
10
+ passes: [],
11
+ }
12
+ end
14
13
 
15
- def self._assertion_todo msg
16
- self.totals[:todos] << msg
17
- end
14
+ def self._assertion_todo msg
15
+ self.totals[:todos] << msg
16
+ end
18
17
 
19
- def self._assertion_passed
20
- self.totals[:passes] << 1
21
- end
18
+ def self._assertion_passed
19
+ self.totals[:passes] << 1
20
+ end
22
21
 
23
- def self._assertion_failed msg
24
- self.totals[:fails] << msg
25
- end
22
+ def self._assertion_failed msg
23
+ self.totals[:fails] << msg
24
+ end
26
25
 
27
- def self._assertion_errored e
28
- self.totals[:errors] << e
29
- end
26
+ def self._assertion_errored e
27
+ self.totals[:errors] << e
28
+ end
30
29
 
31
- # INSTANCE
30
+ # INSTANCE
32
31
 
33
- attr_writer :assertions
32
+ attr_writer :assertions
34
33
 
35
- def assertions
36
- @assertions ||= 0
37
- end
34
+ def assertions
35
+ @assertions ||= 0
36
+ end
38
37
 
39
- def _inc_assertions
40
- self.assertions += 1
41
- end
38
+ def _inc_assertions
39
+ self.assertions += 1
40
+ end
42
41
 
43
- # ASSERTIONS
42
+ # ASSERTIONS
44
43
 
45
- def todo msg
46
- self.class._assertion_todo msg
47
- @last_result = :todo
44
+ def todo msg
45
+ self.class._assertion_todo msg
46
+ @last_result = :todo
48
47
 
49
- _assertion_log __method__, caller if _groups.empty?
50
- end
48
+ log_test_assertion __method__, caller if _groups.empty?
49
+ end
51
50
 
52
- def _groups
53
- @_groups ||= []
54
- end
51
+ def _groups
52
+ @_groups ||= []
53
+ end
54
+
55
+ def group kaller: nil, **_words, &block
56
+ block_given? || raise(ArgumentError, "No block given")
55
57
 
56
- def group kaller: nil, **_words, &block
57
- block_given? || raise(ArgumentError, "No block given")
58
+ _groups << block
59
+ instance_exec &block
60
+ _groups.pop
58
61
 
59
- _groups << block
60
- instance_exec &block
61
- _groups.pop
62
+ kaller ||= caller
63
+ log_test_assertion __method__, kaller if _groups.empty?
64
+ end
62
65
 
63
- kaller ||= caller
64
- _assertion_log __method__, kaller if _groups.empty?
66
+ def assert b, msg = "it should have been true", kaller: nil
67
+ if b
68
+ self.class._assertion_passed
69
+ @last_result = :passed
70
+ else
71
+ self.class._assertion_failed msg
72
+ @last_result = :failed
65
73
  end
66
74
 
67
- def assert b, msg = "it should have been true", kaller: nil
68
- if b
69
- self.class._assertion_passed
70
- @last_result = :passed
71
- else
72
- self.class._assertion_failed msg
73
- @last_result = :failed
74
- end
75
+ kaller ||= caller
76
+ log_test_assertion __method__, kaller if _groups.empty?
75
77
 
76
- kaller ||= caller
77
- _assertion_log __method__, kaller if _groups.empty?
78
+ b
79
+ end
78
80
 
79
- b
81
+ def refute b, msg = "it should have been false", kaller: nil
82
+ if b
83
+ self.class._assertion_failed msg
84
+ @last_result = :failed
85
+ else
86
+ self.class._assertion_passed
87
+ @last_result = :passed
80
88
  end
81
89
 
82
- def refute b, msg = "it should have been false", kaller: nil
83
- if b
84
- self.class._assertion_failed msg
85
- @last_result = :failed
86
- else
87
- self.class._assertion_passed
88
- @last_result = :passed
89
- end
90
+ kaller ||= caller
91
+ log_test_assertion __method__, kaller if _groups.empty?
90
92
 
91
- kaller ||= caller
92
- _assertion_log __method__, kaller if _groups.empty?
93
-
94
- b
95
- end
93
+ b
94
+ end
96
95
 
97
- def assert! b, msg = "it should have been true"
98
- critical assert b, msg, kaller: caller
99
- end
96
+ def assert! b, msg = "it should have been true"
97
+ critical assert b, msg, kaller: caller
98
+ end
100
99
 
101
- def refute! b, msg = "it should have been false"
102
- critical refute b, msg, kaller: caller
103
- end
100
+ def refute! b, msg = "it should have been false"
101
+ critical refute b, msg, kaller: caller
102
+ end
104
103
 
105
- def critical passed
106
- throw :critical, :critical if not passed
107
- end
104
+ def critical passed
105
+ throw :critical, :critical if not passed
108
106
  end
107
+
109
108
  end
110
109
  end