lizarb 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +7 -4
- data/README.md +23 -64
- data/README_SYSTEMS.md +80 -0
- data/Rakefile +3 -1
- data/app/dev/benches/loops_bench.rb +35 -0
- data/app/dev/commands/calculator_command.rb +69 -0
- data/app/dev/commands/calculator_command_test.rb +58 -0
- data/app/dev/commands/circle_command.rb +70 -0
- data/app/dev/commands/circle_command_test.rb +76 -0
- data/app/dev/commands/narrative_method_command.rb +60 -0
- data/app/dev/commands/narrative_method_command_test.rb +36 -0
- data/app/dev/commands/quadratic_command.rb +66 -0
- data/app/dev/commands/quadratic_command_test.rb +47 -0
- data/app/dev/generators/bench_generator/bench.rb.erb +24 -0
- data/app/dev/generators/bench_generator/bench_test.rb.erb +12 -0
- data/app/dev/generators/bench_generator.rb +2 -51
- data/app/dev/generators/command_generator/command.rb.erb +26 -0
- data/app/dev/generators/command_generator/command_test.rb.erb +12 -0
- data/app/dev/generators/command_generator.rb +2 -35
- data/app/dev/generators/record_generator.rb +46 -0
- data/app/dev/generators/{model_generator_test.rb → record_generator_test.rb} +2 -2
- data/app/net/{models/app_model.rb → records/app_record.rb} +2 -1
- data/app/net/{models/post_model_test.rb → records/app_record_test.rb} +2 -2
- data/app/net/records/post_record.rb +4 -0
- data/app/net/{models/app_model_test.rb → records/post_record_test.rb} +2 -2
- data/app/net/records/user_record.rb +4 -0
- data/app/net/{models/user_model_test.rb → records/user_record_test.rb} +2 -2
- data/app/web/requests/api_request.rb +8 -7
- data/app/web/requests/assets_request.rb +12 -13
- data/app/web/requests/root_request.rb +6 -7
- data/app/web/requests/root_request_test.rb +1 -1
- data/app/web_box.rb +8 -0
- data/app_new/Procfile +1 -1
- data/exe/lrb +3 -0
- data/lib/app.rb +18 -14
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +29 -0
- data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/bench_command.rb +11 -1
- data/lib/dev_system/dev/controllers/command/generate_command.rb +14 -2
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +29 -0
- data/lib/dev_system/dev/controllers/command/{dev_command_test.rb → not_found_command_test.rb} +2 -2
- data/lib/dev_system/dev/controllers/command/{dev_command.rb → terminal_command.rb} +1 -1
- data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/test_command.rb +6 -2
- data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +1 -1
- data/lib/dev_system/dev/controllers/generators/app_generator.rb +30 -5
- data/lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb +18 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb +12 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +9 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb +12 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator.rb +30 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +29 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +14 -0
- data/lib/dev_system/dev/controllers/shell/bin_shell.rb +22 -0
- data/lib/dev_system/dev/controllers/shell/bin_shell_test.rb +87 -0
- data/lib/dev_system/dev/controllers/shell/dir_shell.rb +27 -0
- data/lib/dev_system/dev/controllers/shell/dir_shell_test.rb +73 -0
- data/lib/dev_system/dev/controllers/shell/file_shell.rb +56 -26
- data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +143 -7
- data/lib/dev_system/dev/controllers/shell/text_shell.rb +23 -0
- data/lib/dev_system/dev/controllers/shell/text_shell_test.rb +84 -0
- data/lib/dev_system/dev/controllers/shell.rb +26 -14
- data/lib/dev_system/dev/controllers/shell_test.rb +42 -9
- data/lib/dev_system/dev/panels/command_panel.rb +21 -1
- data/lib/dev_system/dev/panels/log_panel.rb +1 -1
- data/lib/lerb.rb +106 -0
- data/lib/liza/base/controller.rb +2 -0
- data/lib/liza/base/panel.rb +6 -5
- data/lib/liza/base_parts/controller_renderer_part.rb +140 -0
- data/lib/liza/base_parts/controller_renderer_part_test.rb +16 -0
- data/lib/liza/meta/part_extension.rb +6 -1
- data/lib/liza/ruby_test.rb +9 -0
- data/lib/liza/ruby_tests/module_test.rb +21 -0
- data/lib/liza/ruby_tests/string_test.rb +59 -0
- data/lib/liza/test/test.rb +3 -1
- data/lib/liza/test/test_test.rb +108 -15
- data/lib/liza/test_parts/test_assertions_advanced_part.rb +127 -0
- data/lib/liza/test_parts/test_assertions_part.rb +7 -6
- data/lib/liza/test_parts/test_dsl_part.rb +37 -89
- data/lib/liza/test_parts/test_log_part.rb +124 -0
- data/lib/liza/test_parts/test_tree_part.rb +139 -0
- data/lib/liza/unit.rb +2 -0
- data/lib/liza/unit_parts/unit_procedure_part.rb +17 -0
- data/lib/liza/unit_parts/unit_procedure_part_test.rb +65 -0
- data/lib/liza.rb +5 -0
- data/lib/lizarb/ruby/module.rb +17 -0
- data/lib/lizarb/ruby/string.rb +10 -2
- data/lib/lizarb/version.rb +1 -1
- data/lib/lizarb.rb +24 -2
- data/lib/net_system/net/controllers/record.rb +31 -0
- data/lib/net_system/net/controllers/{model_test.rb → record_test.rb} +2 -2
- data/lib/web_system/dev/rack_command.rb +26 -0
- data/lib/web_system/dev/request_command.rb +143 -0
- data/lib/web_system/dev/web_command.rb +3 -34
- data/lib/web_system/web/controllers/rack.rb +8 -0
- data/lib/web_system/web/controllers/rack_test.rb +18 -0
- data/lib/web_system/web/controllers/request/client_error_request.rb +0 -1
- data/lib/web_system/web/controllers/request/not_found_request.rb +0 -1
- data/lib/web_system/web/controllers/request/server_error_request.rb +0 -1
- data/lib/web_system/web/panels/rack_panel.rb +44 -0
- data/lib/web_system/web/panels/rack_panel_test.rb +14 -0
- data/lib/web_system/web/panels/request_panel.rb +51 -32
- data/lib/web_system/web/panels/request_panel_test.rb +28 -9
- data/lib/web_system/web/web_box.rb +12 -0
- data/lizarb.gemspec +2 -2
- metadata +68 -25
- data/app/dev/commands/example_command.rb +0 -57
- data/app/dev/commands/example_command_test.rb +0 -43
- data/app/dev/commands/macro_child_command.rb +0 -32
- data/app/dev/commands/macro_child_command_test.rb +0 -7
- data/app/dev/commands/macro_parent_command.rb +0 -70
- data/app/dev/commands/macro_parent_command_test.rb +0 -7
- data/app/dev/commands/my_command.rb +0 -7
- data/app/dev/commands/my_command_test.rb +0 -7
- data/app/dev/generators/model_generator.rb +0 -46
- data/app/net/models/post_model.rb +0 -4
- data/app/net/models/user_model.rb +0 -4
- data/lib/liza/test_parts/test_context_part.rb +0 -81
- data/lib/net_system/net/controllers/model.rb +0 -31
@@ -0,0 +1,140 @@
|
|
1
|
+
class Liza::ControllerRendererPart < Liza::Part
|
2
|
+
|
3
|
+
class Error < Liza::Error; end
|
4
|
+
class RendererNotFound < Error; end
|
5
|
+
class EmptyRenderStack < Error; end
|
6
|
+
|
7
|
+
EMPTY_RENDER_STACK_MESSAGE = <<~STRING
|
8
|
+
You called render without ERB keys,
|
9
|
+
but the render stack is empty.
|
10
|
+
Did you forget to add ERB keys?
|
11
|
+
STRING
|
12
|
+
|
13
|
+
insertion do
|
14
|
+
# EXTENSION
|
15
|
+
|
16
|
+
def self.renderer
|
17
|
+
Liza::ControllerRendererPart::Extension
|
18
|
+
end
|
19
|
+
|
20
|
+
def renderer
|
21
|
+
@renderer ||= self.class.renderer.new self
|
22
|
+
end
|
23
|
+
|
24
|
+
# CLASS
|
25
|
+
|
26
|
+
def self.controller_ancestors
|
27
|
+
ancestors.take_while { |k| k != Liza::Controller }
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.render_paths
|
31
|
+
@render_paths ||= controller_ancestors.map &:source_location_radical
|
32
|
+
end
|
33
|
+
|
34
|
+
def render_paths
|
35
|
+
self.class.render_paths
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.renderers
|
39
|
+
@renderers ||=
|
40
|
+
LERB.load(source_location_radical)
|
41
|
+
.map { |lerb| [lerb.key, lerb] }
|
42
|
+
.to_h
|
43
|
+
end
|
44
|
+
|
45
|
+
# INSTANCE
|
46
|
+
|
47
|
+
def render *keys
|
48
|
+
if keys.any?
|
49
|
+
_log_render_in keys
|
50
|
+
renderer.render keys, binding, self
|
51
|
+
elsif renderer.stack.any?
|
52
|
+
renderer.stack.pop
|
53
|
+
else
|
54
|
+
raise EmptyRenderStack, EMPTY_RENDER_STACK_MESSAGE, caller
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def _log_render_in keys
|
59
|
+
if renderer.stack.any?
|
60
|
+
log "render ↓ #{keys.join ", "}"
|
61
|
+
else
|
62
|
+
log "render #{"→ " * keys.size}#{keys.join ", "}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
extension do
|
68
|
+
# CLASS
|
69
|
+
|
70
|
+
def self.log(...)
|
71
|
+
solder.log(...)
|
72
|
+
end
|
73
|
+
|
74
|
+
# INSTANCE
|
75
|
+
|
76
|
+
def log(...)
|
77
|
+
self.class.log(...)
|
78
|
+
end
|
79
|
+
|
80
|
+
def erb_lists
|
81
|
+
@erb_lists ||= []
|
82
|
+
end
|
83
|
+
|
84
|
+
def stack
|
85
|
+
@stack ||= []
|
86
|
+
end
|
87
|
+
|
88
|
+
def render keys, the_binding, receiver
|
89
|
+
erbs = find_erbs_for(keys).to_a
|
90
|
+
|
91
|
+
erbs.reverse.each do |key, erb|
|
92
|
+
t = Time.now
|
93
|
+
s = erb.result the_binding, receiver
|
94
|
+
_log_render_out key, s.length, t.diff
|
95
|
+
s = wrap_comment_tags s, erb if App.mode == :code && erb.tags?
|
96
|
+
stack.push s.strip
|
97
|
+
end
|
98
|
+
|
99
|
+
stack.pop
|
100
|
+
end
|
101
|
+
|
102
|
+
def find_erbs_for keys
|
103
|
+
ret = {}
|
104
|
+
keys.each do |key|
|
105
|
+
key = "#{key}.erb"
|
106
|
+
|
107
|
+
controller = solder.class.controller_ancestors.
|
108
|
+
find { |controller| controller.renderers.has_key? key }
|
109
|
+
|
110
|
+
if controller
|
111
|
+
ret[key] = controller.renderers[key]
|
112
|
+
else
|
113
|
+
raise_renderer_not_found key
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
ret
|
118
|
+
end
|
119
|
+
|
120
|
+
def raise_renderer_not_found key
|
121
|
+
render_paths = solder.render_paths.map { |s| " #{s}/#{"#{key}".red}" }.join
|
122
|
+
raise RendererNotFound, %|Failed to find ERB #{key}
|
123
|
+
Failed to find ERB #{"#{key}".red} in #{solder.class}.render_paths
|
124
|
+
#{render_paths}|
|
125
|
+
end
|
126
|
+
|
127
|
+
def _log_render_out key, length, t
|
128
|
+
if stack.any?
|
129
|
+
log "render #{"↑ #{key}".ljust_blanks 20} with #{length.to_s.rjust_blanks 4} characters in #{t}s"
|
130
|
+
else
|
131
|
+
log "render #{"← #{key}".ljust_blanks 20} with #{length.to_s.rjust_blanks 4} characters in #{t}s"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def wrap_comment_tags s, erb
|
136
|
+
"<!-- #{erb.filename.split("/").last}:#{erb.lineno} -->\n#{s}\n<!-- #{erb.filename.split("/").last} -->"
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Liza::ControllerRendererPartTest < Liza::Test
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == Liza::ControllerRendererPart
|
5
|
+
end
|
6
|
+
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.get(:log_level) == :normal
|
9
|
+
assert subject_class.get(:log_color) == :white
|
10
|
+
assert subject_class.log_level == :normal
|
11
|
+
assert subject_class.log_color == :white
|
12
|
+
|
13
|
+
assert subject_class.settings == {}
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module Liza
|
2
2
|
class PartExtension
|
3
3
|
def self.solder
|
4
|
-
@solder ||=
|
4
|
+
@solder ||=
|
5
|
+
if first_namespace == "Liza"
|
6
|
+
Liza.const_get last_namespace[0..-12]
|
7
|
+
else
|
8
|
+
Object.const_get name[0..-12]
|
9
|
+
end
|
5
10
|
end
|
6
11
|
|
7
12
|
def initialize solder
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Liza::ModuleTest < Liza::RubyTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == Module
|
5
|
+
end
|
6
|
+
|
7
|
+
test :source_location do
|
8
|
+
assert Object.source_location == []
|
9
|
+
|
10
|
+
assert Liza::Command.source_location[1] == 2
|
11
|
+
assert AppCommand.source_location[1] == 1
|
12
|
+
end
|
13
|
+
|
14
|
+
test :source_location_radical do
|
15
|
+
assert Object.source_location_radical == nil
|
16
|
+
|
17
|
+
assert Liza::Command.source_location_radical.end_with? "/lib/dev_system/dev/controllers/command"
|
18
|
+
assert AppCommand.source_location_radical.end_with? "/app/dev/commands/app_command"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class Liza::StringTest < Liza::RubyTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == String
|
5
|
+
end
|
6
|
+
|
7
|
+
test :initializers do
|
8
|
+
s0 = String.new
|
9
|
+
s1 = ''
|
10
|
+
s2 = ""
|
11
|
+
|
12
|
+
assert s0.class == String
|
13
|
+
assert s1.class == String
|
14
|
+
assert s2.class == String
|
15
|
+
end
|
16
|
+
|
17
|
+
test :lpartition do
|
18
|
+
todo "write examples"
|
19
|
+
end
|
20
|
+
|
21
|
+
test :rpartition do
|
22
|
+
todo "write examples"
|
23
|
+
end
|
24
|
+
|
25
|
+
test :camelcase do
|
26
|
+
assert "" == "".camelcase
|
27
|
+
assert "A" == "a".camelcase
|
28
|
+
assert "Ab" == "ab".camelcase
|
29
|
+
assert "AbC" == "ab_c".camelcase
|
30
|
+
assert "AbCd" == "ab_cd".camelcase
|
31
|
+
assert "Ab" == "ab_".camelcase
|
32
|
+
assert "Cd" == "_cd".camelcase
|
33
|
+
end
|
34
|
+
|
35
|
+
test :snakecase do
|
36
|
+
assert "" == "".snakecase
|
37
|
+
assert "a" == "A".snakecase
|
38
|
+
assert "ab" == "Ab".snakecase
|
39
|
+
assert "ab_c" == "AbC".snakecase
|
40
|
+
assert "ab_cd" == "AbCd".snakecase
|
41
|
+
end
|
42
|
+
|
43
|
+
test :rjust_blanks do
|
44
|
+
todo "write examples"
|
45
|
+
end
|
46
|
+
|
47
|
+
test :rjust_zeroes do
|
48
|
+
todo "write examples"
|
49
|
+
end
|
50
|
+
|
51
|
+
test :ljust_blanks do
|
52
|
+
todo "write examples"
|
53
|
+
end
|
54
|
+
|
55
|
+
test :ljust_zeroes do
|
56
|
+
todo "write examples"
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/lib/liza/test/test.rb
CHANGED
data/lib/liza/test/test_test.rb
CHANGED
@@ -26,6 +26,74 @@ module Liza
|
|
26
26
|
end
|
27
27
|
end
|
28
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
|
63
|
+
end
|
64
|
+
|
65
|
+
assert_raises RuntimeError do
|
66
|
+
raise RuntimeError
|
67
|
+
end
|
68
|
+
|
69
|
+
refute_raises RuntimeError do
|
70
|
+
raise StandardError
|
71
|
+
end
|
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
|
79
|
+
|
80
|
+
test :test_block do
|
81
|
+
assert_equality @test_block.source_location[1], __LINE__ - 1
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
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
|
92
|
+
|
93
|
+
assert_equality self.class.test_tree.tests.map(&:first).flatten, [:settings, :instance_groups]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
29
97
|
test :instance_groups do
|
30
98
|
assert assertions == 0
|
31
99
|
|
@@ -48,32 +116,57 @@ module Liza
|
|
48
116
|
assert assertions == 4
|
49
117
|
end
|
50
118
|
|
51
|
-
group do
|
119
|
+
group :class_groups do
|
52
120
|
before do
|
53
|
-
@
|
54
|
-
|
121
|
+
@string = "START"
|
122
|
+
assert_equality @string, "START"
|
55
123
|
end
|
56
124
|
|
57
|
-
|
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
|
58
140
|
before do
|
59
|
-
|
60
|
-
@
|
141
|
+
@string.concat "-BEGIN"
|
142
|
+
assert_equality @string, "START-BEGIN"
|
61
143
|
end
|
62
144
|
|
63
|
-
test :
|
64
|
-
|
65
|
-
|
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"
|
66
151
|
end
|
67
|
-
end
|
68
152
|
|
69
|
-
|
70
|
-
|
71
|
-
|
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"
|
159
|
+
end
|
160
|
+
|
161
|
+
after do
|
162
|
+
@string.concat "-END"
|
163
|
+
assert_equality @string, @expectation_inner
|
164
|
+
end
|
72
165
|
end
|
73
166
|
|
74
167
|
after do
|
75
|
-
|
76
|
-
|
168
|
+
@string << "-FINISH"
|
169
|
+
assert_equality @string, @expectation_outer
|
77
170
|
end
|
78
171
|
end
|
79
172
|
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module Liza
|
2
|
+
class TestAssertionsAdvancedPart < Part
|
3
|
+
insertion do
|
4
|
+
|
5
|
+
def assert_equality a, b, msg = nil, kaller: nil
|
6
|
+
ret = a == b
|
7
|
+
|
8
|
+
if ret
|
9
|
+
self.class._assertion_passed
|
10
|
+
@last_result = :passed
|
11
|
+
else
|
12
|
+
self.class._assertion_failed msg
|
13
|
+
@last_result = :failed
|
14
|
+
end
|
15
|
+
|
16
|
+
kaller ||= caller
|
17
|
+
log_test_assertion __method__, kaller if _groups.empty?
|
18
|
+
|
19
|
+
if log_test_assertion_message?
|
20
|
+
msg ||= "#{__method__} #{a}, #{b} (== equality)"
|
21
|
+
log_test_assertion_message ret, msg
|
22
|
+
end
|
23
|
+
|
24
|
+
ret
|
25
|
+
end
|
26
|
+
|
27
|
+
def refute_equality a, b, msg = nil, kaller: nil
|
28
|
+
ret = a == b
|
29
|
+
|
30
|
+
if ret
|
31
|
+
self.class._assertion_failed msg
|
32
|
+
@last_result = :failed
|
33
|
+
else
|
34
|
+
self.class._assertion_passed
|
35
|
+
@last_result = :passed
|
36
|
+
end
|
37
|
+
|
38
|
+
kaller ||= caller
|
39
|
+
log_test_assertion __method__, kaller if _groups.empty?
|
40
|
+
|
41
|
+
if log_test_assertion_message?
|
42
|
+
msg ||= "#{__method__} #{a}, #{b} (== equality)"
|
43
|
+
log_test_assertion_message !ret, msg
|
44
|
+
end
|
45
|
+
|
46
|
+
ret
|
47
|
+
end
|
48
|
+
|
49
|
+
def assert_equality! a, b, msg = nil
|
50
|
+
critical assert_equality a, b, msg, kaller: caller
|
51
|
+
end
|
52
|
+
|
53
|
+
def refute_equality! a, b, msg = nil
|
54
|
+
critical refute_equality a, b, msg, kaller: caller
|
55
|
+
end
|
56
|
+
|
57
|
+
def assert_raises exception_klass, msg = nil, kaller: nil, &block
|
58
|
+
raise ArgumentError, "No block given" unless block_given?
|
59
|
+
|
60
|
+
ret = false
|
61
|
+
begin
|
62
|
+
yield
|
63
|
+
rescue => e
|
64
|
+
ret = exception_klass === e
|
65
|
+
error = e
|
66
|
+
end
|
67
|
+
|
68
|
+
if ret
|
69
|
+
self.class._assertion_passed
|
70
|
+
@last_result = :passed
|
71
|
+
else
|
72
|
+
self.class._assertion_failed msg
|
73
|
+
@last_result = :failed
|
74
|
+
end
|
75
|
+
|
76
|
+
kaller ||= caller
|
77
|
+
log_test_assertion __method__, kaller if _groups.empty?
|
78
|
+
|
79
|
+
if log_test_assertion_message?
|
80
|
+
msg ||= "#{__method__} (#{exception_klass}) #{error.inspect}"
|
81
|
+
log_test_assertion_message ret, msg
|
82
|
+
end
|
83
|
+
|
84
|
+
ret
|
85
|
+
end
|
86
|
+
|
87
|
+
def refute_raises exception_klass, msg = nil, kaller: nil, &block
|
88
|
+
raise ArgumentError, "No block given" unless block_given?
|
89
|
+
|
90
|
+
ret = false
|
91
|
+
begin
|
92
|
+
yield
|
93
|
+
rescue => e
|
94
|
+
ret = !exception_klass === e
|
95
|
+
error = e
|
96
|
+
end
|
97
|
+
|
98
|
+
if ret
|
99
|
+
self.class._assertion_failed msg
|
100
|
+
@last_result = :failed
|
101
|
+
else
|
102
|
+
self.class._assertion_passed
|
103
|
+
@last_result = :passed
|
104
|
+
end
|
105
|
+
|
106
|
+
kaller ||= caller
|
107
|
+
log_test_assertion __method__, kaller if _groups.empty?
|
108
|
+
|
109
|
+
if log_test_assertion_message?
|
110
|
+
msg ||= "#{__method__} (#{exception_klass}) #{error.inspect}"
|
111
|
+
log_test_assertion_message !ret, msg
|
112
|
+
end
|
113
|
+
|
114
|
+
ret
|
115
|
+
end
|
116
|
+
|
117
|
+
def assert_raises! e, msg = nil
|
118
|
+
critical assert_raises e, msg, kaller: caller
|
119
|
+
end
|
120
|
+
|
121
|
+
def refute_raises! e, msg = nil
|
122
|
+
critical refute_raises e, msg, kaller: caller
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -5,10 +5,10 @@ module Liza
|
|
5
5
|
|
6
6
|
def self.totals
|
7
7
|
@totals ||= {
|
8
|
+
errors: [],
|
8
9
|
todos: [],
|
9
|
-
passes: [],
|
10
10
|
fails: [],
|
11
|
-
|
11
|
+
passes: [],
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
@@ -46,7 +46,7 @@ module Liza
|
|
46
46
|
self.class._assertion_todo msg
|
47
47
|
@last_result = :todo
|
48
48
|
|
49
|
-
|
49
|
+
log_test_assertion __method__, caller if _groups.empty?
|
50
50
|
end
|
51
51
|
|
52
52
|
def _groups
|
@@ -61,7 +61,7 @@ module Liza
|
|
61
61
|
_groups.pop
|
62
62
|
|
63
63
|
kaller ||= caller
|
64
|
-
|
64
|
+
log_test_assertion __method__, kaller if _groups.empty?
|
65
65
|
end
|
66
66
|
|
67
67
|
def assert b, msg = "it should have been true", kaller: nil
|
@@ -74,7 +74,7 @@ module Liza
|
|
74
74
|
end
|
75
75
|
|
76
76
|
kaller ||= caller
|
77
|
-
|
77
|
+
log_test_assertion __method__, kaller if _groups.empty?
|
78
78
|
|
79
79
|
b
|
80
80
|
end
|
@@ -89,7 +89,7 @@ module Liza
|
|
89
89
|
end
|
90
90
|
|
91
91
|
kaller ||= caller
|
92
|
-
|
92
|
+
log_test_assertion __method__, kaller if _groups.empty?
|
93
93
|
|
94
94
|
b
|
95
95
|
end
|
@@ -105,6 +105,7 @@ module Liza
|
|
105
105
|
def critical passed
|
106
106
|
throw :critical, :critical if not passed
|
107
107
|
end
|
108
|
+
|
108
109
|
end
|
109
110
|
end
|
110
111
|
end
|