minitest-utils 0.5.5 → 0.5.6

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: d692e7aebfdb3b534d238231824d8bd4296a48a516fdedbb92e8eefb7d696767
4
- data.tar.gz: 24c4d46362aa1cf905f4594b26d21cd1c21e55044fcd1071f1844b521e393538
3
+ metadata.gz: 2dd3332349124b344a5c54b49a5a68b625a5866438350ecb8753d196748bf979
4
+ data.tar.gz: 99785612b3df911aa58f0975740001532cb11be661266a4d90b8d936a9243c4e
5
5
  SHA512:
6
- metadata.gz: 656cfb1af22c4854ed4fbb396e20869f1956c0ae3808fa55de53061041550d310bec14b7b3b91714cd1303faa167bb074ed6a9068e42cc894af5b160f870ee59
7
- data.tar.gz: d6111257a0d64ca69d16544f5563e8ba635a094c66e6314a1a907fa48862c62f734a826557687744fd2cf35a0e5096d2fd3e44f29c62e1fc31f078d922d4b32b
6
+ metadata.gz: a22c26e74ffca9d640b87610400d1d5898cec8aa00d969ce7ac6f97c75562a4f5e189f3a74faafc12fe1214b7115e81f160190e3480a4faed2e04128f1e18345
7
+ data.tar.gz: 70c5322c8d76806706e0721360785d983ffb5697e09bafcd97fa4e89557dee62cfc5e99888a92d9ee58db5ba4800e02ebfd92b57c5f7f68e4ab4dc678ac73001
@@ -22,7 +22,16 @@ module Minitest
22
22
  @tests ||= {}
23
23
  end
24
24
 
25
- def self.test(name, &block)
25
+ def self.test_method_name(description)
26
+ method_name = description.downcase
27
+ .gsub(/[^a-z0-9]+/, "_")
28
+ .gsub(/^_+/, "")
29
+ .gsub(/_+$/, "")
30
+ .squeeze("_")
31
+ "test_#{method_name}".to_sym
32
+ end
33
+
34
+ def self.test(description, &block)
26
35
  source_location = caller_locations(1..1).first
27
36
  source_location = [
28
37
  Pathname(source_location.path).relative_path_from(Pathname(Dir.pwd)),
@@ -30,14 +39,11 @@ module Minitest
30
39
  ]
31
40
 
32
41
  klass = self.name
33
- method_name = name.downcase
34
- .gsub(/[^a-z0-9]+/, "_")
35
- .gsub(/^_+/, "")
36
- .gsub(/_+$/, "").squeeze("_")
37
- test_name = "test_#{method_name}".to_sym
42
+ test_name = test_method_name(description)
38
43
  defined = method_defined?(test_name)
39
44
 
40
45
  Test.tests["#{klass}##{test_name}"] = {
46
+ description:,
41
47
  name: name,
42
48
  source_location:,
43
49
  benchmark: nil
@@ -158,10 +158,10 @@ module Minitest
158
158
  end
159
159
 
160
160
  private def display_replay_command(result)
161
- location, line = find_test_file(result)
162
- return if location.empty?
161
+ test = find_test_file(result)
162
+ return if test[:source_location].empty?
163
163
 
164
- command = build_test_command(location, line, result)
164
+ command = build_test_command(test, result)
165
165
 
166
166
  output = ["\n"]
167
167
  output << color(command, :red)
@@ -170,9 +170,7 @@ module Minitest
170
170
  end
171
171
 
172
172
  private def find_test_file(result)
173
- info = Test.tests.fetch("#{result.klass}##{result.name}")
174
-
175
- info[:source_location]
173
+ Test.tests.fetch("#{result.klass}##{result.name}")
176
174
  end
177
175
 
178
176
  private def backtrace(backtrace)
@@ -199,13 +197,14 @@ module Minitest
199
197
 
200
198
  return location unless location.start_with?(Dir.pwd)
201
199
 
202
- location.gsub(%r{^#{Regexp.escape(Dir.pwd)}/}, "")
200
+ location.delete_prefix("#{Dir.pwd}/")
203
201
  end
204
202
 
205
203
  private def filter_backtrace(backtrace)
206
204
  Minitest.backtrace_filter
207
205
  .filter(backtrace)
208
206
  .reject {|line| Reporter.filters.any? { line.match?(_1) } }
207
+ .reject {|line| !line.start_with?(Dir.pwd) }
209
208
  end
210
209
 
211
210
  private def result_name(name)
@@ -249,12 +248,15 @@ module Minitest
249
248
  Rails.version >= "5.0.0"
250
249
  end
251
250
 
252
- private def build_test_command(location, line, result)
251
+ private def build_test_command(test, result)
252
+ location, line = test[:source_location]
253
+
253
254
  if ENV["MINITEST_TEST_COMMAND"]
254
255
  return format(
255
256
  ENV["MINITEST_TEST_COMMAND"],
256
257
  location: location,
257
258
  line: line,
259
+ description: test[:description],
258
260
  name: result.name
259
261
  )
260
262
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minitest
4
4
  module Utils
5
- VERSION = "0.5.5"
5
+ VERSION = "0.5.6"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-02 00:00:00.000000000 Z
10
+ date: 2025-03-11 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: benchmark
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  - !ruby/object:Gem::Version
177
177
  version: '0'
178
178
  requirements: []
179
- rubygems_version: 3.6.2
179
+ rubygems_version: 3.6.4
180
180
  specification_version: 4
181
181
  summary: Some utilities for your Minitest day-to-day usage.
182
182
  test_files: []