lizarb 1.0.2 → 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/Gemfile.lock +1 -1
- 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/records/app_record_test.rb +1 -1
- data/app/net/records/post_record_test.rb +1 -1
- data/app/net/records/user_record_test.rb +1 -1
- data/app/net_box.rb +7 -7
- data/app/web_box.rb +2 -2
- data/lib/app.rb +1 -1
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +17 -19
- data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +9 -11
- 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 -22
- 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 +20 -22
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +17 -19
- data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/terminal_command.rb +12 -14
- data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/test_command.rb +64 -53
- 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 +103 -53
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +17 -19
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +8 -10
- 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 +16 -18
- 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/liza/base/box.rb +71 -26
- data/lib/liza/base/box_test.rb +7 -9
- data/lib/liza/base/controller.rb +19 -21
- data/lib/liza/base/controller_test.rb +7 -9
- data/lib/liza/base/panel.rb +42 -27
- data/lib/liza/base/panel_test.rb +10 -12
- data/lib/liza/meta/part.rb +12 -14
- data/lib/liza/meta/part_extension.rb +14 -16
- 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 +4 -6
- data/lib/liza/ruby_tests/module_test.rb +1 -1
- data/lib/liza/test/test.rb +7 -10
- data/lib/liza/test/test_test.rb +158 -159
- data/lib/liza/test_parts/test_assertions_advanced_part.rb +102 -104
- data/lib/liza/test_parts/test_assertions_part.rb +81 -83
- data/lib/liza/test_parts/test_dsl_part.rb +47 -49
- data/lib/liza/test_parts/test_log_part.rb +88 -90
- data/lib/liza/test_parts/test_subject_part.rb +16 -18
- data/lib/liza/test_parts/test_tree_part.rb +105 -107
- data/lib/liza/unit.rb +108 -104
- data/lib/liza/unit_test.rb +69 -71
- data/lib/lizarb/version.rb +1 -1
- 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 +21 -23
- data/lib/net_system/net/controllers/record_test.rb +8 -10
- 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 +26 -17
- data/lib/web_system/dev/request_command.rb +2 -2
- data/lib/web_system/dev/web_command.rb +6 -8
- data/lib/web_system/web/controllers/rack.rb +4 -6
- data/lib/web_system/web/controllers/rack_test.rb +11 -13
- data/lib/web_system/web/controllers/request/client_error_request.rb +9 -11
- data/lib/web_system/web/controllers/request/not_found_request.rb +9 -11
- data/lib/web_system/web/controllers/request/server_error_request.rb +10 -12
- 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 +37 -39
- data/lib/web_system/web/panels/rack_panel_test.rb +8 -10
- data/lib/web_system/web/panels/request_panel.rb +54 -56
- data/lib/web_system/web/panels/request_panel_test.rb +1 -1
- data/lib/web_system/web/web_box.rb +14 -18
- data/lib/web_system/web/web_box_test.rb +11 -13
- metadata +10 -5
- data/app_new/.gitignore +0 -4
- data/app_new/Gemfile +0 -31
- data/app_new/Procfile +0 -3
@@ -1,139 +1,137 @@
|
|
1
|
-
|
2
|
-
|
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
|
3
23
|
|
4
|
-
|
24
|
+
def self.test *words, &block
|
25
|
+
raise ArgumentError, "No block given" unless block_given?
|
26
|
+
test_node.add_test words, &block
|
27
|
+
end
|
5
28
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def self.after_stack; @after_stack ||= superclass.after_stack.dup end
|
11
|
-
|
12
|
-
def self.test_node; @test_node ||= test_tree end
|
13
|
-
def self.test_tree; @test_tree ||= Liza::TestTreePart::Extension.new nil, before_stack, after_stack end
|
14
|
-
|
15
|
-
#
|
16
|
-
|
17
|
-
def self.group *words, &block
|
18
|
-
raise ArgumentError, "No block given" unless block_given?
|
19
|
-
previous = test_node
|
20
|
-
@test_node = test_node.branch_out words
|
21
|
-
instance_exec &block
|
22
|
-
@test_node = previous
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.test *words, &block
|
26
|
-
raise ArgumentError, "No block given" unless block_given?
|
27
|
-
test_node.add_test words, &block
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.before &block
|
31
|
-
raise ArgumentError, "No block given" unless block_given?
|
32
|
-
test_node.add_before &block
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.after &block
|
36
|
-
raise ArgumentError, "No block given" unless block_given?
|
37
|
-
test_node.add_after &block
|
38
|
-
end
|
29
|
+
def self.before &block
|
30
|
+
raise ArgumentError, "No block given" unless block_given?
|
31
|
+
test_node.add_before &block
|
32
|
+
end
|
39
33
|
|
34
|
+
def self.after &block
|
35
|
+
raise ArgumentError, "No block given" unless block_given?
|
36
|
+
test_node.add_after &block
|
40
37
|
end
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
def log *args
|
45
|
-
self.class.solder.log *args
|
46
|
-
end
|
39
|
+
end
|
47
40
|
|
48
|
-
|
49
|
-
|
50
|
-
|
41
|
+
extension do
|
42
|
+
|
43
|
+
def log *args
|
44
|
+
self.class.solder.log *args
|
45
|
+
end
|
51
46
|
|
52
|
-
|
47
|
+
def log_test_building?
|
48
|
+
Liza::Test.log_test_building?
|
49
|
+
end
|
53
50
|
|
54
|
-
|
55
|
-
@parent = parent || self
|
51
|
+
attr_reader :tests, :parent, :children, :before_stack, :after_stack
|
56
52
|
|
57
|
-
|
58
|
-
|
53
|
+
def initialize parent, before_stack, after_stack
|
54
|
+
@parent = parent || self
|
59
55
|
|
60
|
-
|
61
|
-
|
56
|
+
@children, @tests = [], []
|
57
|
+
@before_top, @after_top = [], []
|
62
58
|
|
63
|
-
|
64
|
-
|
59
|
+
@before_stack = before_stack.push @before_top
|
60
|
+
@after_stack = after_stack.unshift @after_top
|
65
61
|
|
66
|
-
|
67
|
-
|
62
|
+
@parent.children << self if @parent != self
|
63
|
+
end
|
68
64
|
|
69
|
-
|
65
|
+
def initialize parent, before_stack, after_stack
|
66
|
+
@parent = parent || self
|
70
67
|
|
71
|
-
|
72
|
-
@after_stack = after_stack.unshift @after_top
|
68
|
+
@children, @tests, @before_top, @after_top = [], [], [], []
|
73
69
|
|
74
|
-
|
75
|
-
|
70
|
+
@before_stack = before_stack.push @before_top
|
71
|
+
@after_stack = after_stack.unshift @after_top
|
76
72
|
|
77
|
-
|
78
|
-
|
79
|
-
@children, @tests = [], []
|
80
|
-
@parent.children << self if @parent != self
|
73
|
+
@parent.children << self if @parent != self
|
74
|
+
end
|
81
75
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
76
|
+
def initialize parent, before_stack, after_stack
|
77
|
+
@parent = parent || self
|
78
|
+
@children, @tests = [], []
|
79
|
+
@parent.children << self if @parent != self
|
86
80
|
|
87
|
-
|
88
|
-
|
81
|
+
@before_top, @after_top = [], []
|
82
|
+
@before_stack = before_stack.push @before_top
|
83
|
+
@after_stack = after_stack.unshift @after_top
|
84
|
+
end
|
89
85
|
|
90
|
-
|
91
|
-
|
92
|
-
@parent.children << self if @parent != self
|
86
|
+
def initialize parent, before_stack, after_stack
|
87
|
+
@tests = []
|
93
88
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
89
|
+
@parent = parent || self
|
90
|
+
@children = []
|
91
|
+
@parent.children << self if @parent != self
|
98
92
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
93
|
+
@before_top, @after_top = [], []
|
94
|
+
@before_stack = before_stack.push @before_top
|
95
|
+
@after_stack = after_stack.unshift @after_top
|
96
|
+
end
|
104
97
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
98
|
+
def initialize parent, before_stack, after_stack
|
99
|
+
@tests = []
|
100
|
+
initialize_parenting parent
|
101
|
+
initialize_filters before_stack, after_stack
|
102
|
+
end
|
110
103
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
104
|
+
def initialize_parenting parent
|
105
|
+
@parent = parent || self
|
106
|
+
@children = []
|
107
|
+
@parent.children << self if @parent != self
|
108
|
+
end
|
116
109
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
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
|
121
115
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
116
|
+
def add_before &block
|
117
|
+
log "add_before to ##{object_id} #{block}" if log_test_building?
|
118
|
+
@before_top.push block
|
119
|
+
end
|
126
120
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
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
|
131
125
|
|
132
|
-
|
133
|
-
|
134
|
-
|
126
|
+
def add_after &block
|
127
|
+
log "add_after to ##{object_id} #{block}" if log_test_building?
|
128
|
+
@after_top.push block
|
129
|
+
end
|
135
130
|
|
131
|
+
def branch_out words, &block
|
132
|
+
self.class.new self, before_stack.dup, after_stack.dup
|
136
133
|
end
|
137
134
|
|
138
135
|
end
|
136
|
+
|
139
137
|
end
|
data/lib/liza/unit.rb
CHANGED
@@ -1,151 +1,155 @@
|
|
1
|
-
|
2
|
-
class Unit
|
1
|
+
class Liza::Unit
|
3
2
|
|
4
|
-
|
3
|
+
# PARTS
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
part :unit_procedure
|
5
|
+
def self.part key, system: nil
|
6
|
+
App.connect_part self, key, system
|
7
|
+
end
|
11
8
|
|
12
|
-
|
9
|
+
def self.const_missing name
|
10
|
+
Liza.const name
|
11
|
+
rescue Liza::ConstNotFound => e
|
12
|
+
raise NameError, "uninitialized constant #{name}", caller[1..], cause: nil
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
@settings ||= {}
|
16
|
-
end
|
15
|
+
part :unit_procedure
|
17
16
|
|
18
|
-
|
19
|
-
return settings[key] if settings.has_key? key
|
17
|
+
# SETTINGS
|
20
18
|
|
21
|
-
|
19
|
+
def self.settings
|
20
|
+
@settings ||= {}
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
def self.get key
|
24
|
+
return settings[key] if settings.has_key? key
|
25
25
|
|
26
|
-
|
27
|
-
found = klass.settings[key]
|
26
|
+
found = nil
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
end
|
28
|
+
for klass in ancestors
|
29
|
+
break unless klass.respond_to? :settings
|
32
30
|
|
33
|
-
|
31
|
+
if klass.settings.has_key? key
|
32
|
+
found = klass.settings[key]
|
34
33
|
|
35
|
-
|
34
|
+
break
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
settings[key] = value
|
40
|
-
value
|
41
|
-
end
|
38
|
+
found = settings[key] = found.dup if found.is_a? Enumerable
|
42
39
|
|
43
|
-
|
44
|
-
|
45
|
-
fetch(list) { Hash.new }[key] = value
|
46
|
-
else
|
47
|
-
fetch(list) { Set.new } << value
|
48
|
-
end
|
49
|
-
end
|
40
|
+
found
|
41
|
+
end
|
50
42
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
43
|
+
def self.set key, value
|
44
|
+
settings[key] = value
|
45
|
+
value
|
46
|
+
end
|
56
47
|
|
57
|
-
|
58
|
-
|
48
|
+
def self.add list, key = nil, value
|
49
|
+
if key
|
50
|
+
fetch(list) { Hash.new }[key] = value
|
51
|
+
else
|
52
|
+
fetch(list) { Set.new } << value
|
59
53
|
end
|
54
|
+
end
|
60
55
|
|
61
|
-
|
62
|
-
|
56
|
+
def self.fetch key, &block
|
57
|
+
x = get key
|
58
|
+
x ||= set key, instance_eval(&block)
|
59
|
+
x
|
60
|
+
end
|
63
61
|
|
64
|
-
|
65
|
-
|
62
|
+
def settings
|
63
|
+
@settings ||= {}
|
64
|
+
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
end
|
66
|
+
def get key
|
67
|
+
return settings[key] if settings.has_key? key
|
70
68
|
|
71
|
-
|
72
|
-
|
73
|
-
fetch(list) { Hash.new }[key] = value
|
74
|
-
else
|
75
|
-
fetch(list) { Set.new } << value
|
76
|
-
end
|
77
|
-
end
|
69
|
+
self.class.get key
|
70
|
+
end
|
78
71
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
72
|
+
def set key, value
|
73
|
+
settings[key] = value
|
74
|
+
end
|
75
|
+
|
76
|
+
def add list, key = nil, value
|
77
|
+
if key
|
78
|
+
fetch(list) { Hash.new }[key] = value
|
79
|
+
else
|
80
|
+
fetch(list) { Set.new } << value
|
83
81
|
end
|
82
|
+
end
|
84
83
|
|
85
|
-
|
84
|
+
def fetch key, &block
|
85
|
+
x = get key
|
86
|
+
x ||= set key, eval(&block)
|
87
|
+
x
|
88
|
+
end
|
86
89
|
|
87
|
-
|
88
|
-
:higher => 2,
|
89
|
-
:high => 1,
|
90
|
-
:normal => 0,
|
91
|
-
:low => -1,
|
92
|
-
:lower => -2,
|
93
|
-
}
|
90
|
+
# LOG
|
94
91
|
|
95
|
-
|
96
|
-
|
92
|
+
LOG_LEVELS = {
|
93
|
+
:higher => 2,
|
94
|
+
:high => 1,
|
95
|
+
:normal => 0,
|
96
|
+
:low => -1,
|
97
|
+
:lower => -2,
|
98
|
+
}
|
97
99
|
|
98
|
-
|
100
|
+
set :log_level, :normal
|
101
|
+
set :log_color, :white
|
99
102
|
|
100
|
-
|
103
|
+
#
|
101
104
|
|
102
|
-
|
103
|
-
raise "invalid log_level `#{log_level}`" unless LOG_LEVELS.keys.include? log_level
|
104
|
-
return unless log_level? log_level
|
105
|
+
LOG_JUST = 40
|
105
106
|
|
106
|
-
|
107
|
-
|
107
|
+
def self.log log_level = :normal, string
|
108
|
+
raise "invalid log_level `#{log_level}`" unless LOG_LEVELS.keys.include? log_level
|
109
|
+
return unless log_level? log_level
|
108
110
|
|
109
|
-
|
111
|
+
source = (self.is_a? Class) ? self : self.class
|
112
|
+
source = source.to_s.ljust(LOG_JUST).bold.colorize(source.log_color)
|
110
113
|
|
111
|
-
|
112
|
-
end
|
114
|
+
string = "#{source} #{string}"
|
113
115
|
|
114
|
-
|
115
|
-
|
116
|
-
end
|
116
|
+
DevBox[:log].call string
|
117
|
+
end
|
117
118
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
119
|
+
def self.log_level
|
120
|
+
get(:log_level) || :normal
|
121
|
+
end
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
def self.log_level? log_level = :normal
|
124
|
+
# TODO
|
125
|
+
true
|
126
|
+
end
|
126
127
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
def log?(...)= self.class.log?(...)
|
131
|
-
def log_level?(...)= self.class.log_level?(...)
|
132
|
-
def log_color(...)= self.class.log_color(...)
|
128
|
+
def self.log_color
|
129
|
+
(get(:system) || self).get :log_color
|
130
|
+
end
|
133
131
|
|
134
|
-
|
132
|
+
def self.log?(log_level = :normal)= log_level? log_level
|
133
|
+
def log(...)= self.class.log(...)
|
134
|
+
def log_level(...)= self.class.log_level(...)
|
135
|
+
def log?(...)= self.class.log?(...)
|
136
|
+
def log_level?(...)= self.class.log_level?(...)
|
137
|
+
def log_color(...)= self.class.log_color(...)
|
135
138
|
|
136
|
-
|
139
|
+
# SYSTEM
|
137
140
|
|
138
|
-
|
139
|
-
super
|
141
|
+
def self.inherited_explicitly_sets_system
|
140
142
|
|
141
|
-
|
143
|
+
def self.inherited sub
|
144
|
+
super
|
142
145
|
|
143
|
-
|
146
|
+
return unless sub.name.to_s.include? "::"
|
144
147
|
|
145
|
-
|
146
|
-
end
|
148
|
+
system = Object.const_get sub.first_namespace
|
147
149
|
|
150
|
+
sub.set :system, system
|
148
151
|
end
|
149
152
|
|
150
153
|
end
|
154
|
+
|
151
155
|
end
|
data/lib/liza/unit_test.rb
CHANGED
@@ -1,79 +1,77 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
class Liza::UnitTest < Liza::Test
|
2
|
+
test :subject_class do
|
3
|
+
assert subject_class == Liza::Unit
|
4
|
+
end
|
5
|
+
|
6
|
+
test :settings do
|
7
|
+
assert subject_class.get(:log_level) == :normal
|
8
|
+
assert subject_class.get(:log_color) == :white
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :white
|
11
|
+
|
12
|
+
assert subject_class.settings == {log_level: :normal, log_color: :white}
|
13
|
+
end
|
14
|
+
|
15
|
+
test :settings_inheritance do
|
16
|
+
class_a = Class.new(subject_class) do
|
17
|
+
set :number, 1
|
18
|
+
|
19
|
+
add :default, 10
|
20
|
+
add :default, 20
|
6
21
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
assert subject_class.log_level == :normal
|
11
|
-
assert subject_class.log_color == :white
|
22
|
+
set :array, []
|
23
|
+
add :array, 10
|
24
|
+
add :array, 20
|
12
25
|
|
13
|
-
|
26
|
+
add :hash, :a, 10
|
27
|
+
add :hash, :b, 20
|
14
28
|
end
|
15
29
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
assert class_a.get(:default) == Set[10, 20]
|
39
|
-
assert class_a.get(:array) == [10, 20]
|
40
|
-
assert class_a.get(:hash) == {a: 10, b: 20}
|
41
|
-
|
42
|
-
class_b = Class.new(class_a) do
|
43
|
-
set :string, "a"
|
44
|
-
|
45
|
-
add :default, 30
|
46
|
-
add :default, 40
|
47
|
-
|
48
|
-
add :array, 30
|
49
|
-
add :array, 40
|
50
|
-
|
51
|
-
add :hash, :c, 30
|
52
|
-
add :hash, :d, 40
|
53
|
-
end
|
54
|
-
|
55
|
-
assert class_a.settings == {
|
56
|
-
number: 1,
|
57
|
-
default: Set[10, 20],
|
58
|
-
array: [10, 20],
|
59
|
-
hash: {a: 10, b: 20}
|
60
|
-
}
|
61
|
-
|
62
|
-
assert class_a.get(:default) == Set[10, 20]
|
63
|
-
assert class_a.get(:array) == [10, 20]
|
64
|
-
assert class_a.get(:hash) == {a: 10, b: 20}
|
65
|
-
|
66
|
-
assert class_b.settings == {
|
67
|
-
string: "a",
|
68
|
-
default: Set[10, 20, 30, 40],
|
69
|
-
array: [10, 20, 30, 40],
|
70
|
-
hash: {a: 10, b: 20, c: 30, d: 40}
|
71
|
-
}
|
72
|
-
|
73
|
-
assert class_b.get(:default) == Set[10, 20, 30, 40]
|
74
|
-
assert class_b.get(:array) == [10, 20, 30, 40]
|
75
|
-
assert class_b.get(:hash) == {a: 10, b: 20, c: 30, d: 40}
|
30
|
+
assert class_a.settings == {
|
31
|
+
number: 1,
|
32
|
+
default: Set[10, 20],
|
33
|
+
array: [10, 20],
|
34
|
+
hash: {a: 10, b: 20}
|
35
|
+
}
|
36
|
+
|
37
|
+
assert class_a.get(:default) == Set[10, 20]
|
38
|
+
assert class_a.get(:array) == [10, 20]
|
39
|
+
assert class_a.get(:hash) == {a: 10, b: 20}
|
40
|
+
|
41
|
+
class_b = Class.new(class_a) do
|
42
|
+
set :string, "a"
|
43
|
+
|
44
|
+
add :default, 30
|
45
|
+
add :default, 40
|
46
|
+
|
47
|
+
add :array, 30
|
48
|
+
add :array, 40
|
49
|
+
|
50
|
+
add :hash, :c, 30
|
51
|
+
add :hash, :d, 40
|
76
52
|
end
|
77
53
|
|
54
|
+
assert class_a.settings == {
|
55
|
+
number: 1,
|
56
|
+
default: Set[10, 20],
|
57
|
+
array: [10, 20],
|
58
|
+
hash: {a: 10, b: 20}
|
59
|
+
}
|
60
|
+
|
61
|
+
assert class_a.get(:default) == Set[10, 20]
|
62
|
+
assert class_a.get(:array) == [10, 20]
|
63
|
+
assert class_a.get(:hash) == {a: 10, b: 20}
|
64
|
+
|
65
|
+
assert class_b.settings == {
|
66
|
+
string: "a",
|
67
|
+
default: Set[10, 20, 30, 40],
|
68
|
+
array: [10, 20, 30, 40],
|
69
|
+
hash: {a: 10, b: 20, c: 30, d: 40}
|
70
|
+
}
|
71
|
+
|
72
|
+
assert class_b.get(:default) == Set[10, 20, 30, 40]
|
73
|
+
assert class_b.get(:array) == [10, 20, 30, 40]
|
74
|
+
assert class_b.get(:hash) == {a: 10, b: 20, c: 30, d: 40}
|
78
75
|
end
|
76
|
+
|
79
77
|
end
|
data/lib/lizarb/version.rb
CHANGED