lizarb 1.0.1 → 1.0.3
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/dev_box.rb +24 -4
- data/app/happy_box.rb +1 -1
- data/app/net/databases/sqlite_db_test.rb +5 -5
- data/app/net/{models/app_model.rb → records/app_record.rb} +2 -1
- data/app/net/records/app_record_test.rb +8 -0
- data/app/net/records/post_record.rb +4 -0
- data/app/net/records/post_record_test.rb +8 -0
- data/app/net/records/user_record.rb +4 -0
- data/app/net/records/user_record_test.rb +8 -0
- data/app/net_box.rb +7 -7
- 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 +9 -1
- data/exe/lrb +3 -0
- data/lib/app.rb +19 -15
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +27 -0
- data/lib/dev_system/dev/controllers/{command/dev_command_test.rb → bench/not_found_bench_test.rb} +3 -5
- data/lib/dev_system/dev/controllers/bench.rb +5 -7
- data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +37 -39
- data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/bench_command.rb +20 -12
- data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/echo_command.rb +5 -7
- data/lib/dev_system/dev/controllers/command/echo_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/generate_command.rb +22 -12
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +27 -0
- data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +12 -0
- data/lib/dev_system/dev/controllers/command/terminal_command.rb +22 -0
- data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +12 -0
- data/lib/dev_system/dev/controllers/command/test_command.rb +64 -49
- data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/version_command.rb +4 -6
- data/lib/dev_system/dev/controllers/command/version_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command.rb +11 -13
- data/lib/dev_system/dev/controllers/command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generator.rb +5 -7
- data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +35 -37
- data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generators/app_generator.rb +122 -47
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +8 -10
- 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 +27 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +12 -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/controllers/terminal/irb_terminal.rb +11 -13
- data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
- data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
- data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
- data/lib/dev_system/dev/controllers/terminal.rb +11 -13
- data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
- data/lib/dev_system/dev/dev_box.rb +33 -16
- data/lib/dev_system/dev/dev_box_test.rb +12 -14
- data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
- data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/command_panel.rb +24 -6
- data/lib/dev_system/dev/panels/command_panel_test.rb +15 -17
- data/lib/dev_system/dev/panels/generator_panel.rb +3 -0
- data/lib/dev_system/dev/panels/generator_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/log_panel.rb +9 -6
- data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
- data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
- data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
- data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
- data/lib/happy_system/happy/controllers/axo.rb +4 -5
- data/lib/happy_system/happy/happy_box.rb +6 -9
- data/lib/happy_system/happy/happy_box_test.rb +11 -13
- data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
- data/lib/lerb.rb +106 -0
- data/lib/liza/base/box.rb +71 -26
- data/lib/liza/base/box_test.rb +7 -9
- data/lib/liza/base/controller.rb +19 -19
- data/lib/liza/base/controller_test.rb +7 -9
- data/lib/liza/base/panel.rb +40 -24
- data/lib/liza/base/panel_test.rb +10 -12
- 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.rb +12 -14
- data/lib/liza/meta/part_extension.rb +14 -11
- data/lib/liza/meta/part_test.rb +4 -6
- data/lib/liza/meta/system.rb +12 -14
- data/lib/liza/meta/system_test.rb +8 -10
- data/lib/liza/ruby_test.rb +7 -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 +7 -8
- data/lib/liza/test/test_test.rb +168 -76
- data/lib/liza/test_parts/test_assertions_advanced_part.rb +125 -0
- data/lib/liza/test_parts/test_assertions_part.rb +81 -82
- data/lib/liza/test_parts/test_dsl_part.rb +44 -98
- data/lib/liza/test_parts/test_log_part.rb +122 -0
- data/lib/liza/test_parts/test_subject_part.rb +16 -18
- data/lib/liza/test_parts/test_tree_part.rb +137 -0
- data/lib/liza/unit.rb +108 -102
- 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/unit_test.rb +69 -71
- 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/dev/net_command.rb +10 -12
- data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
- data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
- data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
- data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
- data/lib/net_system/net/controllers/client.rb +1 -3
- data/lib/net_system/net/controllers/client_test.rb +8 -10
- data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
- data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
- data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
- data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
- data/lib/net_system/net/controllers/database.rb +21 -23
- data/lib/net_system/net/controllers/database_test.rb +8 -10
- data/lib/net_system/net/controllers/record.rb +29 -0
- data/lib/net_system/net/controllers/record_test.rb +12 -0
- data/lib/net_system/net/net_box.rb +11 -16
- data/lib/net_system/net/net_box_test.rb +12 -14
- data/lib/net_system/net/panels/client_panel.rb +1 -3
- data/lib/net_system/net/panels/client_panel_test.rb +11 -13
- data/lib/net_system/net/panels/database_panel.rb +6 -8
- data/lib/net_system/net/panels/database_panel_test.rb +11 -13
- data/lib/web_system/dev/rack_command.rb +35 -0
- data/lib/web_system/dev/request_command.rb +143 -0
- data/lib/web_system/dev/web_command.rb +6 -39
- data/lib/web_system/web/controllers/rack.rb +6 -0
- data/lib/web_system/web/controllers/rack_test.rb +16 -0
- data/lib/web_system/web/controllers/request/client_error_request.rb +9 -12
- data/lib/web_system/web/controllers/request/not_found_request.rb +9 -12
- data/lib/web_system/web/controllers/request/server_error_request.rb +10 -13
- data/lib/web_system/web/controllers/request.rb +1 -3
- data/lib/web_system/web/controllers/request_test.rb +11 -13
- data/lib/web_system/web/panels/rack_panel.rb +42 -0
- data/lib/web_system/web/panels/rack_panel_test.rb +12 -0
- data/lib/web_system/web/panels/request_panel.rb +54 -37
- data/lib/web_system/web/panels/request_panel_test.rb +28 -9
- data/lib/web_system/web/web_box.rb +16 -8
- data/lib/web_system/web/web_box_test.rb +11 -13
- data/lizarb.gemspec +2 -2
- metadata +76 -28
- 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/app_model_test.rb +0 -8
- data/app/net/models/post_model.rb +0 -4
- data/app/net/models/post_model_test.rb +0 -8
- data/app/net/models/user_model.rb +0 -4
- data/app/net/models/user_model_test.rb +0 -8
- data/app_new/.gitignore +0 -4
- data/app_new/Gemfile +0 -31
- data/app_new/Procfile +0 -3
- data/lib/dev_system/dev/controllers/command/dev_command.rb +0 -24
- data/lib/liza/test_parts/test_context_part.rb +0 -81
- data/lib/net_system/net/controllers/model.rb +0 -31
- data/lib/net_system/net/controllers/model_test.rb +0 -14
@@ -1,122 +1,68 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
insertion do
|
4
|
-
def self.test *words, &block
|
5
|
-
Liza.log "#{inspect}.test #{words}, &block"
|
6
|
-
block_given? || raise(ArgumentError, "No block given")
|
1
|
+
class Liza::TestDslPart < Liza::Part
|
2
|
+
insertion do
|
7
3
|
|
8
|
-
|
9
|
-
|
10
|
-
'b',
|
11
|
-
context.befores.flatten.map(&:source_location),
|
12
|
-
'a',
|
13
|
-
context.afters.flatten.map(&:source_location),
|
14
|
-
].flatten.join("-")
|
4
|
+
def self.call class_index, class_count
|
5
|
+
counter_class = "#{class_index.to_s.rjust 3, "0"}/#{class_count.to_s.rjust 3, "0"}"
|
15
6
|
|
16
|
-
|
7
|
+
log "+ #{counter_class} #{self} class".bold.white
|
17
8
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.instances
|
25
|
-
@instances ||= {}
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.call class_index, class_count
|
29
|
-
counter_class = "#{class_index.to_s.rjust 3, "0"}/#{class_count.to_s.rjust 3, "0"}"
|
9
|
+
array = [test_tree]
|
10
|
+
while array.any?
|
11
|
+
node = array.pop
|
12
|
+
i = 0
|
30
13
|
|
31
|
-
|
14
|
+
node.tests.each do |test_words, test_block|
|
15
|
+
counter_instance = "#{(i+=1).to_s.rjust 2, '0'}/#{node.tests.size.to_s.rjust 2, '0'}"
|
16
|
+
label = test_words.to_a.flatten.join(" ")[0..25]
|
32
17
|
|
33
|
-
|
34
|
-
counter_instance = "#{(i+=1).to_s.rjust 2, '0'}/#{instances.size.to_s.rjust 2, '0'}"
|
35
|
-
label = instance.words_as_label
|
36
|
-
|
37
|
-
puts " #{ counter_class } #{ counter_instance } (#{ label })".light_cyan
|
18
|
+
log " #{ counter_class } #{ counter_instance } #{ label.ljust(27)} #{_log_test_block test_block}"
|
38
19
|
|
20
|
+
log_test_building node, test_block if log_test_building?
|
21
|
+
|
22
|
+
instance = new test_words, node.before_stack, node.after_stack, &test_block
|
39
23
|
instance.call
|
40
24
|
end
|
25
|
+
|
26
|
+
array.concat node.children
|
41
27
|
end
|
42
28
|
|
43
|
-
|
29
|
+
end
|
44
30
|
|
45
|
-
|
31
|
+
attr_reader :test_words
|
46
32
|
|
47
|
-
|
48
|
-
|
49
|
-
|
33
|
+
def initialize test_words, before_stack, after_stack, &test_block
|
34
|
+
@test_words, @before_stack, @after_stack, @test_block = test_words, before_stack, after_stack, test_block
|
35
|
+
end
|
50
36
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
37
|
+
def call
|
38
|
+
catch :critical do
|
39
|
+
@before_stack.each do |stack|
|
40
|
+
log " calling stacked before blocks #{stack.map { |bl| _log_test_block bl }}".magenta if log_test_building?
|
41
|
+
stack.each do |bl|
|
42
|
+
log_test_call "B&", &bl if log_test_call_block?
|
55
43
|
instance_exec &bl
|
56
44
|
end
|
45
|
+
end
|
57
46
|
|
58
|
-
|
59
|
-
|
60
|
-
|
47
|
+
bl = @test_block
|
48
|
+
log " calling test block #{_log_test_block bl}".magenta if log_test_building?
|
49
|
+
log_test_call "T&", &bl if log_test_call_block?
|
50
|
+
instance_exec &bl
|
61
51
|
|
62
|
-
|
63
|
-
|
52
|
+
@after_stack.each do |stack|
|
53
|
+
log " calling stacked after blocks #{stack.map { |bl| _log_test_block bl }}".magenta if log_test_building?
|
54
|
+
stack.each do |bl|
|
55
|
+
log_test_call "A&", &bl if log_test_call_block?
|
64
56
|
instance_exec &bl
|
65
57
|
end
|
66
58
|
end
|
67
|
-
rescue Exception => e
|
68
|
-
self.class._assertion_errored e
|
69
|
-
_rescue_log e
|
70
|
-
ensure
|
71
|
-
puts
|
72
|
-
end
|
73
|
-
|
74
|
-
def words_as_label
|
75
|
-
label = words.to_s
|
76
|
-
label = label[1..-2] if label.start_with? "["
|
77
|
-
label = label[1..-2] if label.start_with? "{"
|
78
|
-
label
|
79
|
-
end
|
80
|
-
|
81
|
-
def _rescue_log e
|
82
|
-
prefix = "error"
|
83
|
-
|
84
|
-
kaller = e.backtrace
|
85
|
-
|
86
|
-
source_location = _caller_line_split(kaller[0])[0]
|
87
|
-
source_location = source_location.gsub("#{Lizarb::CUR_DIR}/", "")
|
88
|
-
|
89
|
-
log " #{prefix} #{source_location}"
|
90
|
-
|
91
|
-
puts "Exception!".red
|
92
|
-
puts e.class.to_s.red
|
93
|
-
puts e.message.red
|
94
|
-
puts
|
95
|
-
puts e.backtrace.join("\n").red
|
96
|
-
end
|
97
|
-
|
98
|
-
def _call_log prefix, &block
|
99
|
-
source_location = block.source_location.join(":").gsub("#{Lizarb::CUR_DIR}/", "")
|
100
|
-
source_location = source_location[0..-1]
|
101
|
-
log " #{prefix} #{source_location}"
|
102
|
-
end
|
103
|
-
|
104
|
-
def _assertion_log method_name, kaller
|
105
|
-
_inc_assertions
|
106
|
-
method_name = method_name.to_s.ljust 6
|
107
|
-
prefix = "#{assertions} #{method_name} #{@last_result}"
|
108
|
-
|
109
|
-
source_location = _caller_line_split(kaller[0])[0]
|
110
|
-
source_location = source_location.gsub("#{Lizarb::CUR_DIR}/", "")
|
111
|
-
|
112
|
-
log " #{prefix} #{source_location}"
|
113
|
-
end
|
114
|
-
|
115
|
-
def _caller_line_split s
|
116
|
-
x = s.split ":in `"
|
117
|
-
x[1] = x[1][0..-2]
|
118
|
-
x
|
119
59
|
end
|
60
|
+
rescue Exception => e
|
61
|
+
self.class._assertion_errored e
|
62
|
+
log_test_call_rescue e
|
63
|
+
ensure
|
64
|
+
puts
|
120
65
|
end
|
66
|
+
|
121
67
|
end
|
122
68
|
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
class Liza::TestLogPart < Liza::Part
|
2
|
+
|
3
|
+
insertion do
|
4
|
+
|
5
|
+
LOG_BUILDING = false
|
6
|
+
LOG_ASSERTION = true
|
7
|
+
LOG_ASSERTION_MESSAGE = true
|
8
|
+
LOG_CALL_BLOCK = true
|
9
|
+
|
10
|
+
def self.log_test_building?
|
11
|
+
LOG_BUILDING
|
12
|
+
end
|
13
|
+
|
14
|
+
def log_test_building?
|
15
|
+
self.class.log_test_building?
|
16
|
+
end
|
17
|
+
|
18
|
+
def log_test_assertion?
|
19
|
+
LOG_ASSERTION
|
20
|
+
end
|
21
|
+
|
22
|
+
def log_test_assertion_message?
|
23
|
+
LOG_ASSERTION_MESSAGE
|
24
|
+
end
|
25
|
+
|
26
|
+
def log_test_call_block?
|
27
|
+
LOG_CALL_BLOCK
|
28
|
+
end
|
29
|
+
|
30
|
+
def log_test_call_rescue e
|
31
|
+
prefix = "error".yellow
|
32
|
+
|
33
|
+
kaller = e.backtrace
|
34
|
+
|
35
|
+
source_location = _caller_line_split(kaller[0])[0]
|
36
|
+
source_location = source_location.gsub("#{Lizarb::CUR_DIR}/", "")
|
37
|
+
|
38
|
+
log " #{prefix} #{e.class.to_s.ljust 20} #{source_location}"
|
39
|
+
|
40
|
+
puts "Exception!".red
|
41
|
+
puts e.class.to_s.red
|
42
|
+
puts e.message.red
|
43
|
+
puts
|
44
|
+
puts e.backtrace.join("\n").red
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.log_test_building node, test_block
|
48
|
+
log " the building blocks are".magenta
|
49
|
+
|
50
|
+
node.before_stack.each do |stack|
|
51
|
+
stack.each do |bl|
|
52
|
+
log " before block #{_log_test_block bl}".magenta
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
log " test block #{_log_test_block test_block}".magenta
|
57
|
+
|
58
|
+
node.after_stack.each do |stack|
|
59
|
+
stack.each do |bl|
|
60
|
+
log " after block #{_log_test_block bl}".magenta
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def log_test_call prefix, &block
|
66
|
+
source_location = block.source_location.join(":").gsub("#{Lizarb::CUR_DIR}/", "")
|
67
|
+
source_location = source_location[0..-1]
|
68
|
+
log " #{prefix} #{source_location}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def log_test_assertion method_name, kaller
|
72
|
+
_inc_assertions
|
73
|
+
prefix = "#{assertions.to_s.rjust 2, "0"} #{_log_test_assertion_tag method_name}"
|
74
|
+
|
75
|
+
source_location = _caller_line_split(kaller[0])[0]
|
76
|
+
source_location = source_location.gsub("#{Lizarb::CUR_DIR}/", "")
|
77
|
+
|
78
|
+
log " #{prefix} #{source_location}" if log_test_assertion?
|
79
|
+
end
|
80
|
+
|
81
|
+
def _log_test_assertion_tag method_name
|
82
|
+
"#{log_test_assertion_result} #{method_name.to_s.ljust(20).bold.white}"
|
83
|
+
end
|
84
|
+
|
85
|
+
def self._log_test_block test_block
|
86
|
+
test_block.source_location.join(":").gsub("#{Lizarb::CUR_DIR}/", "")
|
87
|
+
end
|
88
|
+
|
89
|
+
def _log_test_block test_block
|
90
|
+
self.class._log_test_block test_block
|
91
|
+
end
|
92
|
+
|
93
|
+
def log_test_assertion_result
|
94
|
+
case @last_result
|
95
|
+
when :todo
|
96
|
+
" todo".blue
|
97
|
+
when :passed
|
98
|
+
"passed".green
|
99
|
+
when :failed
|
100
|
+
"failed".red
|
101
|
+
else
|
102
|
+
raise "Unknown result: #{@last_result}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def log_test_assertion_message b, msg
|
107
|
+
if b
|
108
|
+
log " passed #{msg}".green
|
109
|
+
else
|
110
|
+
log " failed #{msg}".red
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def _caller_line_split s
|
115
|
+
x = s.split ":in `"
|
116
|
+
x[1] = x[1][0..-2]
|
117
|
+
x
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
@@ -1,24 +1,22 @@
|
|
1
|
-
|
2
|
-
class TestSubjectPart < Part
|
1
|
+
class Liza::TestSubjectPart < Liza::Part
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def subject_class
|
15
|
-
self.class.subject_class
|
16
|
-
end
|
3
|
+
insertion do
|
4
|
+
def self.subject_class
|
5
|
+
@subject_class ||=
|
6
|
+
if first_namespace == "Liza"
|
7
|
+
Liza.const_get last_namespace[0..-5]
|
8
|
+
else
|
9
|
+
Object.const_get name[0..-5]
|
10
|
+
end
|
11
|
+
end
|
17
12
|
|
18
|
-
|
19
|
-
|
20
|
-
end
|
13
|
+
def subject_class
|
14
|
+
self.class.subject_class
|
21
15
|
end
|
22
16
|
|
17
|
+
def subject
|
18
|
+
@subject ||= subject_class.new
|
19
|
+
end
|
23
20
|
end
|
21
|
+
|
24
22
|
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
class Liza::TestTreePart < Liza::Part
|
2
|
+
|
3
|
+
insertion do
|
4
|
+
|
5
|
+
@before_stack = []
|
6
|
+
@after_stack = []
|
7
|
+
|
8
|
+
def self.before_stack; @before_stack ||= superclass.before_stack.dup end
|
9
|
+
def self.after_stack; @after_stack ||= superclass.after_stack.dup end
|
10
|
+
|
11
|
+
def self.test_node; @test_node ||= test_tree end
|
12
|
+
def self.test_tree; @test_tree ||= Liza::TestTreePart::Extension.new nil, before_stack, after_stack end
|
13
|
+
|
14
|
+
#
|
15
|
+
|
16
|
+
def self.group *words, &block
|
17
|
+
raise ArgumentError, "No block given" unless block_given?
|
18
|
+
previous = test_node
|
19
|
+
@test_node = test_node.branch_out words
|
20
|
+
instance_exec &block
|
21
|
+
@test_node = previous
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.test *words, &block
|
25
|
+
raise ArgumentError, "No block given" unless block_given?
|
26
|
+
test_node.add_test words, &block
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.before &block
|
30
|
+
raise ArgumentError, "No block given" unless block_given?
|
31
|
+
test_node.add_before &block
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.after &block
|
35
|
+
raise ArgumentError, "No block given" unless block_given?
|
36
|
+
test_node.add_after &block
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
extension do
|
42
|
+
|
43
|
+
def log *args
|
44
|
+
self.class.solder.log *args
|
45
|
+
end
|
46
|
+
|
47
|
+
def log_test_building?
|
48
|
+
Liza::Test.log_test_building?
|
49
|
+
end
|
50
|
+
|
51
|
+
attr_reader :tests, :parent, :children, :before_stack, :after_stack
|
52
|
+
|
53
|
+
def initialize parent, before_stack, after_stack
|
54
|
+
@parent = parent || self
|
55
|
+
|
56
|
+
@children, @tests = [], []
|
57
|
+
@before_top, @after_top = [], []
|
58
|
+
|
59
|
+
@before_stack = before_stack.push @before_top
|
60
|
+
@after_stack = after_stack.unshift @after_top
|
61
|
+
|
62
|
+
@parent.children << self if @parent != self
|
63
|
+
end
|
64
|
+
|
65
|
+
def initialize parent, before_stack, after_stack
|
66
|
+
@parent = parent || self
|
67
|
+
|
68
|
+
@children, @tests, @before_top, @after_top = [], [], [], []
|
69
|
+
|
70
|
+
@before_stack = before_stack.push @before_top
|
71
|
+
@after_stack = after_stack.unshift @after_top
|
72
|
+
|
73
|
+
@parent.children << self if @parent != self
|
74
|
+
end
|
75
|
+
|
76
|
+
def initialize parent, before_stack, after_stack
|
77
|
+
@parent = parent || self
|
78
|
+
@children, @tests = [], []
|
79
|
+
@parent.children << self if @parent != self
|
80
|
+
|
81
|
+
@before_top, @after_top = [], []
|
82
|
+
@before_stack = before_stack.push @before_top
|
83
|
+
@after_stack = after_stack.unshift @after_top
|
84
|
+
end
|
85
|
+
|
86
|
+
def initialize parent, before_stack, after_stack
|
87
|
+
@tests = []
|
88
|
+
|
89
|
+
@parent = parent || self
|
90
|
+
@children = []
|
91
|
+
@parent.children << self if @parent != self
|
92
|
+
|
93
|
+
@before_top, @after_top = [], []
|
94
|
+
@before_stack = before_stack.push @before_top
|
95
|
+
@after_stack = after_stack.unshift @after_top
|
96
|
+
end
|
97
|
+
|
98
|
+
def initialize parent, before_stack, after_stack
|
99
|
+
@tests = []
|
100
|
+
initialize_parenting parent
|
101
|
+
initialize_filters before_stack, after_stack
|
102
|
+
end
|
103
|
+
|
104
|
+
def initialize_parenting parent
|
105
|
+
@parent = parent || self
|
106
|
+
@children = []
|
107
|
+
@parent.children << self if @parent != self
|
108
|
+
end
|
109
|
+
|
110
|
+
def initialize_filters before_stack, after_stack
|
111
|
+
@before_top, @after_top = [], []
|
112
|
+
@before_stack = before_stack.push @before_top
|
113
|
+
@after_stack = after_stack.unshift @after_top
|
114
|
+
end
|
115
|
+
|
116
|
+
def add_before &block
|
117
|
+
log "add_before to ##{object_id} #{block}" if log_test_building?
|
118
|
+
@before_top.push block
|
119
|
+
end
|
120
|
+
|
121
|
+
def add_test words, &block
|
122
|
+
log "add_test to ##{object_id} #{words} #{block}" if log_test_building?
|
123
|
+
tests << [words, block]
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_after &block
|
127
|
+
log "add_after to ##{object_id} #{block}" if log_test_building?
|
128
|
+
@after_top.push block
|
129
|
+
end
|
130
|
+
|
131
|
+
def branch_out words, &block
|
132
|
+
self.class.new self, before_stack.dup, after_stack.dup
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|