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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 582a2365a947f562ffdbd75bfe09f5af077bb1309b12cd9adeb29c8886d13472
4
- data.tar.gz: a73846f568ac913e621716a49273000631fbbb9255e40e74e59db3f49b2cd41c
3
+ metadata.gz: d3f8b488a261e18bdf9030e0c369c534cd987341222892b3f397467ab382998b
4
+ data.tar.gz: bc20743265959a07b2acd5b1975b4d59eb9e30ab612d40621c1b8ccc1a86648e
5
5
  SHA512:
6
- metadata.gz: 9ddde3d544c159212ddcaf4aae80e9f0cd1294165cae78de2dacda04a7a667bf208479a64c38b6d65c4872cdf5229935bfacc3bdd80b4db0dc1be9a66a7f9aed
7
- data.tar.gz: a035d7f5b72ab485137995eeb8c70102c4ac5e2dd1220a590c40f9bd4732dcdbaadce35bc89f3689f7d103816078570cd053479c99dcb27c466e6e4dc209f920
6
+ metadata.gz: 17f37531c01a9a60131c69bd6cb87c6b4cb8b9a56ab54ddf1cfc04520fda3eb2f03d998f4b1c814ff4f29813ffb93280dbc940a28ba5b23de18d7b81c6b0861b
7
+ data.tar.gz: e29091cc308623a4f80d4423968c22d6882785dbf4712441567e3435e56f7fc1839e3120e6409fab285542fdae81d532ba364e71e29cea3efc18cfcb3c04f961
@@ -55,16 +55,19 @@ module LesliTesting
55
55
 
56
56
  class << self
57
57
 
58
- def start_coverage!(engine_module = nil, options = {})
59
- return if defined?(SimpleCov) && SimpleCov.running
58
+ attr_accessor :engine_module;
60
59
 
61
- name = engine_module ? engine_module.name : "RailsApp"
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(name, options[:min_coverage] || 40)
67
+ LesliTesting::Coverage.start(engine_module, options[:min_coverage] || 40)
65
68
  end
66
69
 
67
- def configure_tests!(engine_module = nil)
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(" Running Lesli tests...", :blue),
12
- Termline::Style.colorize(" -> For a better result run test over a clean database", :blue),
13
- Termline::Style.colorize(" -> You can use: rake dev:db:reset", :blue)
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
- Termline.br
18
+
19
+ Termline.br 2
16
20
  end
17
21
 
18
22
  def record(test)
19
23
  super
20
24
 
21
- assert_color = :green
22
- assert_color = :yellow if test.assertions < 5
23
- assert_color = :red if test.assertions < 2
24
-
25
- parts = []
26
- parts << Termline::Style.colorize('['+Time.now.strftime('%H:%M:%S:%L')+']', :gray)
27
-
28
- case test.result_code
29
- when "."
30
- parts << Termline::Style.colorize("PASS", :green)
31
- when "F"
32
- parts << Termline::Style.colorize("FAIL", :red)
33
- when "E"
34
- parts << Termline::Style.colorize("ERROR", :red)
35
- when "S"
36
- parts << Termline::Style.colorize("SKIP", :yellow)
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
- parts << Termline::Style.colorize(test.klass, :blue)
41
- parts << '->'
42
- parts << Termline::Style.colorize(test.name, :skyblue)
43
- parts << Termline::Style.colorize("(#{ test.assertions} asserts)", assert_color)
44
- parts << Termline::Style.colorize("#{"(%.2fs)" % test.time}", :red) if test.time > 1
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.compact.join(" ").strip)
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
- location_file = "#{result.source_location.first} (line: #{result.source_location.second})"
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 parse_minitest_assertion_messages message
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LesliTesting
4
- VERSION = "1.2.2"
5
- BUILD = "1774678451"
4
+ VERSION = "1.2.3"
5
+ BUILD = "1775000800"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lesli_testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Lesli Development Team