minitest-retry 0.2.1 → 0.2.2

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: ee8f32526c33316323c344291e448fff7a4107a4d98af04a0fb7fc8b645a3678
4
- data.tar.gz: a139a0a4ea5c047e0216903832b688ac1f33e64e78c24ddfed81c624fe4811b1
3
+ metadata.gz: 986ef3b3ffb779d7f4351d864c93d932226cbef9653fa7f5bc208502f46586b2
4
+ data.tar.gz: 5e0a10b926b1aa02e08289c017379b68a4b6741dd5572e66ed5fb7aaba5a9d66
5
5
  SHA512:
6
- metadata.gz: '048d1154af57d771bfa0022ca6686844afda442227c51a123111b101fdd527a0f1029633f0c8aa2783d453963f9c45bd1fe4efc72bbe72f6502fe6979f2b602a'
7
- data.tar.gz: 9323ed80ec1a7df777504f6b25e602907994d56c4dfea2431124a682c10ead588088e87747dbf1e4cb3a941ccbaf4276538fa00b40e93bfef7ea97771487353c
6
+ metadata.gz: 800c226cf0c6f93553db2e2e242a46fbddcd6f048c2c266db7c4ceec0ab50186601e46e858ac512d3075aead1c23e79067ee887f1552fe3bb12275d097f1cb43
7
+ data.tar.gz: eb564f112cad335895e657924e437240db612dd1d2afde35f2da2d30aeed5ed25805641287ba69a93ec996a31563630ba6acdb7f4ff837029c1ac361dfe8cf0a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.2
2
+
3
+ * Add `methods_to_retry` option #33 [edudepetris]
4
+
1
5
  ## 0.2.1
2
6
 
3
7
  * Pass a test result to consistent failure callback #30 [rmacklin]
data/README.md CHANGED
@@ -37,7 +37,8 @@ Minitest::Retry.use!(
37
37
  retry_count: 3, # The number of times to retry. The default is 3.
38
38
  verbose: true, # Whether or not to display the message at the time of retry. The default is true.
39
39
  io: $stdout, # Display destination of retry when the message. The default is stdout.
40
- exceptions_to_retry: [] # List of exceptions that will trigger a retry (when empty, all exceptions will).
40
+ exceptions_to_retry: [], # List of exceptions that will trigger a retry (when empty, all exceptions will).
41
+ methods_to_retry: [] # List of methods that will trigger a retry (when empty, all methods will).
41
42
  )
42
43
  ```
43
44
 
@@ -3,8 +3,8 @@ require "minitest/retry/version"
3
3
  module Minitest
4
4
  module Retry
5
5
  class << self
6
- def use!(retry_count: 3, io: $stdout, verbose: true, exceptions_to_retry: [])
7
- @retry_count, @io, @verbose, @exceptions_to_retry = retry_count, io, verbose, exceptions_to_retry
6
+ def use!(retry_count: 3, io: $stdout, verbose: true, exceptions_to_retry: [], methods_to_retry: [])
7
+ @retry_count, @io, @verbose, @exceptions_to_retry, @methods_to_retry = retry_count, io, verbose, exceptions_to_retry, methods_to_retry
8
8
  @failure_callback, @consistent_failure_callback, @retry_callback = nil, nil, nil
9
9
  Minitest.prepend(self)
10
10
  end
@@ -40,6 +40,10 @@ module Minitest
40
40
  @exceptions_to_retry
41
41
  end
42
42
 
43
+ def methods_to_retry
44
+ @methods_to_retry
45
+ end
46
+
43
47
  def failure_callback
44
48
  @failure_callback
45
49
  end
@@ -52,8 +56,13 @@ module Minitest
52
56
  @retry_callback
53
57
  end
54
58
 
55
- def failure_to_retry?(failures = [])
59
+ def failure_to_retry?(failures = [], klass_method_name)
56
60
  return false if failures.empty?
61
+
62
+ if methods_to_retry.any?
63
+ return methods_to_retry.include?(klass_method_name)
64
+ end
65
+
57
66
  return true if Minitest::Retry.exceptions_to_retry.empty?
58
67
  errors = failures.map(&:error).map(&:class)
59
68
  (errors & Minitest::Retry.exceptions_to_retry).any?
@@ -63,7 +72,9 @@ module Minitest
63
72
  module ClassMethods
64
73
  def run_one_method(klass, method_name)
65
74
  result = super(klass, method_name)
66
- return result unless Minitest::Retry.failure_to_retry?(result.failures)
75
+
76
+ klass_method_name = "#{klass.name}##{method_name}"
77
+ return result unless Minitest::Retry.failure_to_retry?(result.failures, klass_method_name)
67
78
  if !result.skipped?
68
79
  Minitest::Retry.failure_callback.call(klass, method_name, result) if Minitest::Retry.failure_callback
69
80
  Minitest::Retry.retry_count.times do |count|
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Retry
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-retry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Yaginuma
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2021-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest