lesli_testing 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lesli_testing/loader.rb +8 -5
- data/lib/lesli_testing/reporters/cli_reporter.rb +73 -30
- data/lib/lesli_testing/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d3f8b488a261e18bdf9030e0c369c534cd987341222892b3f397467ab382998b
|
|
4
|
+
data.tar.gz: bc20743265959a07b2acd5b1975b4d59eb9e30ab612d40621c1b8ccc1a86648e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17f37531c01a9a60131c69bd6cb87c6b4cb8b9a56ab54ddf1cfc04520fda3eb2f03d998f4b1c814ff4f29813ffb93280dbc940a28ba5b23de18d7b81c6b0861b
|
|
7
|
+
data.tar.gz: e29091cc308623a4f80d4423968c22d6882785dbf4712441567e3435e56f7fc1839e3120e6409fab285542fdae81d532ba364e71e29cea3efc18cfcb3c04f961
|
data/lib/lesli_testing/loader.rb
CHANGED
|
@@ -55,16 +55,19 @@ module LesliTesting
|
|
|
55
55
|
|
|
56
56
|
class << self
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
return if defined?(SimpleCov) && SimpleCov.running
|
|
58
|
+
attr_accessor :engine_module;
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
def configure(engine_module = nil, options = {})
|
|
61
|
+
|
|
62
|
+
engine_module = engine_module ? engine_module.name : "RailsApp"
|
|
63
|
+
|
|
64
|
+
return if defined?(SimpleCov) && SimpleCov.running
|
|
62
65
|
|
|
63
66
|
# Start Coverage
|
|
64
|
-
LesliTesting::Coverage.start(
|
|
67
|
+
LesliTesting::Coverage.start(engine_module, options[:min_coverage] || 40)
|
|
65
68
|
end
|
|
66
69
|
|
|
67
|
-
def configure_tests
|
|
70
|
+
def configure_tests()
|
|
68
71
|
|
|
69
72
|
# Apply Minitest/Reporters/Paths
|
|
70
73
|
LesliTesting::Config.apply(engine_module)
|
|
@@ -7,43 +7,54 @@ module LesliTesting
|
|
|
7
7
|
class CliReporter < Minitest::StatisticsReporter
|
|
8
8
|
def start
|
|
9
9
|
super
|
|
10
|
+
|
|
11
|
+
Termline.br
|
|
12
|
+
|
|
10
13
|
Termline.m(
|
|
11
|
-
Termline::Style.colorize("
|
|
12
|
-
Termline::Style.colorize("
|
|
13
|
-
Termline::Style.colorize("
|
|
14
|
+
Termline::Style.colorize("Running Lesli tests...", :blue),
|
|
15
|
+
Termline::Style.colorize("-> For a better result run test over a clean database", :blue),
|
|
16
|
+
Termline::Style.colorize("-> You can use: rake dev:db:reset", :blue)
|
|
14
17
|
)
|
|
15
|
-
|
|
18
|
+
|
|
19
|
+
Termline.br 2
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
def record(test)
|
|
19
23
|
super
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
# Only print the line if the configuration allows it
|
|
26
|
+
return if ENV["QUIET"]
|
|
27
|
+
|
|
28
|
+
# Map result codes to styles
|
|
29
|
+
status_map = {
|
|
30
|
+
"." => [:green, "PASS"],
|
|
31
|
+
"S" => [:yellow, "SKIP"],
|
|
32
|
+
"E" => [:red, "ERROR"],
|
|
33
|
+
"F" => [:red, "FAIL"]
|
|
34
|
+
}
|
|
35
|
+
color, label = status_map[test.result_code] || [:gray, "????"]
|
|
36
|
+
|
|
37
|
+
# Determine assertion health
|
|
38
|
+
assert_color = case test.assertions
|
|
39
|
+
when 0..1 then :red
|
|
40
|
+
when 2..4 then :yellow
|
|
41
|
+
else :green
|
|
37
42
|
end
|
|
38
43
|
|
|
39
|
-
parts
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
parts = [
|
|
45
|
+
Termline::Style.colorize("[#{Time.now.strftime('%H:%M:%S')}]", :gray),
|
|
46
|
+
Termline::Style.colorize(label, color),
|
|
47
|
+
"::",
|
|
48
|
+
Termline::Style.colorize(test.klass, :blue),
|
|
49
|
+
"->",
|
|
50
|
+
Termline::Style.colorize(test.name, :skyblue),
|
|
51
|
+
Termline::Style.colorize("(#{test.assertions} asserts)", assert_color)
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
# Add execution time per test
|
|
55
|
+
parts << Termline::Style.colorize("(%.2fs)" % test.time, :red) if test.time > 1
|
|
45
56
|
|
|
46
|
-
puts(parts.
|
|
57
|
+
puts(parts.join(" "))
|
|
47
58
|
end
|
|
48
59
|
|
|
49
60
|
def report
|
|
@@ -86,7 +97,7 @@ module LesliTesting
|
|
|
86
97
|
Termline.danger("Test suite failed", tag:'FAILURE')
|
|
87
98
|
end
|
|
88
99
|
|
|
89
|
-
Termline.br
|
|
100
|
+
Termline.br 2
|
|
90
101
|
|
|
91
102
|
print_failure_details if total_failures.positive? || total_errors.positive?
|
|
92
103
|
|
|
@@ -104,7 +115,8 @@ module LesliTesting
|
|
|
104
115
|
failure_tag = failure.is_a?(Minitest::Assertion) ? "FAILURE" : "ERROR"
|
|
105
116
|
failure_msg = "#{result.class}##{result.name} (#{result.assertions} asserts)"
|
|
106
117
|
|
|
107
|
-
|
|
118
|
+
file, line = result.source_location
|
|
119
|
+
location_file = file ? "#{file} (line: #{line})" : "Location unknown"
|
|
108
120
|
|
|
109
121
|
Termline.br
|
|
110
122
|
Termline.line(6)
|
|
@@ -116,6 +128,7 @@ module LesliTesting
|
|
|
116
128
|
if failure.is_a?(Minitest::Assertion)
|
|
117
129
|
result.failure.message.to_s.lines.each do |message|
|
|
118
130
|
puts(parse_minitest_assertion_messages(message))
|
|
131
|
+
#puts(parse_minitest_assertion_messages2(message))
|
|
119
132
|
end
|
|
120
133
|
end
|
|
121
134
|
end
|
|
@@ -123,12 +136,42 @@ module LesliTesting
|
|
|
123
136
|
Termline.br
|
|
124
137
|
end
|
|
125
138
|
|
|
126
|
-
def
|
|
139
|
+
def parse_minitest_assertion_messages2 message
|
|
127
140
|
msg = message.strip
|
|
128
141
|
return Termline::Style.colorize(" + #{msg}", :green) if msg.start_with? "Expected:"
|
|
129
142
|
return Termline::Style.colorize(" - #{msg}", :red) if msg.start_with? "Actual:"
|
|
130
143
|
return Termline::Style.colorize(" #{Termline::Style.icon(:warning)} #{msg}", :yellow)
|
|
131
144
|
end
|
|
145
|
+
|
|
146
|
+
def parse_minitest_assertion_messages(message)
|
|
147
|
+
msg = message.strip
|
|
148
|
+
|
|
149
|
+
case msg
|
|
150
|
+
|
|
151
|
+
# 1. Boolean/Nil Failures (e.g., "Expected true to be nil" or "Expected false to be truthy")
|
|
152
|
+
when /Expected (.*) to be (nil|truthy|falsey)/, /Expected (.*) to be (.*)/
|
|
153
|
+
Termline::Style.colorize(" #{Termline::Style.icon(:info)} #{msg}", :skyblue)
|
|
154
|
+
|
|
155
|
+
# 2. Standard Diffs (Expected vs Actual)
|
|
156
|
+
when /^Expected:?\s+/
|
|
157
|
+
Termline::Style.colorize(" #{Termline::Style.icon(:add)} #{msg}", :green)
|
|
158
|
+
|
|
159
|
+
when /^Actual:?\s+/
|
|
160
|
+
Termline::Style.colorize(" #{Termline::Style.icon(:remove)} #{msg}", :red)
|
|
161
|
+
|
|
162
|
+
# 3. Rails Difference Failures (e.g., "User.count" didn't change by 1)
|
|
163
|
+
when /"(.*)" didn't change by (.*)/, /actual change was (.*)/
|
|
164
|
+
Termline::Style.colorize(" #{Termline::Style.icon(:warning)} #{msg}", :yellow)
|
|
165
|
+
|
|
166
|
+
# 4. Collection/Count Failures (e.g., Expected 5 elements, found 2)
|
|
167
|
+
when /Expected (.*) elements?, found (.*)/, /Expected exactly (.*) nodes/
|
|
168
|
+
Termline::Style.colorize(" #{Termline::Style.icon(:list)} #{msg}", :magenta)
|
|
169
|
+
|
|
170
|
+
# 5. Fallback for custom messages (anything else)
|
|
171
|
+
else
|
|
172
|
+
Termline::Style.colorize(" #{Termline::Style.icon(:arrow_right)} #{msg}", :gray)
|
|
173
|
+
end
|
|
174
|
+
end
|
|
132
175
|
end
|
|
133
176
|
end
|
|
134
177
|
end
|