Module: Minitest::Retry
- Defined in:
- lib/minitest/retry.rb,
lib/minitest/retry/version.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
"0.2.3"
Class Method Summary collapse
- .classes_to_retry ⇒ Object
- .consistent_failure_callback ⇒ Object
- .exceptions_to_retry ⇒ Object
- .failure_callback ⇒ Object
- .failure_to_retry?(failures = [], klass_method_name, klass) ⇒ Boolean
- .io ⇒ Object
- .methods_to_retry ⇒ Object
- .on_consistent_failure(&block) ⇒ Object
- .on_failure(&block) ⇒ Object
- .on_retry(&block) ⇒ Object
- .prepended(base) ⇒ Object
- .retry_callback ⇒ Object
- .retry_count ⇒ Object
- .use!(retry_count: 3, io: $stdout, verbose: true, exceptions_to_retry: [], methods_to_retry: [], classes_to_retry: []) ⇒ Object
- .verbose ⇒ Object
Class Method Details
.classes_to_retry ⇒ Object
47 48 49 |
# File 'lib/minitest/retry.rb', line 47 def classes_to_retry @classes_to_retry end |
.consistent_failure_callback ⇒ Object
55 56 57 |
# File 'lib/minitest/retry.rb', line 55 def consistent_failure_callback @consistent_failure_callback end |
.exceptions_to_retry ⇒ Object
39 40 41 |
# File 'lib/minitest/retry.rb', line 39 def exceptions_to_retry @exceptions_to_retry end |
.failure_callback ⇒ Object
51 52 53 |
# File 'lib/minitest/retry.rb', line 51 def failure_callback @failure_callback end |
.failure_to_retry?(failures = [], klass_method_name, klass) ⇒ Boolean
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/minitest/retry.rb', line 63 def failure_to_retry?(failures = [], klass_method_name, klass) return false if failures.empty? if methods_to_retry.any? return methods_to_retry.include?(klass_method_name) end if exceptions_to_retry.any? errors = failures.map(&:error).map(&:class) return (errors & exceptions_to_retry).any? end return true if classes_to_retry.empty? ancestors = klass.ancestors.map(&:to_s) return classes_to_retry.any? { |class_to_retry| ancestors.include?(class_to_retry) } end |
.io ⇒ Object
31 32 33 |
# File 'lib/minitest/retry.rb', line 31 def io @io end |
.methods_to_retry ⇒ Object
43 44 45 |
# File 'lib/minitest/retry.rb', line 43 def methods_to_retry @methods_to_retry end |
.on_consistent_failure(&block) ⇒ Object
17 18 19 20 |
# File 'lib/minitest/retry.rb', line 17 def on_consistent_failure(&block) return unless block_given? @consistent_failure_callback = block end |
.on_failure(&block) ⇒ Object
12 13 14 15 |
# File 'lib/minitest/retry.rb', line 12 def on_failure(&block) return unless block_given? @failure_callback = block end |
.on_retry(&block) ⇒ Object
22 23 24 25 |
# File 'lib/minitest/retry.rb', line 22 def on_retry(&block) return unless block_given? @retry_callback = block end |
.prepended(base) ⇒ Object
109 110 111 112 113 |
# File 'lib/minitest/retry.rb', line 109 def self.prepended(base) class << base prepend ClassMethods end end |
.retry_callback ⇒ Object
59 60 61 |
# File 'lib/minitest/retry.rb', line 59 def retry_callback @retry_callback end |
.retry_count ⇒ Object
27 28 29 |
# File 'lib/minitest/retry.rb', line 27 def retry_count @retry_count end |
.use!(retry_count: 3, io: $stdout, verbose: true, exceptions_to_retry: [], methods_to_retry: [], classes_to_retry: []) ⇒ Object
6 7 8 9 10 |
# File 'lib/minitest/retry.rb', line 6 def use!(retry_count: 3, io: $stdout, verbose: true, exceptions_to_retry: [], methods_to_retry: [], classes_to_retry: []) @retry_count, @io, @verbose, @exceptions_to_retry, @methods_to_retry, @classes_to_retry = retry_count, io, verbose, exceptions_to_retry, methods_to_retry, classes_to_retry @failure_callback, @consistent_failure_callback, @retry_callback = nil, nil, nil Minitest.prepend(self) end |
.verbose ⇒ Object
35 36 37 |
# File 'lib/minitest/retry.rb', line 35 def verbose @verbose end |