Module: DeepTest::ObjectExtension
- Defined in:
- lib/deep_test/extensions/object_extension.rb
Instance Method Summary collapse
Instance Method Details
#capture_stderr ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/deep_test/extensions/object_extension.rb', line 12 def capture_stderr old_stderr, $stderr = $stderr, StringIO.new yield $stderr.string ensure $stderr = old_stderr if old_stderr end |
#capture_stdout ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/deep_test/extensions/object_extension.rb', line 4 def capture_stdout old_stdout, $stdout = $stdout, StringIO.new yield $stdout.string ensure $stdout = old_stdout if old_stdout end |
#retrying(description = nil, times = 5) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/deep_test/extensions/object_extension.rb', line 20 def (description = nil, times = 5) i = 0 loop do begin return yield rescue => e i += 1 print "#{description} received exception #{e}. " if i < times puts "Retrying..." sleep 0.5 else puts "Aborting." raise e end end end end |